@wecode-team/cms-supabase-api 0.1.43 → 0.1.45
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/handlers/configs.d.ts +23 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +1400 -759
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1402 -758
- package/dist/index.js.map +1 -1
- package/dist/utils/route-helpers.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -28,6 +28,16 @@ function _asyncToGenerator(n) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function _typeof$1(o) {
|
|
32
|
+
"@babel/helpers - typeof";
|
|
33
|
+
|
|
34
|
+
return _typeof$1 = "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$1(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
|
}
|
|
@@ -37,12 +47,11 @@ var regeneratorRuntime$1 = {exports: {}};
|
|
|
37
47
|
var OverloadYield = {exports: {}};
|
|
38
48
|
|
|
39
49
|
(function (module) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
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);
|
|
46
55
|
var OverloadYieldExports = OverloadYield.exports;
|
|
47
56
|
|
|
48
57
|
var regenerator$1 = {exports: {}};
|
|
@@ -50,124 +59,122 @@ var regenerator$1 = {exports: {}};
|
|
|
50
59
|
var regeneratorDefine = {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
|
-
|
|
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);
|
|
77
85
|
var regeneratorDefineExports = regeneratorDefine.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
|
-
|
|
88
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
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$1);
|
|
171
178
|
var regeneratorExports = regenerator$1.exports;
|
|
172
179
|
|
|
173
180
|
var regeneratorAsync = {exports: {}};
|
|
@@ -177,206 +184,199 @@ var regeneratorAsyncGen = {exports: {}};
|
|
|
177
184
|
var regeneratorAsyncIterator = {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
|
-
|
|
187
|
+
var OverloadYield = OverloadYieldExports;
|
|
188
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
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);
|
|
215
221
|
var regeneratorAsyncIteratorExports = regeneratorAsyncIterator.exports;
|
|
216
222
|
|
|
217
223
|
(function (module) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
224
|
+
var regenerator = regeneratorExports;
|
|
225
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
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);
|
|
226
231
|
var regeneratorAsyncGenExports = regeneratorAsyncGen.exports;
|
|
227
232
|
|
|
228
233
|
(function (module) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
234
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
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);
|
|
239
243
|
var regeneratorAsyncExports = regeneratorAsync.exports;
|
|
240
244
|
|
|
241
245
|
var regeneratorKeys = {exports: {}};
|
|
242
246
|
|
|
243
247
|
(function (module) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
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);
|
|
256
259
|
var regeneratorKeysExports = regeneratorKeys.exports;
|
|
257
260
|
|
|
258
261
|
var regeneratorValues = {exports: {}};
|
|
259
262
|
|
|
260
|
-
var _typeof
|
|
263
|
+
var _typeof = {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);
|
|
277
|
+
var _typeofExports = _typeof.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
|
-
|
|
280
|
+
var _typeof = _typeofExports["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);
|
|
299
300
|
var regeneratorValuesExports = regeneratorValues.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;
|
|
304
|
+
var regenerator = regeneratorExports;
|
|
305
|
+
var regeneratorAsync = regeneratorAsyncExports;
|
|
306
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
307
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
308
|
+
var regeneratorKeys = regeneratorKeysExports;
|
|
309
|
+
var regeneratorValues = regeneratorValuesExports;
|
|
310
|
+
function _regeneratorRuntime() {
|
|
379
311
|
|
|
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$1);
|
|
380
380
|
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
381
381
|
|
|
382
382
|
// TODO(Babel 8): Remove this file.
|
|
@@ -388,13 +388,12 @@ var regenerator = runtime;
|
|
|
388
388
|
try {
|
|
389
389
|
regeneratorRuntime = runtime;
|
|
390
390
|
} catch (accidentalStrictMode) {
|
|
391
|
-
if (typeof globalThis === "object") {
|
|
391
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$1(globalThis)) === "object") {
|
|
392
392
|
globalThis.regeneratorRuntime = runtime;
|
|
393
393
|
} else {
|
|
394
394
|
Function("r", "regeneratorRuntime = r")(runtime);
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
|
|
398
397
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
399
398
|
|
|
400
399
|
var supabaseInstance = null;
|
|
@@ -678,22 +677,12 @@ function _classCallCheck(a, n) {
|
|
|
678
677
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
679
678
|
}
|
|
680
679
|
|
|
681
|
-
function _typeof(o) {
|
|
682
|
-
"@babel/helpers - typeof";
|
|
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
680
|
function toPrimitive(t, r) {
|
|
692
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
681
|
+
if ("object" != _typeof$1(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$1(i)) return i;
|
|
697
686
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
698
687
|
}
|
|
699
688
|
return ("string" === r ? String : Number)(t);
|
|
@@ -701,7 +690,7 @@ function toPrimitive(t, r) {
|
|
|
701
690
|
|
|
702
691
|
function toPropertyKey(t) {
|
|
703
692
|
var i = toPrimitive(t, "string");
|
|
704
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
693
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
705
694
|
}
|
|
706
695
|
|
|
707
696
|
function _defineProperties(e, r) {
|
|
@@ -1018,8 +1007,8 @@ function _defineProperty(e, r, t) {
|
|
|
1018
1007
|
}) : e[r] = t, e;
|
|
1019
1008
|
}
|
|
1020
1009
|
|
|
1021
|
-
function ownKeys$
|
|
1022
|
-
function _objectSpread$
|
|
1010
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1011
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1023
1012
|
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
1024
1013
|
function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
|
|
1025
1014
|
function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -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$5({
|
|
2078
2067
|
id: item.id,
|
|
2079
2068
|
label: item[displayField] || "ID: ".concat(item.id)
|
|
2080
2069
|
}, item);
|
|
@@ -2187,8 +2176,8 @@ function getDynamicTableService() {
|
|
|
2187
2176
|
return defaultService$1;
|
|
2188
2177
|
}
|
|
2189
2178
|
|
|
2190
|
-
function ownKeys$
|
|
2191
|
-
function _objectSpread$
|
|
2179
|
+
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; }
|
|
2180
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2192
2181
|
var AuthService = /*#__PURE__*/function () {
|
|
2193
2182
|
function AuthService() {
|
|
2194
2183
|
_classCallCheck(this, AuthService);
|
|
@@ -2365,7 +2354,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2365
2354
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
2366
2355
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2367
2356
|
case 0:
|
|
2368
|
-
finalUserData = _objectSpread$
|
|
2357
|
+
finalUserData = _objectSpread$4({
|
|
2369
2358
|
tableName: this.defaultTableName
|
|
2370
2359
|
}, userData);
|
|
2371
2360
|
_context4.prev = 1;
|
|
@@ -2423,7 +2412,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2423
2412
|
case 0:
|
|
2424
2413
|
updateData = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
2425
2414
|
// 设置默认值
|
|
2426
|
-
finalUpdateData = _objectSpread$
|
|
2415
|
+
finalUpdateData = _objectSpread$4({
|
|
2427
2416
|
tableName: this.defaultTableName
|
|
2428
2417
|
}, updateData);
|
|
2429
2418
|
_context5.prev = 1;
|
|
@@ -2723,7 +2712,7 @@ function _assertThisInitialized(e) {
|
|
|
2723
2712
|
}
|
|
2724
2713
|
|
|
2725
2714
|
function _possibleConstructorReturn(t, e) {
|
|
2726
|
-
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
|
|
2715
|
+
if (e && ("object" == _typeof$1(e) || "function" == typeof e)) return e;
|
|
2727
2716
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2728
2717
|
return _assertThisInitialized(t);
|
|
2729
2718
|
}
|
|
@@ -2761,17 +2750,17 @@ function _isNativeFunction(t) {
|
|
|
2761
2750
|
}
|
|
2762
2751
|
}
|
|
2763
2752
|
|
|
2764
|
-
function _isNativeReflectConstruct$
|
|
2753
|
+
function _isNativeReflectConstruct$2() {
|
|
2765
2754
|
try {
|
|
2766
2755
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2767
2756
|
} catch (t) {}
|
|
2768
|
-
return (_isNativeReflectConstruct$
|
|
2757
|
+
return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() {
|
|
2769
2758
|
return !!t;
|
|
2770
2759
|
})();
|
|
2771
2760
|
}
|
|
2772
2761
|
|
|
2773
2762
|
function _construct(t, e, r) {
|
|
2774
|
-
if (_isNativeReflectConstruct$
|
|
2763
|
+
if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments);
|
|
2775
2764
|
var o = [null];
|
|
2776
2765
|
o.push.apply(o, e);
|
|
2777
2766
|
var p = new (t.bind.apply(t, o))();
|
|
@@ -2801,6 +2790,40 @@ function _wrapNativeSuper(t) {
|
|
|
2801
2790
|
}, _wrapNativeSuper(t);
|
|
2802
2791
|
}
|
|
2803
2792
|
|
|
2793
|
+
function _arrayLikeToArray$2(r, a) {
|
|
2794
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2795
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2796
|
+
return n;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
function _arrayWithoutHoles(r) {
|
|
2800
|
+
if (Array.isArray(r)) return _arrayLikeToArray$2(r);
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
function _iterableToArray(r) {
|
|
2804
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
function _unsupportedIterableToArray$2(r, a) {
|
|
2808
|
+
if (r) {
|
|
2809
|
+
if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
|
|
2810
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2811
|
+
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$2(r, a) : void 0;
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
function _nonIterableSpread() {
|
|
2816
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
function _toConsumableArray(r) {
|
|
2820
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread();
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
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; }
|
|
2824
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2825
|
+
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)); }
|
|
2826
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2804
2827
|
// src/error.ts
|
|
2805
2828
|
var ErrorCode = {
|
|
2806
2829
|
/** 网络错误(断网、DNS 解析失败等) */
|
|
@@ -2816,117 +2839,170 @@ var ErrorCode = {
|
|
|
2816
2839
|
/** 存储服务未启用 */
|
|
2817
2840
|
STORAGE_DISABLED: 503
|
|
2818
2841
|
};
|
|
2819
|
-
var OssError =
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
this
|
|
2823
|
-
|
|
2824
|
-
|
|
2842
|
+
var OssError = /*#__PURE__*/function (_Error) {
|
|
2843
|
+
function OssError(code, message) {
|
|
2844
|
+
var _this;
|
|
2845
|
+
_classCallCheck(this, OssError);
|
|
2846
|
+
_this = _callSuper$1(this, OssError, [message]);
|
|
2847
|
+
_this.name = "OssError";
|
|
2848
|
+
_this.code = code;
|
|
2849
|
+
_this.isRetryable = code === ErrorCode.NETWORK || code === ErrorCode.TIMEOUT || code >= 500;
|
|
2850
|
+
return _this;
|
|
2825
2851
|
}
|
|
2826
|
-
|
|
2852
|
+
_inherits(OssError, _Error);
|
|
2853
|
+
return _createClass(OssError);
|
|
2854
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
2827
2855
|
|
|
2828
2856
|
// src/validate.ts
|
|
2829
2857
|
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
|
-
]
|
|
2858
|
+
// 图片
|
|
2859
|
+
{
|
|
2860
|
+
ext: ["jpg", "jpeg"],
|
|
2861
|
+
bytes: [255, 216, 255]
|
|
2862
|
+
}, {
|
|
2863
|
+
ext: ["png"],
|
|
2864
|
+
bytes: [137, 80, 78, 71, 13, 10, 26, 10]
|
|
2865
|
+
}, {
|
|
2866
|
+
ext: ["gif"],
|
|
2867
|
+
bytes: [71, 73, 70, 56]
|
|
2868
|
+
}, {
|
|
2869
|
+
ext: ["bmp"],
|
|
2870
|
+
bytes: [66, 77]
|
|
2871
|
+
}, {
|
|
2872
|
+
ext: ["webp"],
|
|
2873
|
+
bytes: [87, 69, 66, 80],
|
|
2874
|
+
offset: 8
|
|
2875
|
+
}, {
|
|
2876
|
+
ext: ["ico"],
|
|
2877
|
+
bytes: [0, 0, 1, 0]
|
|
2878
|
+
}, {
|
|
2879
|
+
ext: ["svg"],
|
|
2880
|
+
bytes: []
|
|
2881
|
+
},
|
|
2882
|
+
// SVG 是文本,单独处理
|
|
2883
|
+
// 视频
|
|
2884
|
+
{
|
|
2885
|
+
ext: ["mp4", "m4v"],
|
|
2886
|
+
bytes: [102, 116, 121, 112],
|
|
2887
|
+
offset: 4
|
|
2888
|
+
}, {
|
|
2889
|
+
ext: ["webm"],
|
|
2890
|
+
bytes: [26, 69, 223, 163]
|
|
2891
|
+
}, {
|
|
2892
|
+
ext: ["avi"],
|
|
2893
|
+
bytes: [82, 73, 70, 70]
|
|
2894
|
+
}, {
|
|
2895
|
+
ext: ["mov"],
|
|
2896
|
+
bytes: [102, 116, 121, 112],
|
|
2897
|
+
offset: 4
|
|
2898
|
+
}, {
|
|
2899
|
+
ext: ["flv"],
|
|
2900
|
+
bytes: [70, 76, 86]
|
|
2901
|
+
}, {
|
|
2902
|
+
ext: ["mkv"],
|
|
2903
|
+
bytes: [26, 69, 223, 163]
|
|
2904
|
+
},
|
|
2905
|
+
// 文档
|
|
2906
|
+
{
|
|
2907
|
+
ext: ["pdf"],
|
|
2908
|
+
bytes: [37, 80, 68, 70]
|
|
2909
|
+
}];
|
|
2910
|
+
var DEFAULT_ALLOWED_EXTENSIONS = /* @__PURE__ */new Set([
|
|
2911
|
+
// 图片
|
|
2912
|
+
"jpg", "jpeg", "png", "gif", "webp", "bmp", "ico", "svg",
|
|
2913
|
+
// 视频
|
|
2914
|
+
"mp4", "webm", "mov", "avi", "mkv", "flv", "wmv", "m4v",
|
|
2915
|
+
// 文档
|
|
2916
|
+
"pdf",
|
|
2917
|
+
// 代码/文本
|
|
2918
|
+
"html", "css", "js", "ts", "json", "xml", "txt", "md", "csv"]);
|
|
2881
2919
|
function getExt(fileName) {
|
|
2882
2920
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
2883
2921
|
}
|
|
2884
2922
|
function validateExtension(fileName, allowedExtensions) {
|
|
2885
|
-
|
|
2886
|
-
|
|
2923
|
+
var ext = getExt(fileName);
|
|
2924
|
+
var whitelist = allowedExtensions !== null && allowedExtensions !== void 0 ? allowedExtensions : DEFAULT_ALLOWED_EXTENSIONS;
|
|
2887
2925
|
if (!ext) {
|
|
2888
|
-
throw new OssError(ErrorCode.INVALID_PARAMS,
|
|
2926
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u7F3A\u5C11\u6269\u5C55\u540D"));
|
|
2889
2927
|
}
|
|
2890
2928
|
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
|
-
);
|
|
2929
|
+
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
2930
|
}
|
|
2896
2931
|
}
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2932
|
+
function validateMagicBytes(_x, _x2) {
|
|
2933
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
2934
|
+
} // src/request.ts
|
|
2935
|
+
function _validateMagicBytes() {
|
|
2936
|
+
_validateMagicBytes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, fileName) {
|
|
2937
|
+
var _rule$offset;
|
|
2938
|
+
var ext, textExts, text, rule, offset, needed, headerBuf, header, matched;
|
|
2939
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
2940
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
2941
|
+
case 0:
|
|
2942
|
+
ext = getExt(fileName);
|
|
2943
|
+
textExts = /* @__PURE__ */new Set(["html", "css", "js", "ts", "json", "xml", "txt", "md", "csv", "svg"]);
|
|
2944
|
+
if (!textExts.has(ext)) {
|
|
2945
|
+
_context6.next = 3;
|
|
2946
|
+
break;
|
|
2947
|
+
}
|
|
2948
|
+
if (!(ext === "svg")) {
|
|
2949
|
+
_context6.next = 2;
|
|
2950
|
+
break;
|
|
2951
|
+
}
|
|
2952
|
+
_context6.next = 1;
|
|
2953
|
+
return blob.slice(0, 1024).text();
|
|
2954
|
+
case 1:
|
|
2955
|
+
text = _context6.sent;
|
|
2956
|
+
if (!(!text.includes("<svg") && !text.includes("<?xml"))) {
|
|
2957
|
+
_context6.next = 2;
|
|
2958
|
+
break;
|
|
2959
|
+
}
|
|
2960
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u4E0D\u662F\u6709\u6548\u7684 SVG \u6587\u4EF6"));
|
|
2961
|
+
case 2:
|
|
2962
|
+
return _context6.abrupt("return");
|
|
2963
|
+
case 3:
|
|
2964
|
+
rule = MAGIC_BYTES.find(function (r) {
|
|
2965
|
+
return r.ext.includes(ext);
|
|
2966
|
+
});
|
|
2967
|
+
if (!(!rule || rule.bytes.length === 0)) {
|
|
2968
|
+
_context6.next = 4;
|
|
2969
|
+
break;
|
|
2970
|
+
}
|
|
2971
|
+
return _context6.abrupt("return");
|
|
2972
|
+
case 4:
|
|
2973
|
+
offset = (_rule$offset = rule.offset) !== null && _rule$offset !== void 0 ? _rule$offset : 0;
|
|
2974
|
+
needed = offset + rule.bytes.length;
|
|
2975
|
+
if (!(blob.size < needed)) {
|
|
2976
|
+
_context6.next = 5;
|
|
2977
|
+
break;
|
|
2978
|
+
}
|
|
2979
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B"));
|
|
2980
|
+
case 5:
|
|
2981
|
+
_context6.next = 6;
|
|
2982
|
+
return blob.slice(0, needed).arrayBuffer();
|
|
2983
|
+
case 6:
|
|
2984
|
+
headerBuf = _context6.sent;
|
|
2985
|
+
header = new Uint8Array(headerBuf);
|
|
2986
|
+
matched = rule.bytes.every(function (_byte, i) {
|
|
2987
|
+
return header[offset + i] === _byte;
|
|
2988
|
+
});
|
|
2989
|
+
if (matched) {
|
|
2990
|
+
_context6.next = 7;
|
|
2991
|
+
break;
|
|
2992
|
+
}
|
|
2993
|
+
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"));
|
|
2994
|
+
case 7:
|
|
2995
|
+
case "end":
|
|
2996
|
+
return _context6.stop();
|
|
2905
2997
|
}
|
|
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
|
-
}
|
|
2998
|
+
}, _callee6);
|
|
2999
|
+
}));
|
|
3000
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
2925
3001
|
}
|
|
2926
|
-
|
|
2927
|
-
// src/request.ts
|
|
2928
3002
|
function sleep(ms) {
|
|
2929
|
-
return new Promise((resolve)
|
|
3003
|
+
return new Promise(function (resolve) {
|
|
3004
|
+
return setTimeout(resolve, ms);
|
|
3005
|
+
});
|
|
2930
3006
|
}
|
|
2931
3007
|
function parseJson(json) {
|
|
2932
3008
|
if (json.code !== 200) {
|
|
@@ -2934,160 +3010,327 @@ function parseJson(json) {
|
|
|
2934
3010
|
}
|
|
2935
3011
|
return json.data;
|
|
2936
3012
|
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
const controller = new AbortController();
|
|
2940
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
2941
|
-
let res;
|
|
2942
|
-
try {
|
|
2943
|
-
res = await fetch(url, {
|
|
2944
|
-
method: "POST",
|
|
2945
|
-
headers: { "Content-Type": "application/json" },
|
|
2946
|
-
body: JSON.stringify(body),
|
|
2947
|
-
signal: controller.signal
|
|
2948
|
-
});
|
|
2949
|
-
} catch (err) {
|
|
2950
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
2951
|
-
throw new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`);
|
|
2952
|
-
}
|
|
2953
|
-
throw new OssError(ErrorCode.NETWORK, `\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
2954
|
-
} finally {
|
|
2955
|
-
clearTimeout(timer);
|
|
2956
|
-
}
|
|
2957
|
-
let json;
|
|
2958
|
-
try {
|
|
2959
|
-
json = await res.json();
|
|
2960
|
-
} catch {
|
|
2961
|
-
throw new OssError(res.status, `\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ${res.status}\uFF09`);
|
|
2962
|
-
}
|
|
2963
|
-
return parseJson(json);
|
|
3013
|
+
function fetchJson(_x3, _x4, _x5, _x6) {
|
|
3014
|
+
return _fetchJson.apply(this, arguments);
|
|
2964
3015
|
}
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
3016
|
+
function _fetchJson() {
|
|
3017
|
+
_fetchJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(baseURL, timeout, path, body) {
|
|
3018
|
+
var url, controller, timer, res, json, _t;
|
|
3019
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
3020
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3021
|
+
case 0:
|
|
3022
|
+
url = "".concat(baseURL).concat(path);
|
|
3023
|
+
controller = new AbortController();
|
|
3024
|
+
timer = setTimeout(function () {
|
|
3025
|
+
return controller.abort();
|
|
3026
|
+
}, timeout);
|
|
3027
|
+
_context7.prev = 1;
|
|
3028
|
+
_context7.next = 2;
|
|
3029
|
+
return fetch(url, {
|
|
3030
|
+
method: "POST",
|
|
3031
|
+
headers: {
|
|
3032
|
+
"Content-Type": "application/json"
|
|
3033
|
+
},
|
|
3034
|
+
body: JSON.stringify(body),
|
|
3035
|
+
signal: controller.signal
|
|
3036
|
+
});
|
|
3037
|
+
case 2:
|
|
3038
|
+
res = _context7.sent;
|
|
3039
|
+
_context7.next = 5;
|
|
3040
|
+
break;
|
|
3041
|
+
case 3:
|
|
3042
|
+
_context7.prev = 3;
|
|
3043
|
+
_t = _context7["catch"](1);
|
|
3044
|
+
if (!(_t instanceof DOMException && _t.name === "AbortError")) {
|
|
3045
|
+
_context7.next = 4;
|
|
3046
|
+
break;
|
|
3047
|
+
}
|
|
3048
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3049
|
+
case 4:
|
|
3050
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t instanceof Error ? _t.message : String(_t)));
|
|
3051
|
+
case 5:
|
|
3052
|
+
_context7.prev = 5;
|
|
3053
|
+
clearTimeout(timer);
|
|
3054
|
+
return _context7.finish(5);
|
|
3055
|
+
case 6:
|
|
3056
|
+
_context7.prev = 6;
|
|
3057
|
+
_context7.next = 7;
|
|
3058
|
+
return res.json();
|
|
3059
|
+
case 7:
|
|
3060
|
+
json = _context7.sent;
|
|
3061
|
+
_context7.next = 9;
|
|
3062
|
+
break;
|
|
3063
|
+
case 8:
|
|
3064
|
+
_context7.prev = 8;
|
|
3065
|
+
_context7["catch"](6);
|
|
3066
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3067
|
+
case 9:
|
|
3068
|
+
return _context7.abrupt("return", parseJson(json));
|
|
3069
|
+
case 10:
|
|
3070
|
+
case "end":
|
|
3071
|
+
return _context7.stop();
|
|
3072
|
+
}
|
|
3073
|
+
}, _callee7, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3074
|
+
}));
|
|
3075
|
+
return _fetchJson.apply(this, arguments);
|
|
2991
3076
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3077
|
+
function fetchFormData(_x7, _x8, _x9, _x0) {
|
|
3078
|
+
return _fetchFormData.apply(this, arguments);
|
|
3079
|
+
}
|
|
3080
|
+
function _fetchFormData() {
|
|
3081
|
+
_fetchFormData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(baseURL, timeout, path, formData) {
|
|
3082
|
+
var url, controller, timer, res, json, _t3;
|
|
3083
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
3084
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3085
|
+
case 0:
|
|
3086
|
+
url = "".concat(baseURL).concat(path);
|
|
3087
|
+
controller = new AbortController();
|
|
3088
|
+
timer = setTimeout(function () {
|
|
3089
|
+
return controller.abort();
|
|
3090
|
+
}, timeout);
|
|
3091
|
+
_context8.prev = 1;
|
|
3092
|
+
_context8.next = 2;
|
|
3093
|
+
return fetch(url, {
|
|
3094
|
+
method: "POST",
|
|
3095
|
+
body: formData,
|
|
3096
|
+
signal: controller.signal
|
|
3097
|
+
});
|
|
3098
|
+
case 2:
|
|
3099
|
+
res = _context8.sent;
|
|
3100
|
+
_context8.next = 5;
|
|
3101
|
+
break;
|
|
3102
|
+
case 3:
|
|
3103
|
+
_context8.prev = 3;
|
|
3104
|
+
_t3 = _context8["catch"](1);
|
|
3105
|
+
if (!(_t3 instanceof DOMException && _t3.name === "AbortError")) {
|
|
3106
|
+
_context8.next = 4;
|
|
3107
|
+
break;
|
|
3108
|
+
}
|
|
3109
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3110
|
+
case 4:
|
|
3111
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t3 instanceof Error ? _t3.message : String(_t3)));
|
|
3112
|
+
case 5:
|
|
3113
|
+
_context8.prev = 5;
|
|
3114
|
+
clearTimeout(timer);
|
|
3115
|
+
return _context8.finish(5);
|
|
3116
|
+
case 6:
|
|
3117
|
+
_context8.prev = 6;
|
|
3118
|
+
_context8.next = 7;
|
|
3119
|
+
return res.json();
|
|
3120
|
+
case 7:
|
|
3121
|
+
json = _context8.sent;
|
|
3122
|
+
_context8.next = 9;
|
|
3123
|
+
break;
|
|
3124
|
+
case 8:
|
|
3125
|
+
_context8.prev = 8;
|
|
3126
|
+
_context8["catch"](6);
|
|
3127
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3128
|
+
case 9:
|
|
3129
|
+
return _context8.abrupt("return", parseJson(json));
|
|
3130
|
+
case 10:
|
|
3131
|
+
case "end":
|
|
3132
|
+
return _context8.stop();
|
|
3008
3133
|
}
|
|
3009
|
-
};
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3134
|
+
}, _callee8, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3135
|
+
}));
|
|
3136
|
+
return _fetchFormData.apply(this, arguments);
|
|
3137
|
+
}
|
|
3138
|
+
function fetchFormDataWithProgress(_x1, _x10, _x11, _x12, _x13) {
|
|
3139
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
3140
|
+
}
|
|
3141
|
+
function _fetchFormDataWithProgress() {
|
|
3142
|
+
_fetchFormDataWithProgress = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(baseURL, timeout, path, formData, onProgress) {
|
|
3143
|
+
var url;
|
|
3144
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
3145
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3146
|
+
case 0:
|
|
3147
|
+
if (!(typeof XMLHttpRequest === "undefined")) {
|
|
3148
|
+
_context9.next = 1;
|
|
3149
|
+
break;
|
|
3150
|
+
}
|
|
3151
|
+
return _context9.abrupt("return", fetchFormData(baseURL, timeout, path, formData));
|
|
3152
|
+
case 1:
|
|
3153
|
+
url = "".concat(baseURL).concat(path);
|
|
3154
|
+
return _context9.abrupt("return", new Promise(function (resolve, reject) {
|
|
3155
|
+
var xhr = new XMLHttpRequest();
|
|
3156
|
+
xhr.open("POST", url, true);
|
|
3157
|
+
xhr.timeout = timeout;
|
|
3158
|
+
xhr.upload.onprogress = function (e) {
|
|
3159
|
+
if (e.lengthComputable) {
|
|
3160
|
+
onProgress({
|
|
3161
|
+
loaded: e.loaded,
|
|
3162
|
+
total: e.total,
|
|
3163
|
+
percent: Math.round(e.loaded / e.total * 100)
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
};
|
|
3167
|
+
xhr.onload = function () {
|
|
3168
|
+
try {
|
|
3169
|
+
var json = JSON.parse(xhr.responseText);
|
|
3170
|
+
if (json.code !== 200) {
|
|
3171
|
+
reject(new OssError(json.code, json.message || json.error || "Unknown error"));
|
|
3172
|
+
} else {
|
|
3173
|
+
resolve(json.data);
|
|
3174
|
+
}
|
|
3175
|
+
} catch (_unused3) {
|
|
3176
|
+
reject(new OssError(xhr.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(xhr.status, "\uFF09")));
|
|
3177
|
+
}
|
|
3178
|
+
};
|
|
3179
|
+
xhr.onerror = function () {
|
|
3180
|
+
reject(new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25"));
|
|
3181
|
+
};
|
|
3182
|
+
xhr.ontimeout = function () {
|
|
3183
|
+
reject(new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09")));
|
|
3184
|
+
};
|
|
3185
|
+
xhr.send(formData);
|
|
3186
|
+
}));
|
|
3187
|
+
case 2:
|
|
3188
|
+
case "end":
|
|
3189
|
+
return _context9.stop();
|
|
3020
3190
|
}
|
|
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
|
-
});
|
|
3191
|
+
}, _callee9);
|
|
3192
|
+
}));
|
|
3193
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
3030
3194
|
}
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3195
|
+
function fetchGet(_x14, _x15, _x16) {
|
|
3196
|
+
return _fetchGet.apply(this, arguments);
|
|
3197
|
+
}
|
|
3198
|
+
function _fetchGet() {
|
|
3199
|
+
_fetchGet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(baseURL, timeout, path) {
|
|
3200
|
+
var url, controller, timer, res, json, _t5;
|
|
3201
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
3202
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
3203
|
+
case 0:
|
|
3204
|
+
url = "".concat(baseURL).concat(path);
|
|
3205
|
+
controller = new AbortController();
|
|
3206
|
+
timer = setTimeout(function () {
|
|
3207
|
+
return controller.abort();
|
|
3208
|
+
}, timeout);
|
|
3209
|
+
_context0.prev = 1;
|
|
3210
|
+
_context0.next = 2;
|
|
3211
|
+
return fetch(url, {
|
|
3212
|
+
method: "GET",
|
|
3213
|
+
signal: controller.signal
|
|
3214
|
+
});
|
|
3215
|
+
case 2:
|
|
3216
|
+
res = _context0.sent;
|
|
3217
|
+
_context0.next = 5;
|
|
3218
|
+
break;
|
|
3219
|
+
case 3:
|
|
3220
|
+
_context0.prev = 3;
|
|
3221
|
+
_t5 = _context0["catch"](1);
|
|
3222
|
+
if (!(_t5 instanceof DOMException && _t5.name === "AbortError")) {
|
|
3223
|
+
_context0.next = 4;
|
|
3224
|
+
break;
|
|
3225
|
+
}
|
|
3226
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3227
|
+
case 4:
|
|
3228
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t5 instanceof Error ? _t5.message : String(_t5)));
|
|
3229
|
+
case 5:
|
|
3230
|
+
_context0.prev = 5;
|
|
3231
|
+
clearTimeout(timer);
|
|
3232
|
+
return _context0.finish(5);
|
|
3233
|
+
case 6:
|
|
3234
|
+
_context0.prev = 6;
|
|
3235
|
+
_context0.next = 7;
|
|
3236
|
+
return res.json();
|
|
3237
|
+
case 7:
|
|
3238
|
+
json = _context0.sent;
|
|
3239
|
+
_context0.next = 9;
|
|
3240
|
+
break;
|
|
3241
|
+
case 8:
|
|
3242
|
+
_context0.prev = 8;
|
|
3243
|
+
_context0["catch"](6);
|
|
3244
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3245
|
+
case 9:
|
|
3246
|
+
return _context0.abrupt("return", parseJson(json));
|
|
3247
|
+
case 10:
|
|
3248
|
+
case "end":
|
|
3249
|
+
return _context0.stop();
|
|
3250
|
+
}
|
|
3251
|
+
}, _callee0, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3252
|
+
}));
|
|
3253
|
+
return _fetchGet.apply(this, arguments);
|
|
3254
|
+
}
|
|
3255
|
+
function withRetry(_x17, _x18) {
|
|
3256
|
+
return _withRetry.apply(this, arguments);
|
|
3257
|
+
}
|
|
3258
|
+
function _withRetry() {
|
|
3259
|
+
_withRetry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(fn, retry) {
|
|
3260
|
+
var _retry$retries, _retry$delay, _retry$backoff;
|
|
3261
|
+
var maxRetries, baseDelay, backoff, lastError, attempt, waitMs, _t7;
|
|
3262
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
3263
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
3264
|
+
case 0:
|
|
3265
|
+
maxRetries = (_retry$retries = retry === null || retry === void 0 ? void 0 : retry.retries) !== null && _retry$retries !== void 0 ? _retry$retries : 2;
|
|
3266
|
+
baseDelay = (_retry$delay = retry === null || retry === void 0 ? void 0 : retry.delay) !== null && _retry$delay !== void 0 ? _retry$delay : 1e3;
|
|
3267
|
+
backoff = (_retry$backoff = retry === null || retry === void 0 ? void 0 : retry.backoff) !== null && _retry$backoff !== void 0 ? _retry$backoff : 2;
|
|
3268
|
+
attempt = 0;
|
|
3269
|
+
case 1:
|
|
3270
|
+
if (!(attempt <= maxRetries)) {
|
|
3271
|
+
_context1.next = 8;
|
|
3272
|
+
break;
|
|
3273
|
+
}
|
|
3274
|
+
_context1.prev = 2;
|
|
3275
|
+
_context1.next = 3;
|
|
3276
|
+
return fn();
|
|
3277
|
+
case 3:
|
|
3278
|
+
return _context1.abrupt("return", _context1.sent);
|
|
3279
|
+
case 4:
|
|
3280
|
+
_context1.prev = 4;
|
|
3281
|
+
_t7 = _context1["catch"](2);
|
|
3282
|
+
lastError = _t7;
|
|
3283
|
+
if (lastError.isRetryable) {
|
|
3284
|
+
_context1.next = 5;
|
|
3285
|
+
break;
|
|
3286
|
+
}
|
|
3287
|
+
throw lastError;
|
|
3288
|
+
case 5:
|
|
3289
|
+
if (!(attempt >= maxRetries)) {
|
|
3290
|
+
_context1.next = 6;
|
|
3291
|
+
break;
|
|
3292
|
+
}
|
|
3293
|
+
return _context1.abrupt("continue", 8);
|
|
3294
|
+
case 6:
|
|
3295
|
+
waitMs = baseDelay * Math.pow(backoff, attempt);
|
|
3296
|
+
_context1.next = 7;
|
|
3297
|
+
return sleep(waitMs);
|
|
3298
|
+
case 7:
|
|
3299
|
+
attempt++;
|
|
3300
|
+
_context1.next = 1;
|
|
3301
|
+
break;
|
|
3302
|
+
case 8:
|
|
3303
|
+
throw lastError;
|
|
3304
|
+
case 9:
|
|
3305
|
+
case "end":
|
|
3306
|
+
return _context1.stop();
|
|
3307
|
+
}
|
|
3308
|
+
}, _callee1, null, [[2, 4]]);
|
|
3309
|
+
}));
|
|
3310
|
+
return _withRetry.apply(this, arguments);
|
|
3074
3311
|
}
|
|
3075
3312
|
function requestJsonWithRetry(baseURL, timeout, path, body, retry) {
|
|
3076
|
-
return withRetry(
|
|
3313
|
+
return withRetry(function () {
|
|
3314
|
+
return fetchJson(baseURL, timeout, path, body);
|
|
3315
|
+
}, retry);
|
|
3077
3316
|
}
|
|
3078
3317
|
function requestFormDataWithRetry(baseURL, timeout, path, formData, retry, onProgress) {
|
|
3079
3318
|
if (onProgress) {
|
|
3080
3319
|
return fetchFormDataWithProgress(baseURL, timeout, path, formData, onProgress);
|
|
3081
3320
|
}
|
|
3082
|
-
return withRetry(
|
|
3321
|
+
return withRetry(function () {
|
|
3322
|
+
return fetchFormData(baseURL, timeout, path, formData);
|
|
3323
|
+
}, retry);
|
|
3083
3324
|
}
|
|
3084
3325
|
function requestGetWithRetry(baseURL, timeout, path, retry) {
|
|
3085
|
-
return withRetry(
|
|
3326
|
+
return withRetry(function () {
|
|
3327
|
+
return fetchGet(baseURL, timeout, path);
|
|
3328
|
+
}, retry);
|
|
3086
3329
|
}
|
|
3087
3330
|
|
|
3088
3331
|
// src/compress.ts
|
|
3089
|
-
var IMAGE_EXTENSIONS = /* @__PURE__ */
|
|
3090
|
-
var VIDEO_EXTENSIONS = /* @__PURE__ */
|
|
3332
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */new Set(["jpg", "jpeg", "png", "webp", "bmp"]);
|
|
3333
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */new Set(["mp4", "webm", "mov", "avi", "mkv", "flv", "wmv"]);
|
|
3091
3334
|
function getExtension(fileName) {
|
|
3092
3335
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
3093
3336
|
}
|
|
@@ -3106,19 +3349,17 @@ var DEFAULT_LIMITS = {
|
|
|
3106
3349
|
other: 10 * 1024 * 1024
|
|
3107
3350
|
};
|
|
3108
3351
|
function getSizeLimit(fileName, limits) {
|
|
3109
|
-
|
|
3352
|
+
var merged = _objectSpread$3(_objectSpread$3({}, DEFAULT_LIMITS), limits);
|
|
3110
3353
|
if (isImage(fileName)) return merged.image;
|
|
3111
3354
|
if (isVideo(fileName)) return merged.video;
|
|
3112
3355
|
return merged.other;
|
|
3113
3356
|
}
|
|
3114
3357
|
function validateFileSize(blob, fileName, limits) {
|
|
3115
|
-
|
|
3358
|
+
var maxSize = getSizeLimit(fileName, limits);
|
|
3116
3359
|
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
|
-
);
|
|
3360
|
+
var sizeMB = (blob.size / 1024 / 1024).toFixed(1);
|
|
3361
|
+
var limitMB = (maxSize / 1024 / 1024).toFixed(1);
|
|
3362
|
+
throw new Error("\u6587\u4EF6 \"".concat(fileName, "\" \u5927\u5C0F ").concat(sizeMB, "MB \u8D85\u8FC7\u9650\u5236 ").concat(limitMB, "MB"));
|
|
3122
3363
|
}
|
|
3123
3364
|
}
|
|
3124
3365
|
var DEFAULT_COMPRESS = {
|
|
@@ -3127,71 +3368,119 @@ var DEFAULT_COMPRESS = {
|
|
|
3127
3368
|
imageMaxWidth: 1920,
|
|
3128
3369
|
imageMaxHeight: 1080
|
|
3129
3370
|
};
|
|
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
|
-
|
|
3371
|
+
function compressImageBlob(_x19, _x20) {
|
|
3372
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3373
|
+
}
|
|
3374
|
+
function _compressImageBlob() {
|
|
3375
|
+
_compressImageBlob = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(blob, options) {
|
|
3376
|
+
var opts, bitmap, srcW, srcH, targetW, targetH, canvas, ctx, ext, outputType, compressed;
|
|
3377
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
3378
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3379
|
+
case 0:
|
|
3380
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), options);
|
|
3381
|
+
if (!(typeof createImageBitmap === "undefined" || typeof OffscreenCanvas === "undefined")) {
|
|
3382
|
+
_context10.next = 1;
|
|
3383
|
+
break;
|
|
3384
|
+
}
|
|
3385
|
+
return _context10.abrupt("return", blob);
|
|
3386
|
+
case 1:
|
|
3387
|
+
_context10.prev = 1;
|
|
3388
|
+
_context10.next = 2;
|
|
3389
|
+
return createImageBitmap(blob);
|
|
3390
|
+
case 2:
|
|
3391
|
+
bitmap = _context10.sent;
|
|
3392
|
+
srcW = bitmap.width, srcH = bitmap.height;
|
|
3393
|
+
targetW = srcW;
|
|
3394
|
+
targetH = srcH;
|
|
3395
|
+
if (targetW > opts.imageMaxWidth) {
|
|
3396
|
+
targetH = Math.round(targetH * (opts.imageMaxWidth / targetW));
|
|
3397
|
+
targetW = opts.imageMaxWidth;
|
|
3398
|
+
}
|
|
3399
|
+
if (targetH > opts.imageMaxHeight) {
|
|
3400
|
+
targetW = Math.round(targetW * (opts.imageMaxHeight / targetH));
|
|
3401
|
+
targetH = opts.imageMaxHeight;
|
|
3402
|
+
}
|
|
3403
|
+
canvas = new OffscreenCanvas(targetW, targetH);
|
|
3404
|
+
ctx = canvas.getContext("2d");
|
|
3405
|
+
if (ctx) {
|
|
3406
|
+
_context10.next = 3;
|
|
3407
|
+
break;
|
|
3408
|
+
}
|
|
3409
|
+
bitmap.close();
|
|
3410
|
+
return _context10.abrupt("return", blob);
|
|
3411
|
+
case 3:
|
|
3412
|
+
ctx.drawImage(bitmap, 0, 0, targetW, targetH);
|
|
3413
|
+
bitmap.close();
|
|
3414
|
+
ext = getExtension(blob.name || "");
|
|
3415
|
+
outputType = "image/webp";
|
|
3416
|
+
if (ext === "png") outputType = "image/png";else if (ext === "jpg" || ext === "jpeg") outputType = "image/jpeg";
|
|
3417
|
+
_context10.next = 4;
|
|
3418
|
+
return canvas.convertToBlob({
|
|
3419
|
+
type: outputType,
|
|
3420
|
+
quality: opts.imageQuality
|
|
3421
|
+
});
|
|
3422
|
+
case 4:
|
|
3423
|
+
compressed = _context10.sent;
|
|
3424
|
+
return _context10.abrupt("return", compressed.size < blob.size ? compressed : blob);
|
|
3425
|
+
case 5:
|
|
3426
|
+
_context10.prev = 5;
|
|
3427
|
+
_context10["catch"](1);
|
|
3428
|
+
return _context10.abrupt("return", blob);
|
|
3429
|
+
case 6:
|
|
3430
|
+
case "end":
|
|
3431
|
+
return _context10.stop();
|
|
3432
|
+
}
|
|
3433
|
+
}, _callee10, null, [[1, 5]]);
|
|
3434
|
+
}));
|
|
3435
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3436
|
+
}
|
|
3437
|
+
function processFile(_x21, _x22, _x23, _x24) {
|
|
3438
|
+
return _processFile.apply(this, arguments);
|
|
3439
|
+
} // src/client.ts
|
|
3440
|
+
function _processFile() {
|
|
3441
|
+
_processFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(blob, fileName, compress, limits) {
|
|
3442
|
+
var opts;
|
|
3443
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
3444
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
3445
|
+
case 0:
|
|
3446
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), compress);
|
|
3447
|
+
if (!(opts.enabled && isImage(fileName))) {
|
|
3448
|
+
_context11.next = 2;
|
|
3449
|
+
break;
|
|
3450
|
+
}
|
|
3451
|
+
_context11.next = 1;
|
|
3452
|
+
return compressImageBlob(blob, opts);
|
|
3453
|
+
case 1:
|
|
3454
|
+
blob = _context11.sent;
|
|
3455
|
+
case 2:
|
|
3456
|
+
validateFileSize(blob, fileName, limits);
|
|
3457
|
+
return _context11.abrupt("return", blob);
|
|
3458
|
+
case 3:
|
|
3459
|
+
case "end":
|
|
3460
|
+
return _context11.stop();
|
|
3461
|
+
}
|
|
3462
|
+
}, _callee11);
|
|
3463
|
+
}));
|
|
3464
|
+
return _processFile.apply(this, arguments);
|
|
3176
3465
|
}
|
|
3177
|
-
|
|
3178
|
-
// src/client.ts
|
|
3179
3466
|
var DEFAULT_BASE_URL = "https://we0.ai";
|
|
3180
3467
|
var DEFAULT_TIMEOUT = 3e4;
|
|
3181
3468
|
function uuid() {
|
|
3182
3469
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
3183
3470
|
return crypto.randomUUID();
|
|
3184
3471
|
}
|
|
3185
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c)
|
|
3186
|
-
|
|
3472
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
3473
|
+
var r = Math.random() * 16 | 0;
|
|
3187
3474
|
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
3188
3475
|
});
|
|
3189
3476
|
}
|
|
3190
3477
|
function toBlob(input) {
|
|
3191
3478
|
if (input instanceof Blob) return input;
|
|
3192
|
-
if (typeof input === "string") return new Blob([input], {
|
|
3479
|
+
if (typeof input === "string") return new Blob([input], {
|
|
3480
|
+
type: "text/plain"
|
|
3481
|
+
});
|
|
3193
3482
|
if (input instanceof ArrayBuffer) return new Blob([input]);
|
|
3194
|
-
|
|
3483
|
+
var copy = input.slice().buffer;
|
|
3195
3484
|
return new Blob([copy]);
|
|
3196
3485
|
}
|
|
3197
3486
|
function getExt2(fileName) {
|
|
@@ -3200,144 +3489,246 @@ function getExt2(fileName) {
|
|
|
3200
3489
|
function resolveFileName(originalName, rename) {
|
|
3201
3490
|
if (!rename) return originalName;
|
|
3202
3491
|
if (rename === true) {
|
|
3203
|
-
|
|
3204
|
-
return ext ?
|
|
3492
|
+
var ext = getExt2(originalName);
|
|
3493
|
+
return ext ? "".concat(uuid(), ".").concat(ext) : uuid();
|
|
3205
3494
|
}
|
|
3206
3495
|
if (typeof rename === "string") return rename;
|
|
3207
3496
|
if (typeof rename === "function") return rename(originalName);
|
|
3208
3497
|
return originalName;
|
|
3209
3498
|
}
|
|
3210
|
-
function createOssClient(
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3499
|
+
function createOssClient() {
|
|
3500
|
+
var _options$baseURL, _options$timeout;
|
|
3501
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3502
|
+
var baseURL = (_options$baseURL = options.baseURL) !== null && _options$baseURL !== void 0 ? _options$baseURL : DEFAULT_BASE_URL;
|
|
3503
|
+
var timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : DEFAULT_TIMEOUT;
|
|
3504
|
+
var defaultRetry = options.retry;
|
|
3505
|
+
var defaultCompress = options.compress;
|
|
3506
|
+
var defaultLimits = options.limits;
|
|
3507
|
+
var allowedExtensions = options.allowedExtensions;
|
|
3217
3508
|
function mergeRetry(override) {
|
|
3218
3509
|
if (!defaultRetry && !override) return void 0;
|
|
3219
|
-
return {
|
|
3510
|
+
return _objectSpread$3(_objectSpread$3({}, defaultRetry), override);
|
|
3220
3511
|
}
|
|
3221
3512
|
function resolveCompress(override) {
|
|
3222
|
-
if (override === false) return {
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3513
|
+
if (override === false) return {
|
|
3514
|
+
enabled: false
|
|
3515
|
+
};
|
|
3516
|
+
if (defaultCompress === false && override === void 0) return {
|
|
3517
|
+
enabled: false
|
|
3518
|
+
};
|
|
3519
|
+
var base = _typeof$1(defaultCompress) === "object" ? defaultCompress : {};
|
|
3520
|
+
return override ? _objectSpread$3(_objectSpread$3({}, base), override) : Object.keys(base).length ? base : void 0;
|
|
3226
3521
|
}
|
|
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
|
-
|
|
3522
|
+
function uploadOne(_x25, _x26, _x27, _x28) {
|
|
3523
|
+
return _uploadOne.apply(this, arguments);
|
|
3524
|
+
}
|
|
3525
|
+
function _uploadOne() {
|
|
3526
|
+
_uploadOne = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(sessionId, file, fileName, opts) {
|
|
3527
|
+
var finalName, blob, compress, formData;
|
|
3528
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
3529
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
3530
|
+
case 0:
|
|
3531
|
+
if (sessionId) {
|
|
3532
|
+
_context5.next = 1;
|
|
3533
|
+
break;
|
|
3534
|
+
}
|
|
3535
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3536
|
+
case 1:
|
|
3537
|
+
if (fileName) {
|
|
3538
|
+
_context5.next = 2;
|
|
3539
|
+
break;
|
|
3540
|
+
}
|
|
3541
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3542
|
+
case 2:
|
|
3543
|
+
finalName = resolveFileName(fileName, opts === null || opts === void 0 ? void 0 : opts.rename);
|
|
3544
|
+
blob = toBlob(file);
|
|
3545
|
+
if (opts !== null && opts !== void 0 && opts.skipValidation) {
|
|
3546
|
+
_context5.next = 3;
|
|
3547
|
+
break;
|
|
3548
|
+
}
|
|
3549
|
+
validateExtension(finalName, allowedExtensions);
|
|
3550
|
+
_context5.next = 3;
|
|
3551
|
+
return validateMagicBytes(blob, finalName);
|
|
3552
|
+
case 3:
|
|
3553
|
+
compress = resolveCompress(opts === null || opts === void 0 ? void 0 : opts.compress);
|
|
3554
|
+
_context5.next = 4;
|
|
3555
|
+
return processFile(blob, finalName, compress, defaultLimits);
|
|
3556
|
+
case 4:
|
|
3557
|
+
blob = _context5.sent;
|
|
3558
|
+
formData = new FormData();
|
|
3559
|
+
formData.append("file", blob, finalName);
|
|
3560
|
+
formData.append("sessionId", sessionId);
|
|
3561
|
+
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));
|
|
3562
|
+
case 5:
|
|
3563
|
+
case "end":
|
|
3564
|
+
return _context5.stop();
|
|
3565
|
+
}
|
|
3566
|
+
}, _callee5);
|
|
3567
|
+
}));
|
|
3568
|
+
return _uploadOne.apply(this, arguments);
|
|
3253
3569
|
}
|
|
3254
3570
|
return {
|
|
3255
3571
|
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;
|
|
3572
|
+
uploadBatch: function uploadBatch(sessionId, files, opts) {
|
|
3573
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
3574
|
+
var _opts$concurrency, _opts$continueOnError;
|
|
3575
|
+
var concurrency, continueOnError, results, running, index;
|
|
3576
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
3577
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3578
|
+
case 0:
|
|
3579
|
+
if (sessionId) {
|
|
3580
|
+
_context.next = 1;
|
|
3581
|
+
break;
|
|
3288
3582
|
}
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3583
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3584
|
+
case 1:
|
|
3585
|
+
if (files.length) {
|
|
3586
|
+
_context.next = 2;
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
return _context.abrupt("return", []);
|
|
3590
|
+
case 2:
|
|
3591
|
+
concurrency = (_opts$concurrency = opts === null || opts === void 0 ? void 0 : opts.concurrency) !== null && _opts$concurrency !== void 0 ? _opts$concurrency : 3;
|
|
3592
|
+
continueOnError = (_opts$continueOnError = opts === null || opts === void 0 ? void 0 : opts.continueOnError) !== null && _opts$continueOnError !== void 0 ? _opts$continueOnError : true;
|
|
3593
|
+
results = [];
|
|
3594
|
+
running = 0;
|
|
3595
|
+
index = 0;
|
|
3596
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
3597
|
+
function next() {
|
|
3598
|
+
if (results.length === files.length) {
|
|
3599
|
+
resolve(results);
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3602
|
+
var _loop = function _loop() {
|
|
3603
|
+
var i = index++;
|
|
3604
|
+
var item = files[i];
|
|
3605
|
+
running++;
|
|
3606
|
+
var fileOpts = _objectSpread$3({
|
|
3607
|
+
retry: opts === null || opts === void 0 ? void 0 : opts.retry,
|
|
3608
|
+
compress: opts === null || opts === void 0 ? void 0 : opts.compress
|
|
3609
|
+
}, item.options);
|
|
3610
|
+
uploadOne(sessionId, item.file, item.fileName, fileOpts).then(function (result) {
|
|
3611
|
+
results[i] = {
|
|
3612
|
+
fileName: item.fileName,
|
|
3613
|
+
success: true,
|
|
3614
|
+
result: result
|
|
3615
|
+
};
|
|
3616
|
+
})["catch"](function (error) {
|
|
3617
|
+
results[i] = {
|
|
3618
|
+
fileName: item.fileName,
|
|
3619
|
+
success: false,
|
|
3620
|
+
error: error
|
|
3621
|
+
};
|
|
3622
|
+
if (!continueOnError) {
|
|
3623
|
+
reject(error);
|
|
3624
|
+
return;
|
|
3625
|
+
}
|
|
3626
|
+
})["finally"](function () {
|
|
3627
|
+
running--;
|
|
3628
|
+
next();
|
|
3629
|
+
});
|
|
3630
|
+
};
|
|
3631
|
+
while (running < concurrency && index < files.length) {
|
|
3632
|
+
_loop();
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
next();
|
|
3636
|
+
}));
|
|
3637
|
+
case 3:
|
|
3638
|
+
case "end":
|
|
3639
|
+
return _context.stop();
|
|
3293
3640
|
}
|
|
3294
|
-
}
|
|
3295
|
-
|
|
3296
|
-
});
|
|
3641
|
+
}, _callee);
|
|
3642
|
+
}))();
|
|
3297
3643
|
},
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3644
|
+
"delete": function _delete(sessionId, fileName, opts) {
|
|
3645
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
3646
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
3647
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3648
|
+
case 0:
|
|
3649
|
+
if (sessionId) {
|
|
3650
|
+
_context2.next = 1;
|
|
3651
|
+
break;
|
|
3652
|
+
}
|
|
3653
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3654
|
+
case 1:
|
|
3655
|
+
if (fileName) {
|
|
3656
|
+
_context2.next = 2;
|
|
3657
|
+
break;
|
|
3658
|
+
}
|
|
3659
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3660
|
+
case 2:
|
|
3661
|
+
return _context2.abrupt("return", requestJsonWithRetry(baseURL, timeout, "/api/oss/delete", {
|
|
3662
|
+
sessionId: sessionId,
|
|
3663
|
+
fileName: fileName
|
|
3664
|
+
}, mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry)));
|
|
3665
|
+
case 3:
|
|
3666
|
+
case "end":
|
|
3667
|
+
return _context2.stop();
|
|
3668
|
+
}
|
|
3669
|
+
}, _callee2);
|
|
3670
|
+
}))();
|
|
3312
3671
|
},
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3672
|
+
getFileUrl: function getFileUrl(sessionId, fileName, opts) {
|
|
3673
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
3674
|
+
var params, result;
|
|
3675
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
3676
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3677
|
+
case 0:
|
|
3678
|
+
if (sessionId) {
|
|
3679
|
+
_context3.next = 1;
|
|
3680
|
+
break;
|
|
3681
|
+
}
|
|
3682
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3683
|
+
case 1:
|
|
3684
|
+
if (fileName) {
|
|
3685
|
+
_context3.next = 2;
|
|
3686
|
+
break;
|
|
3687
|
+
}
|
|
3688
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3689
|
+
case 2:
|
|
3690
|
+
params = new URLSearchParams({
|
|
3691
|
+
sessionId: sessionId,
|
|
3692
|
+
fileName: fileName
|
|
3693
|
+
});
|
|
3694
|
+
_context3.next = 3;
|
|
3695
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
3696
|
+
case 3:
|
|
3697
|
+
result = _context3.sent;
|
|
3698
|
+
return _context3.abrupt("return", result.url || "");
|
|
3699
|
+
case 4:
|
|
3700
|
+
case "end":
|
|
3701
|
+
return _context3.stop();
|
|
3702
|
+
}
|
|
3703
|
+
}, _callee3);
|
|
3704
|
+
}))();
|
|
3328
3705
|
},
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3706
|
+
listFiles: function listFiles(sessionId, opts) {
|
|
3707
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
3708
|
+
var params, result;
|
|
3709
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
3710
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
3711
|
+
case 0:
|
|
3712
|
+
if (sessionId) {
|
|
3713
|
+
_context4.next = 1;
|
|
3714
|
+
break;
|
|
3715
|
+
}
|
|
3716
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3717
|
+
case 1:
|
|
3718
|
+
params = new URLSearchParams({
|
|
3719
|
+
sessionId: sessionId
|
|
3720
|
+
});
|
|
3721
|
+
_context4.next = 2;
|
|
3722
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
3723
|
+
case 2:
|
|
3724
|
+
result = _context4.sent;
|
|
3725
|
+
return _context4.abrupt("return", result.files);
|
|
3726
|
+
case 3:
|
|
3727
|
+
case "end":
|
|
3728
|
+
return _context4.stop();
|
|
3729
|
+
}
|
|
3730
|
+
}, _callee4);
|
|
3731
|
+
}))();
|
|
3341
3732
|
}
|
|
3342
3733
|
};
|
|
3343
3734
|
}
|
|
@@ -3657,9 +4048,9 @@ function _isUserSessionAdmin() {
|
|
|
3657
4048
|
return _isUserSessionAdmin.apply(this, arguments);
|
|
3658
4049
|
}
|
|
3659
4050
|
|
|
3660
|
-
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$
|
|
3661
|
-
function _unsupportedIterableToArray$
|
|
3662
|
-
function _arrayLikeToArray$
|
|
4051
|
+
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(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; } } }; }
|
|
4052
|
+
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(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$1(r, a) : void 0; } }
|
|
4053
|
+
function _arrayLikeToArray$1(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; }
|
|
3663
4054
|
var RESERVED_STATUS_FIELD = "status";
|
|
3664
4055
|
var PUBLISH_STATUS_VALUES = new Set(["draft", "published"]);
|
|
3665
4056
|
// 初始化Supabase连接和CMS系统
|
|
@@ -4177,26 +4568,12 @@ function _iterableToArrayLimit(r, l) {
|
|
|
4177
4568
|
}
|
|
4178
4569
|
}
|
|
4179
4570
|
|
|
4180
|
-
function _arrayLikeToArray$1(r, a) {
|
|
4181
|
-
(null == a || a > r.length) && (a = r.length);
|
|
4182
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4183
|
-
return n;
|
|
4184
|
-
}
|
|
4185
|
-
|
|
4186
|
-
function _unsupportedIterableToArray$1(r, a) {
|
|
4187
|
-
if (r) {
|
|
4188
|
-
if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
|
|
4189
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
4190
|
-
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$1(r, a) : void 0;
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
|
-
|
|
4194
4571
|
function _nonIterableRest() {
|
|
4195
4572
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4196
4573
|
}
|
|
4197
4574
|
|
|
4198
4575
|
function _slicedToArray(r, e) {
|
|
4199
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$
|
|
4576
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
4200
4577
|
}
|
|
4201
4578
|
|
|
4202
4579
|
var _excluded = ["id", "created_at", "updated_at"],
|
|
@@ -4205,8 +4582,8 @@ var _excluded = ["id", "created_at", "updated_at"],
|
|
|
4205
4582
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n2 = 0, F = function F() {}; return { s: F, n: function n() { return _n2 >= r.length ? { done: !0 } : { done: !1, value: r[_n2++] }; }, 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; } } }; }
|
|
4206
4583
|
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
4584
|
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
|
-
function ownKeys$
|
|
4209
|
-
function _objectSpread$
|
|
4585
|
+
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; }
|
|
4586
|
+
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; }
|
|
4210
4587
|
function normalizeJsonLikeFields(schemaFields, payload) {
|
|
4211
4588
|
if (!schemaFields || schemaFields.length === 0) return payload;
|
|
4212
4589
|
var jsonLikeFieldNames = new Set(schemaFields.filter(function (f) {
|
|
@@ -4215,7 +4592,7 @@ function normalizeJsonLikeFields(schemaFields, payload) {
|
|
|
4215
4592
|
return f.name;
|
|
4216
4593
|
}));
|
|
4217
4594
|
if (jsonLikeFieldNames.size === 0) return payload;
|
|
4218
|
-
var normalized = _objectSpread$
|
|
4595
|
+
var normalized = _objectSpread$2({}, payload);
|
|
4219
4596
|
for (var _i = 0, _Object$entries = Object.entries(payload); _i < _Object$entries.length; _i++) {
|
|
4220
4597
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
4221
4598
|
key = _Object$entries$_i[0],
|
|
@@ -5311,8 +5688,8 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5311
5688
|
}]);
|
|
5312
5689
|
}();
|
|
5313
5690
|
|
|
5314
|
-
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; }
|
|
5691
|
+
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; }
|
|
5692
|
+
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; }
|
|
5316
5693
|
function getRoleFromSupabaseUser$2(user) {
|
|
5317
5694
|
var _user$app_metadata, _user$user_metadata;
|
|
5318
5695
|
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;
|
|
@@ -5338,7 +5715,7 @@ function toSupabaseEmail(account, sessionId) {
|
|
|
5338
5715
|
return "".concat(sid, "_").concat(localPart, "@").concat(domain);
|
|
5339
5716
|
}
|
|
5340
5717
|
function buildAdminMetadata(existingMetadata, sessionId, account) {
|
|
5341
|
-
return _objectSpread(_objectSpread({}, existingMetadata || {}), {}, {
|
|
5718
|
+
return _objectSpread$1(_objectSpread$1({}, existingMetadata || {}), {}, {
|
|
5342
5719
|
role: "admin",
|
|
5343
5720
|
session_id: normalizeSessionId(sessionId),
|
|
5344
5721
|
original_username: account
|
|
@@ -6220,6 +6597,262 @@ function _uploadToOss() {
|
|
|
6220
6597
|
return _uploadToOss.apply(this, arguments);
|
|
6221
6598
|
}
|
|
6222
6599
|
|
|
6600
|
+
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; }
|
|
6601
|
+
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; }
|
|
6602
|
+
var CONFIG_NAMESPACE_RE = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;
|
|
6603
|
+
var CONFIG_SESSION_RE = /^[a-zA-Z0-9_]{1,128}$/;
|
|
6604
|
+
function getConfigSessionId(c) {
|
|
6605
|
+
return normalizeSessionId(c.req.header("X-Session-Id") || c.req.header("x-session-id"));
|
|
6606
|
+
}
|
|
6607
|
+
function validateConfigSessionId(sessionId) {
|
|
6608
|
+
if (!sessionId) return "缺少 X-Session-Id,无法访问配置中心";
|
|
6609
|
+
if (!CONFIG_SESSION_RE.test(sessionId)) {
|
|
6610
|
+
return "X-Session-Id 格式不合法";
|
|
6611
|
+
}
|
|
6612
|
+
return null;
|
|
6613
|
+
}
|
|
6614
|
+
function getConfigsTableName(sessionId) {
|
|
6615
|
+
return "".concat(sessionId, "__config__");
|
|
6616
|
+
}
|
|
6617
|
+
function normalizeValues(values) {
|
|
6618
|
+
if (!values || _typeof$1(values) !== "object" || Array.isArray(values)) {
|
|
6619
|
+
return {};
|
|
6620
|
+
}
|
|
6621
|
+
return values;
|
|
6622
|
+
}
|
|
6623
|
+
function buildFieldStatus(values) {
|
|
6624
|
+
return Object.fromEntries(Object.entries(values).map(function (_ref) {
|
|
6625
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
6626
|
+
key = _ref2[0],
|
|
6627
|
+
value = _ref2[1];
|
|
6628
|
+
return [key, {
|
|
6629
|
+
configured: value !== null && value !== undefined && String(value).trim() !== ""
|
|
6630
|
+
}];
|
|
6631
|
+
}));
|
|
6632
|
+
}
|
|
6633
|
+
function ensureConfigsTable(_x) {
|
|
6634
|
+
return _ensureConfigsTable.apply(this, arguments);
|
|
6635
|
+
}
|
|
6636
|
+
function _ensureConfigsTable() {
|
|
6637
|
+
_ensureConfigsTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(tableName) {
|
|
6638
|
+
var supabase, createTableSQL, _yield$supabase$rpc, error;
|
|
6639
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
6640
|
+
while (1) switch (_context.prev = _context.next) {
|
|
6641
|
+
case 0:
|
|
6642
|
+
supabase = getSupabase();
|
|
6643
|
+
createTableSQL = "\n CREATE TABLE IF NOT EXISTS \"".concat(tableName, "\" (\n id SERIAL PRIMARY KEY,\n namespace TEXT NOT NULL UNIQUE,\n values JSONB NOT NULL DEFAULT '{}'::jsonb,\n created_at TIMESTAMPTZ DEFAULT NOW(),\n updated_at TIMESTAMPTZ DEFAULT NOW()\n );\n ");
|
|
6644
|
+
_context.next = 1;
|
|
6645
|
+
return supabase.rpc("execute_sql", {
|
|
6646
|
+
sql_query: createTableSQL
|
|
6647
|
+
});
|
|
6648
|
+
case 1:
|
|
6649
|
+
_yield$supabase$rpc = _context.sent;
|
|
6650
|
+
error = _yield$supabase$rpc.error;
|
|
6651
|
+
if (!error) {
|
|
6652
|
+
_context.next = 2;
|
|
6653
|
+
break;
|
|
6654
|
+
}
|
|
6655
|
+
throw error;
|
|
6656
|
+
case 2:
|
|
6657
|
+
case "end":
|
|
6658
|
+
return _context.stop();
|
|
6659
|
+
}
|
|
6660
|
+
}, _callee);
|
|
6661
|
+
}));
|
|
6662
|
+
return _ensureConfigsTable.apply(this, arguments);
|
|
6663
|
+
}
|
|
6664
|
+
function validateNamespace(namespace) {
|
|
6665
|
+
if (!namespace) return "缺少 namespace";
|
|
6666
|
+
if (!CONFIG_NAMESPACE_RE.test(namespace)) {
|
|
6667
|
+
return "namespace 只能包含字母、数字、下划线和连字符,且必须以字母开头";
|
|
6668
|
+
}
|
|
6669
|
+
return null;
|
|
6670
|
+
}
|
|
6671
|
+
function toConfigResponse(row, fallbackNamespace) {
|
|
6672
|
+
var values = normalizeValues(row === null || row === void 0 ? void 0 : row.values);
|
|
6673
|
+
return {
|
|
6674
|
+
id: row === null || row === void 0 ? void 0 : row.id,
|
|
6675
|
+
namespace: (row === null || row === void 0 ? void 0 : row.namespace) || fallbackNamespace,
|
|
6676
|
+
values: values,
|
|
6677
|
+
fields: buildFieldStatus(values),
|
|
6678
|
+
created_at: row === null || row === void 0 ? void 0 : row.created_at,
|
|
6679
|
+
updated_at: row === null || row === void 0 ? void 0 : row.updated_at
|
|
6680
|
+
};
|
|
6681
|
+
}
|
|
6682
|
+
function getConfig(_x2) {
|
|
6683
|
+
return _getConfig.apply(this, arguments);
|
|
6684
|
+
}
|
|
6685
|
+
function _getConfig() {
|
|
6686
|
+
_getConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
6687
|
+
var namespace, namespaceError, _response, sessionId, sessionError, _response2, tableName, supabase, _yield$supabase$from$, data, error, response, _response3, _t;
|
|
6688
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
6689
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
6690
|
+
case 0:
|
|
6691
|
+
_context2.prev = 0;
|
|
6692
|
+
namespace = (c.req.query("namespace") || "").trim();
|
|
6693
|
+
namespaceError = validateNamespace(namespace);
|
|
6694
|
+
if (!namespaceError) {
|
|
6695
|
+
_context2.next = 1;
|
|
6696
|
+
break;
|
|
6697
|
+
}
|
|
6698
|
+
_response = {
|
|
6699
|
+
success: false,
|
|
6700
|
+
message: namespaceError
|
|
6701
|
+
};
|
|
6702
|
+
return _context2.abrupt("return", c.json(_response, 200));
|
|
6703
|
+
case 1:
|
|
6704
|
+
sessionId = getConfigSessionId(c);
|
|
6705
|
+
sessionError = validateConfigSessionId(sessionId);
|
|
6706
|
+
if (!sessionError) {
|
|
6707
|
+
_context2.next = 2;
|
|
6708
|
+
break;
|
|
6709
|
+
}
|
|
6710
|
+
_response2 = {
|
|
6711
|
+
success: false,
|
|
6712
|
+
message: sessionError
|
|
6713
|
+
};
|
|
6714
|
+
return _context2.abrupt("return", c.json(_response2, 200));
|
|
6715
|
+
case 2:
|
|
6716
|
+
tableName = getConfigsTableName(sessionId);
|
|
6717
|
+
_context2.next = 3;
|
|
6718
|
+
return ensureConfigsTable(tableName);
|
|
6719
|
+
case 3:
|
|
6720
|
+
supabase = getSupabase();
|
|
6721
|
+
_context2.next = 4;
|
|
6722
|
+
return supabase.from(tableName).select("*").eq("namespace", namespace).maybeSingle();
|
|
6723
|
+
case 4:
|
|
6724
|
+
_yield$supabase$from$ = _context2.sent;
|
|
6725
|
+
data = _yield$supabase$from$.data;
|
|
6726
|
+
error = _yield$supabase$from$.error;
|
|
6727
|
+
if (!error) {
|
|
6728
|
+
_context2.next = 5;
|
|
6729
|
+
break;
|
|
6730
|
+
}
|
|
6731
|
+
throw error;
|
|
6732
|
+
case 5:
|
|
6733
|
+
response = {
|
|
6734
|
+
success: true,
|
|
6735
|
+
data: toConfigResponse(data, namespace)
|
|
6736
|
+
};
|
|
6737
|
+
return _context2.abrupt("return", c.json(response, 200));
|
|
6738
|
+
case 6:
|
|
6739
|
+
_context2.prev = 6;
|
|
6740
|
+
_t = _context2["catch"](0);
|
|
6741
|
+
console.error("获取配置失败:", _t);
|
|
6742
|
+
_response3 = {
|
|
6743
|
+
success: false,
|
|
6744
|
+
message: "获取配置失败",
|
|
6745
|
+
error: _t.message
|
|
6746
|
+
};
|
|
6747
|
+
return _context2.abrupt("return", c.json(_response3, 500));
|
|
6748
|
+
case 7:
|
|
6749
|
+
case "end":
|
|
6750
|
+
return _context2.stop();
|
|
6751
|
+
}
|
|
6752
|
+
}, _callee2, null, [[0, 6]]);
|
|
6753
|
+
}));
|
|
6754
|
+
return _getConfig.apply(this, arguments);
|
|
6755
|
+
}
|
|
6756
|
+
function updateConfig(_x3) {
|
|
6757
|
+
return _updateConfig.apply(this, arguments);
|
|
6758
|
+
}
|
|
6759
|
+
function _updateConfig() {
|
|
6760
|
+
_updateConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c) {
|
|
6761
|
+
var namespace, namespaceError, _response4, body, values, sessionId, sessionError, _response5, tableName, supabase, _yield$supabase$from$2, existing, existingError, nextValues, _yield$supabase$from$3, data, error, response, _response6, _t2;
|
|
6762
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
6763
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
6764
|
+
case 0:
|
|
6765
|
+
_context3.prev = 0;
|
|
6766
|
+
namespace = (c.req.param("namespace") || "").trim();
|
|
6767
|
+
namespaceError = validateNamespace(namespace);
|
|
6768
|
+
if (!namespaceError) {
|
|
6769
|
+
_context3.next = 1;
|
|
6770
|
+
break;
|
|
6771
|
+
}
|
|
6772
|
+
_response4 = {
|
|
6773
|
+
success: false,
|
|
6774
|
+
message: namespaceError
|
|
6775
|
+
};
|
|
6776
|
+
return _context3.abrupt("return", c.json(_response4, 200));
|
|
6777
|
+
case 1:
|
|
6778
|
+
_context3.next = 2;
|
|
6779
|
+
return c.req.json();
|
|
6780
|
+
case 2:
|
|
6781
|
+
body = _context3.sent;
|
|
6782
|
+
values = normalizeValues(body === null || body === void 0 ? void 0 : body.values);
|
|
6783
|
+
sessionId = getConfigSessionId(c);
|
|
6784
|
+
sessionError = validateConfigSessionId(sessionId);
|
|
6785
|
+
if (!sessionError) {
|
|
6786
|
+
_context3.next = 3;
|
|
6787
|
+
break;
|
|
6788
|
+
}
|
|
6789
|
+
_response5 = {
|
|
6790
|
+
success: false,
|
|
6791
|
+
message: sessionError
|
|
6792
|
+
};
|
|
6793
|
+
return _context3.abrupt("return", c.json(_response5, 200));
|
|
6794
|
+
case 3:
|
|
6795
|
+
tableName = getConfigsTableName(sessionId);
|
|
6796
|
+
_context3.next = 4;
|
|
6797
|
+
return ensureConfigsTable(tableName);
|
|
6798
|
+
case 4:
|
|
6799
|
+
supabase = getSupabase();
|
|
6800
|
+
_context3.next = 5;
|
|
6801
|
+
return supabase.from(tableName).select("values").eq("namespace", namespace).maybeSingle();
|
|
6802
|
+
case 5:
|
|
6803
|
+
_yield$supabase$from$2 = _context3.sent;
|
|
6804
|
+
existing = _yield$supabase$from$2.data;
|
|
6805
|
+
existingError = _yield$supabase$from$2.error;
|
|
6806
|
+
if (!existingError) {
|
|
6807
|
+
_context3.next = 6;
|
|
6808
|
+
break;
|
|
6809
|
+
}
|
|
6810
|
+
throw existingError;
|
|
6811
|
+
case 6:
|
|
6812
|
+
nextValues = _objectSpread(_objectSpread({}, normalizeValues(existing === null || existing === void 0 ? void 0 : existing.values)), values);
|
|
6813
|
+
_context3.next = 7;
|
|
6814
|
+
return supabase.from(tableName).upsert({
|
|
6815
|
+
namespace: namespace,
|
|
6816
|
+
values: nextValues,
|
|
6817
|
+
updated_at: new Date().toISOString()
|
|
6818
|
+
}, {
|
|
6819
|
+
onConflict: "namespace"
|
|
6820
|
+
}).select("*").single();
|
|
6821
|
+
case 7:
|
|
6822
|
+
_yield$supabase$from$3 = _context3.sent;
|
|
6823
|
+
data = _yield$supabase$from$3.data;
|
|
6824
|
+
error = _yield$supabase$from$3.error;
|
|
6825
|
+
if (!error) {
|
|
6826
|
+
_context3.next = 8;
|
|
6827
|
+
break;
|
|
6828
|
+
}
|
|
6829
|
+
throw error;
|
|
6830
|
+
case 8:
|
|
6831
|
+
response = {
|
|
6832
|
+
success: true,
|
|
6833
|
+
message: "配置保存成功",
|
|
6834
|
+
data: toConfigResponse(data, namespace)
|
|
6835
|
+
};
|
|
6836
|
+
return _context3.abrupt("return", c.json(response, 200));
|
|
6837
|
+
case 9:
|
|
6838
|
+
_context3.prev = 9;
|
|
6839
|
+
_t2 = _context3["catch"](0);
|
|
6840
|
+
console.error("保存配置失败:", _t2);
|
|
6841
|
+
_response6 = {
|
|
6842
|
+
success: false,
|
|
6843
|
+
message: "保存配置失败",
|
|
6844
|
+
error: _t2.message
|
|
6845
|
+
};
|
|
6846
|
+
return _context3.abrupt("return", c.json(_response6, 500));
|
|
6847
|
+
case 10:
|
|
6848
|
+
case "end":
|
|
6849
|
+
return _context3.stop();
|
|
6850
|
+
}
|
|
6851
|
+
}, _callee3, null, [[0, 9]]);
|
|
6852
|
+
}));
|
|
6853
|
+
return _updateConfig.apply(this, arguments);
|
|
6854
|
+
}
|
|
6855
|
+
|
|
6223
6856
|
var AUTH_REQUIRED = "CMS_AUTH_REQUIRED";
|
|
6224
6857
|
var AUTH_INVALID = "CMS_AUTH_INVALID";
|
|
6225
6858
|
var CMS_FORBIDDEN = "CMS_FORBIDDEN";
|
|
@@ -6715,13 +7348,21 @@ function createOssUploadRoute(app) {
|
|
|
6715
7348
|
app.post("/upload", requireJwtAuth, requireAdminRole, uploadToOss);
|
|
6716
7349
|
return app;
|
|
6717
7350
|
}
|
|
7351
|
+
function createConfigRoute(app) {
|
|
7352
|
+
app.get("/configs", requireJwtAuth, requireAdminRole, getConfig);
|
|
7353
|
+
app.put("/configs/:namespace", requireJwtAuth, requireAdminRole, function (c) {
|
|
7354
|
+
return updateConfig(c);
|
|
7355
|
+
});
|
|
7356
|
+
return app;
|
|
7357
|
+
}
|
|
6718
7358
|
// 一键创建所有CMS路由
|
|
6719
7359
|
function createCmsRoutes(app) {
|
|
6720
7360
|
createModelRoute(app);
|
|
7361
|
+
createConfigRoute(app);
|
|
6721
7362
|
createDynamicDataRoute(app);
|
|
6722
7363
|
createDynamicAuthRoute(app);
|
|
6723
7364
|
return app;
|
|
6724
7365
|
}
|
|
6725
7366
|
|
|
6726
|
-
export { AuthService, getCmsModelService as CmsModel, CmsModelService, DynamicTableService, OssUploadError, OssUploadService, closeSupabase as closeDatabase, closeSupabase, createAuthRoute, createCmsRoutes, createDataRoute, createDynamicAuthRoute, createDynamicDataRoute, createModel, createModelRoute, createOssUploadRoute, createTableData, deleteModel, deleteTableData, dropForeignKeys, executeSupabaseSetup, getAuthService, getCmsModelService, getCurrentUser, getSupabase as getDatabase, getDynamicTableService, getModels, getOssUploadService, getRelationOptions, getSupabase, getSupabaseSetupSQL, getTableData, getTableDataWithRelations, initializeCmsModel, initializeCmsSystem, initializeSupabase as initializeDatabase, initializeOssUpload, initializeSupabase, login, requireAuth, signup, signupStatus, initializeCmsSystem as syncDatabase, testConnection, updateModel, updateTableData, uploadToOss, verifyAuth };
|
|
7367
|
+
export { AuthService, getCmsModelService as CmsModel, CmsModelService, DynamicTableService, OssUploadError, OssUploadService, closeSupabase as closeDatabase, closeSupabase, createAuthRoute, createCmsRoutes, createConfigRoute, createDataRoute, createDynamicAuthRoute, createDynamicDataRoute, createModel, createModelRoute, createOssUploadRoute, createTableData, deleteModel, deleteTableData, dropForeignKeys, executeSupabaseSetup, getAuthService, getCmsModelService, getConfig, getCurrentUser, getSupabase as getDatabase, getDynamicTableService, getModels, getOssUploadService, getRelationOptions, getSupabase, getSupabaseSetupSQL, getTableData, getTableDataWithRelations, initializeCmsModel, initializeCmsSystem, initializeSupabase as initializeDatabase, initializeOssUpload, initializeSupabase, login, requireAuth, signup, signupStatus, initializeCmsSystem as syncDatabase, testConnection, updateConfig, updateModel, updateTableData, uploadToOss, verifyAuth };
|
|
6727
7368
|
//# sourceMappingURL=index.esm.js.map
|