@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.js
CHANGED
|
@@ -50,6 +50,16 @@ function _asyncToGenerator(n) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function _typeof$1(o) {
|
|
54
|
+
"@babel/helpers - typeof";
|
|
55
|
+
|
|
56
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
57
|
+
return typeof o;
|
|
58
|
+
} : function (o) {
|
|
59
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
60
|
+
}, _typeof$1(o);
|
|
61
|
+
}
|
|
62
|
+
|
|
53
63
|
function getDefaultExportFromCjs (x) {
|
|
54
64
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
55
65
|
}
|
|
@@ -59,12 +69,11 @@ var regeneratorRuntime$1 = {exports: {}};
|
|
|
59
69
|
var OverloadYield = {exports: {}};
|
|
60
70
|
|
|
61
71
|
(function (module) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
72
|
+
function _OverloadYield(e, d) {
|
|
73
|
+
this.v = e, this.k = d;
|
|
74
|
+
}
|
|
75
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
76
|
+
})(OverloadYield);
|
|
68
77
|
var OverloadYieldExports = OverloadYield.exports;
|
|
69
78
|
|
|
70
79
|
var regenerator$1 = {exports: {}};
|
|
@@ -72,124 +81,122 @@ var regenerator$1 = {exports: {}};
|
|
|
72
81
|
var regeneratorDefine = {exports: {}};
|
|
73
82
|
|
|
74
83
|
(function (module) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
84
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
85
|
+
var i = Object.defineProperty;
|
|
86
|
+
try {
|
|
87
|
+
i({}, "", {});
|
|
88
|
+
} catch (e) {
|
|
89
|
+
i = 0;
|
|
90
|
+
}
|
|
91
|
+
module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
|
|
92
|
+
function o(r, n) {
|
|
93
|
+
_regeneratorDefine(e, r, function (e) {
|
|
94
|
+
return this._invoke(r, n, e);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
r ? i ? i(e, r, {
|
|
98
|
+
value: n,
|
|
99
|
+
enumerable: !t,
|
|
100
|
+
configurable: !t,
|
|
101
|
+
writable: !t
|
|
102
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
103
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
|
|
104
|
+
}
|
|
105
|
+
module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
106
|
+
})(regeneratorDefine);
|
|
99
107
|
var regeneratorDefineExports = regeneratorDefine.exports;
|
|
100
108
|
|
|
101
109
|
(function (module) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
110
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
111
|
+
function _regenerator() {
|
|
112
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
113
|
+
var e,
|
|
114
|
+
t,
|
|
115
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
116
|
+
n = r.iterator || "@@iterator",
|
|
117
|
+
o = r.toStringTag || "@@toStringTag";
|
|
118
|
+
function i(r, n, o, i) {
|
|
119
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
120
|
+
u = Object.create(c.prototype);
|
|
121
|
+
return regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
122
|
+
var i,
|
|
123
|
+
c,
|
|
124
|
+
u,
|
|
125
|
+
f = 0,
|
|
126
|
+
p = o || [],
|
|
127
|
+
y = !1,
|
|
128
|
+
G = {
|
|
129
|
+
p: 0,
|
|
130
|
+
n: 0,
|
|
131
|
+
v: e,
|
|
132
|
+
a: d,
|
|
133
|
+
f: d.bind(e, 4),
|
|
134
|
+
d: function d(t, r) {
|
|
135
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
function d(r, n) {
|
|
139
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
140
|
+
var o,
|
|
141
|
+
i = p[t],
|
|
142
|
+
d = G.p,
|
|
143
|
+
l = i[2];
|
|
144
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
145
|
+
}
|
|
146
|
+
if (o || r > 1) return a;
|
|
147
|
+
throw y = !0, n;
|
|
148
|
+
}
|
|
149
|
+
return function (o, p, l) {
|
|
150
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
151
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
152
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
153
|
+
try {
|
|
154
|
+
if (f = 2, i) {
|
|
155
|
+
if (c || (o = "next"), t = i[o]) {
|
|
156
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
157
|
+
if (!t.done) return t;
|
|
158
|
+
u = t.value, c < 2 && (c = 0);
|
|
159
|
+
} else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
160
|
+
i = e;
|
|
161
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
162
|
+
} catch (t) {
|
|
163
|
+
i = e, c = 1, u = t;
|
|
164
|
+
} finally {
|
|
165
|
+
f = 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
value: t,
|
|
170
|
+
done: y
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
}(r, o, i), !0), u;
|
|
174
|
+
}
|
|
175
|
+
var a = {};
|
|
176
|
+
function Generator() {}
|
|
177
|
+
function GeneratorFunction() {}
|
|
178
|
+
function GeneratorFunctionPrototype() {}
|
|
179
|
+
t = Object.getPrototypeOf;
|
|
180
|
+
var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
|
|
181
|
+
return this;
|
|
182
|
+
}), t),
|
|
183
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
184
|
+
function f(e) {
|
|
185
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
186
|
+
}
|
|
187
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function () {
|
|
188
|
+
return this;
|
|
189
|
+
}), regeneratorDefine(u, "toString", function () {
|
|
190
|
+
return "[object Generator]";
|
|
191
|
+
}), (module.exports = _regenerator = function _regenerator() {
|
|
192
|
+
return {
|
|
193
|
+
w: i,
|
|
194
|
+
m: f
|
|
195
|
+
};
|
|
196
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
197
|
+
}
|
|
198
|
+
module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
199
|
+
})(regenerator$1);
|
|
193
200
|
var regeneratorExports = regenerator$1.exports;
|
|
194
201
|
|
|
195
202
|
var regeneratorAsync = {exports: {}};
|
|
@@ -199,206 +206,199 @@ var regeneratorAsyncGen = {exports: {}};
|
|
|
199
206
|
var regeneratorAsyncIterator = {exports: {}};
|
|
200
207
|
|
|
201
208
|
(function (module) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
209
|
+
var OverloadYield = OverloadYieldExports;
|
|
210
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
211
|
+
function AsyncIterator(t, e) {
|
|
212
|
+
function n(r, o, i, f) {
|
|
213
|
+
try {
|
|
214
|
+
var c = t[r](o),
|
|
215
|
+
u = c.value;
|
|
216
|
+
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
|
|
217
|
+
n("next", t, i, f);
|
|
218
|
+
}, function (t) {
|
|
219
|
+
n("throw", t, i, f);
|
|
220
|
+
}) : e.resolve(u).then(function (t) {
|
|
221
|
+
c.value = t, i(c);
|
|
222
|
+
}, function (t) {
|
|
223
|
+
return n("throw", t, i, f);
|
|
224
|
+
});
|
|
225
|
+
} catch (t) {
|
|
226
|
+
f(t);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
var r;
|
|
230
|
+
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
|
|
231
|
+
return this;
|
|
232
|
+
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
|
|
233
|
+
function f() {
|
|
234
|
+
return new e(function (e, r) {
|
|
235
|
+
n(t, i, e, r);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return r = r ? r.then(f, f) : f();
|
|
239
|
+
}, !0);
|
|
240
|
+
}
|
|
241
|
+
module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
242
|
+
})(regeneratorAsyncIterator);
|
|
237
243
|
var regeneratorAsyncIteratorExports = regeneratorAsyncIterator.exports;
|
|
238
244
|
|
|
239
245
|
(function (module) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
246
|
+
var regenerator = regeneratorExports;
|
|
247
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
248
|
+
function _regeneratorAsyncGen(r, e, t, o, n) {
|
|
249
|
+
return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
|
|
250
|
+
}
|
|
251
|
+
module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
252
|
+
})(regeneratorAsyncGen);
|
|
248
253
|
var regeneratorAsyncGenExports = regeneratorAsyncGen.exports;
|
|
249
254
|
|
|
250
255
|
(function (module) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
256
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
257
|
+
function _regeneratorAsync(n, e, r, t, o) {
|
|
258
|
+
var a = regeneratorAsyncGen(n, e, r, t, o);
|
|
259
|
+
return a.next().then(function (n) {
|
|
260
|
+
return n.done ? n.value : a.next();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
264
|
+
})(regeneratorAsync);
|
|
261
265
|
var regeneratorAsyncExports = regeneratorAsync.exports;
|
|
262
266
|
|
|
263
267
|
var regeneratorKeys = {exports: {}};
|
|
264
268
|
|
|
265
269
|
(function (module) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
270
|
+
function _regeneratorKeys(e) {
|
|
271
|
+
var n = Object(e),
|
|
272
|
+
r = [];
|
|
273
|
+
for (var t in n) r.unshift(t);
|
|
274
|
+
return function e() {
|
|
275
|
+
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
|
|
276
|
+
return e.done = !0, e;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
280
|
+
})(regeneratorKeys);
|
|
278
281
|
var regeneratorKeysExports = regeneratorKeys.exports;
|
|
279
282
|
|
|
280
283
|
var regeneratorValues = {exports: {}};
|
|
281
284
|
|
|
282
|
-
var _typeof
|
|
285
|
+
var _typeof = {exports: {}};
|
|
283
286
|
|
|
284
287
|
(function (module) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
289
|
-
return typeof o;
|
|
290
|
-
} : function (o) {
|
|
291
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
292
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
293
|
-
}
|
|
294
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
295
|
-
} (_typeof$1));
|
|
288
|
+
function _typeof(o) {
|
|
289
|
+
"@babel/helpers - typeof";
|
|
296
290
|
|
|
297
|
-
|
|
291
|
+
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
292
|
+
return typeof o;
|
|
293
|
+
} : function (o) {
|
|
294
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
295
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
296
|
+
}
|
|
297
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
298
|
+
})(_typeof);
|
|
299
|
+
var _typeofExports = _typeof.exports;
|
|
298
300
|
|
|
299
301
|
(function (module) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
302
|
+
var _typeof = _typeofExports["default"];
|
|
303
|
+
function _regeneratorValues(e) {
|
|
304
|
+
if (null != e) {
|
|
305
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
306
|
+
r = 0;
|
|
307
|
+
if (t) return t.call(e);
|
|
308
|
+
if ("function" == typeof e.next) return e;
|
|
309
|
+
if (!isNaN(e.length)) return {
|
|
310
|
+
next: function next() {
|
|
311
|
+
return e && r >= e.length && (e = void 0), {
|
|
312
|
+
value: e && e[r++],
|
|
313
|
+
done: !e
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
319
|
+
}
|
|
320
|
+
module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
321
|
+
})(regeneratorValues);
|
|
321
322
|
var regeneratorValuesExports = regeneratorValues.exports;
|
|
322
323
|
|
|
323
324
|
(function (module) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var r = regenerator(),
|
|
334
|
-
e = r.m(_regeneratorRuntime),
|
|
335
|
-
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
336
|
-
function n(r) {
|
|
337
|
-
var e = "function" == typeof r && r.constructor;
|
|
338
|
-
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
339
|
-
}
|
|
340
|
-
var o = {
|
|
341
|
-
"throw": 1,
|
|
342
|
-
"return": 2,
|
|
343
|
-
"break": 3,
|
|
344
|
-
"continue": 3
|
|
345
|
-
};
|
|
346
|
-
function a(r) {
|
|
347
|
-
var e, t;
|
|
348
|
-
return function (n) {
|
|
349
|
-
e || (e = {
|
|
350
|
-
stop: function stop() {
|
|
351
|
-
return t(n.a, 2);
|
|
352
|
-
},
|
|
353
|
-
"catch": function _catch() {
|
|
354
|
-
return n.v;
|
|
355
|
-
},
|
|
356
|
-
abrupt: function abrupt(r, e) {
|
|
357
|
-
return t(n.a, o[r], e);
|
|
358
|
-
},
|
|
359
|
-
delegateYield: function delegateYield(r, o, a) {
|
|
360
|
-
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
361
|
-
},
|
|
362
|
-
finish: function finish(r) {
|
|
363
|
-
return t(n.f, r);
|
|
364
|
-
}
|
|
365
|
-
}, t = function t(r, _t, o) {
|
|
366
|
-
n.p = e.prev, n.n = e.next;
|
|
367
|
-
try {
|
|
368
|
-
return r(_t, o);
|
|
369
|
-
} finally {
|
|
370
|
-
e.next = n.n;
|
|
371
|
-
}
|
|
372
|
-
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
373
|
-
try {
|
|
374
|
-
return r.call(this, e);
|
|
375
|
-
} finally {
|
|
376
|
-
n.p = e.prev, n.n = e.next;
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
381
|
-
return {
|
|
382
|
-
wrap: function wrap(e, t, n, o) {
|
|
383
|
-
return r.w(a(e), t, n, o && o.reverse());
|
|
384
|
-
},
|
|
385
|
-
isGeneratorFunction: n,
|
|
386
|
-
mark: r.m,
|
|
387
|
-
awrap: function awrap(r, e) {
|
|
388
|
-
return new OverloadYield(r, e);
|
|
389
|
-
},
|
|
390
|
-
AsyncIterator: regeneratorAsyncIterator,
|
|
391
|
-
async: function async(r, e, t, o, u) {
|
|
392
|
-
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
393
|
-
},
|
|
394
|
-
keys: regeneratorKeys,
|
|
395
|
-
values: regeneratorValues
|
|
396
|
-
};
|
|
397
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
398
|
-
}
|
|
399
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
400
|
-
} (regeneratorRuntime$1));
|
|
325
|
+
var OverloadYield = OverloadYieldExports;
|
|
326
|
+
var regenerator = regeneratorExports;
|
|
327
|
+
var regeneratorAsync = regeneratorAsyncExports;
|
|
328
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
329
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
330
|
+
var regeneratorKeys = regeneratorKeysExports;
|
|
331
|
+
var regeneratorValues = regeneratorValuesExports;
|
|
332
|
+
function _regeneratorRuntime() {
|
|
401
333
|
|
|
334
|
+
var r = regenerator(),
|
|
335
|
+
e = r.m(_regeneratorRuntime),
|
|
336
|
+
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
337
|
+
function n(r) {
|
|
338
|
+
var e = "function" == typeof r && r.constructor;
|
|
339
|
+
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
340
|
+
}
|
|
341
|
+
var o = {
|
|
342
|
+
"throw": 1,
|
|
343
|
+
"return": 2,
|
|
344
|
+
"break": 3,
|
|
345
|
+
"continue": 3
|
|
346
|
+
};
|
|
347
|
+
function a(r) {
|
|
348
|
+
var e, t;
|
|
349
|
+
return function (n) {
|
|
350
|
+
e || (e = {
|
|
351
|
+
stop: function stop() {
|
|
352
|
+
return t(n.a, 2);
|
|
353
|
+
},
|
|
354
|
+
"catch": function _catch() {
|
|
355
|
+
return n.v;
|
|
356
|
+
},
|
|
357
|
+
abrupt: function abrupt(r, e) {
|
|
358
|
+
return t(n.a, o[r], e);
|
|
359
|
+
},
|
|
360
|
+
delegateYield: function delegateYield(r, o, a) {
|
|
361
|
+
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
362
|
+
},
|
|
363
|
+
finish: function finish(r) {
|
|
364
|
+
return t(n.f, r);
|
|
365
|
+
}
|
|
366
|
+
}, t = function t(r, _t, o) {
|
|
367
|
+
n.p = e.prev, n.n = e.next;
|
|
368
|
+
try {
|
|
369
|
+
return r(_t, o);
|
|
370
|
+
} finally {
|
|
371
|
+
e.next = n.n;
|
|
372
|
+
}
|
|
373
|
+
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
374
|
+
try {
|
|
375
|
+
return r.call(this, e);
|
|
376
|
+
} finally {
|
|
377
|
+
n.p = e.prev, n.n = e.next;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
382
|
+
return {
|
|
383
|
+
wrap: function wrap(e, t, n, o) {
|
|
384
|
+
return r.w(a(e), t, n, o && o.reverse());
|
|
385
|
+
},
|
|
386
|
+
isGeneratorFunction: n,
|
|
387
|
+
mark: r.m,
|
|
388
|
+
awrap: function awrap(r, e) {
|
|
389
|
+
return new OverloadYield(r, e);
|
|
390
|
+
},
|
|
391
|
+
AsyncIterator: regeneratorAsyncIterator,
|
|
392
|
+
async: function async(r, e, t, o, u) {
|
|
393
|
+
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
394
|
+
},
|
|
395
|
+
keys: regeneratorKeys,
|
|
396
|
+
values: regeneratorValues
|
|
397
|
+
};
|
|
398
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
399
|
+
}
|
|
400
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
401
|
+
})(regeneratorRuntime$1);
|
|
402
402
|
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
403
403
|
|
|
404
404
|
// TODO(Babel 8): Remove this file.
|
|
@@ -410,13 +410,12 @@ var regenerator = runtime;
|
|
|
410
410
|
try {
|
|
411
411
|
regeneratorRuntime = runtime;
|
|
412
412
|
} catch (accidentalStrictMode) {
|
|
413
|
-
if (typeof globalThis === "object") {
|
|
413
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$1(globalThis)) === "object") {
|
|
414
414
|
globalThis.regeneratorRuntime = runtime;
|
|
415
415
|
} else {
|
|
416
416
|
Function("r", "regeneratorRuntime = r")(runtime);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
|
|
420
419
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
421
420
|
|
|
422
421
|
var supabaseInstance = null;
|
|
@@ -700,22 +699,12 @@ function _classCallCheck(a, n) {
|
|
|
700
699
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
701
700
|
}
|
|
702
701
|
|
|
703
|
-
function _typeof(o) {
|
|
704
|
-
"@babel/helpers - typeof";
|
|
705
|
-
|
|
706
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
707
|
-
return typeof o;
|
|
708
|
-
} : function (o) {
|
|
709
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
710
|
-
}, _typeof(o);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
702
|
function toPrimitive(t, r) {
|
|
714
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
703
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
715
704
|
var e = t[Symbol.toPrimitive];
|
|
716
705
|
if (void 0 !== e) {
|
|
717
706
|
var i = e.call(t, r || "default");
|
|
718
|
-
if ("object" != _typeof(i)) return i;
|
|
707
|
+
if ("object" != _typeof$1(i)) return i;
|
|
719
708
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
720
709
|
}
|
|
721
710
|
return ("string" === r ? String : Number)(t);
|
|
@@ -723,7 +712,7 @@ function toPrimitive(t, r) {
|
|
|
723
712
|
|
|
724
713
|
function toPropertyKey(t) {
|
|
725
714
|
var i = toPrimitive(t, "string");
|
|
726
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
715
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
727
716
|
}
|
|
728
717
|
|
|
729
718
|
function _defineProperties(e, r) {
|
|
@@ -1040,8 +1029,8 @@ function _defineProperty(e, r, t) {
|
|
|
1040
1029
|
}) : e[r] = t, e;
|
|
1041
1030
|
}
|
|
1042
1031
|
|
|
1043
|
-
function ownKeys$
|
|
1044
|
-
function _objectSpread$
|
|
1032
|
+
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; }
|
|
1033
|
+
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; }
|
|
1045
1034
|
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; } } }; }
|
|
1046
1035
|
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; } }
|
|
1047
1036
|
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; }
|
|
@@ -2096,7 +2085,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2096
2085
|
throw error;
|
|
2097
2086
|
case 2:
|
|
2098
2087
|
return _context14.abrupt("return", (data || []).map(function (item) {
|
|
2099
|
-
return _objectSpread$
|
|
2088
|
+
return _objectSpread$5({
|
|
2100
2089
|
id: item.id,
|
|
2101
2090
|
label: item[displayField] || "ID: ".concat(item.id)
|
|
2102
2091
|
}, item);
|
|
@@ -2209,8 +2198,8 @@ function getDynamicTableService() {
|
|
|
2209
2198
|
return defaultService$1;
|
|
2210
2199
|
}
|
|
2211
2200
|
|
|
2212
|
-
function ownKeys$
|
|
2213
|
-
function _objectSpread$
|
|
2201
|
+
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; }
|
|
2202
|
+
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; }
|
|
2214
2203
|
var AuthService = /*#__PURE__*/function () {
|
|
2215
2204
|
function AuthService() {
|
|
2216
2205
|
_classCallCheck(this, AuthService);
|
|
@@ -2387,7 +2376,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2387
2376
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
2388
2377
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2389
2378
|
case 0:
|
|
2390
|
-
finalUserData = _objectSpread$
|
|
2379
|
+
finalUserData = _objectSpread$4({
|
|
2391
2380
|
tableName: this.defaultTableName
|
|
2392
2381
|
}, userData);
|
|
2393
2382
|
_context4.prev = 1;
|
|
@@ -2445,7 +2434,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2445
2434
|
case 0:
|
|
2446
2435
|
updateData = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
2447
2436
|
// 设置默认值
|
|
2448
|
-
finalUpdateData = _objectSpread$
|
|
2437
|
+
finalUpdateData = _objectSpread$4({
|
|
2449
2438
|
tableName: this.defaultTableName
|
|
2450
2439
|
}, updateData);
|
|
2451
2440
|
_context5.prev = 1;
|
|
@@ -2745,7 +2734,7 @@ function _assertThisInitialized(e) {
|
|
|
2745
2734
|
}
|
|
2746
2735
|
|
|
2747
2736
|
function _possibleConstructorReturn(t, e) {
|
|
2748
|
-
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
|
|
2737
|
+
if (e && ("object" == _typeof$1(e) || "function" == typeof e)) return e;
|
|
2749
2738
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2750
2739
|
return _assertThisInitialized(t);
|
|
2751
2740
|
}
|
|
@@ -2783,17 +2772,17 @@ function _isNativeFunction(t) {
|
|
|
2783
2772
|
}
|
|
2784
2773
|
}
|
|
2785
2774
|
|
|
2786
|
-
function _isNativeReflectConstruct$
|
|
2775
|
+
function _isNativeReflectConstruct$2() {
|
|
2787
2776
|
try {
|
|
2788
2777
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2789
2778
|
} catch (t) {}
|
|
2790
|
-
return (_isNativeReflectConstruct$
|
|
2779
|
+
return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() {
|
|
2791
2780
|
return !!t;
|
|
2792
2781
|
})();
|
|
2793
2782
|
}
|
|
2794
2783
|
|
|
2795
2784
|
function _construct(t, e, r) {
|
|
2796
|
-
if (_isNativeReflectConstruct$
|
|
2785
|
+
if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments);
|
|
2797
2786
|
var o = [null];
|
|
2798
2787
|
o.push.apply(o, e);
|
|
2799
2788
|
var p = new (t.bind.apply(t, o))();
|
|
@@ -2823,6 +2812,40 @@ function _wrapNativeSuper(t) {
|
|
|
2823
2812
|
}, _wrapNativeSuper(t);
|
|
2824
2813
|
}
|
|
2825
2814
|
|
|
2815
|
+
function _arrayLikeToArray$2(r, a) {
|
|
2816
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2817
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2818
|
+
return n;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
function _arrayWithoutHoles(r) {
|
|
2822
|
+
if (Array.isArray(r)) return _arrayLikeToArray$2(r);
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
function _iterableToArray(r) {
|
|
2826
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
function _unsupportedIterableToArray$2(r, a) {
|
|
2830
|
+
if (r) {
|
|
2831
|
+
if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
|
|
2832
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2833
|
+
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;
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
function _nonIterableSpread() {
|
|
2838
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
function _toConsumableArray(r) {
|
|
2842
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread();
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
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; }
|
|
2846
|
+
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; }
|
|
2847
|
+
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)); }
|
|
2848
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2826
2849
|
// src/error.ts
|
|
2827
2850
|
var ErrorCode = {
|
|
2828
2851
|
/** 网络错误(断网、DNS 解析失败等) */
|
|
@@ -2838,117 +2861,170 @@ var ErrorCode = {
|
|
|
2838
2861
|
/** 存储服务未启用 */
|
|
2839
2862
|
STORAGE_DISABLED: 503
|
|
2840
2863
|
};
|
|
2841
|
-
var OssError =
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
this
|
|
2845
|
-
|
|
2846
|
-
|
|
2864
|
+
var OssError = /*#__PURE__*/function (_Error) {
|
|
2865
|
+
function OssError(code, message) {
|
|
2866
|
+
var _this;
|
|
2867
|
+
_classCallCheck(this, OssError);
|
|
2868
|
+
_this = _callSuper$1(this, OssError, [message]);
|
|
2869
|
+
_this.name = "OssError";
|
|
2870
|
+
_this.code = code;
|
|
2871
|
+
_this.isRetryable = code === ErrorCode.NETWORK || code === ErrorCode.TIMEOUT || code >= 500;
|
|
2872
|
+
return _this;
|
|
2847
2873
|
}
|
|
2848
|
-
|
|
2874
|
+
_inherits(OssError, _Error);
|
|
2875
|
+
return _createClass(OssError);
|
|
2876
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
2849
2877
|
|
|
2850
2878
|
// src/validate.ts
|
|
2851
2879
|
var MAGIC_BYTES = [
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
]
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
"
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
"
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
"webm",
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
"
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
"
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
"
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
"
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
"
|
|
2902
|
-
]
|
|
2880
|
+
// 图片
|
|
2881
|
+
{
|
|
2882
|
+
ext: ["jpg", "jpeg"],
|
|
2883
|
+
bytes: [255, 216, 255]
|
|
2884
|
+
}, {
|
|
2885
|
+
ext: ["png"],
|
|
2886
|
+
bytes: [137, 80, 78, 71, 13, 10, 26, 10]
|
|
2887
|
+
}, {
|
|
2888
|
+
ext: ["gif"],
|
|
2889
|
+
bytes: [71, 73, 70, 56]
|
|
2890
|
+
}, {
|
|
2891
|
+
ext: ["bmp"],
|
|
2892
|
+
bytes: [66, 77]
|
|
2893
|
+
}, {
|
|
2894
|
+
ext: ["webp"],
|
|
2895
|
+
bytes: [87, 69, 66, 80],
|
|
2896
|
+
offset: 8
|
|
2897
|
+
}, {
|
|
2898
|
+
ext: ["ico"],
|
|
2899
|
+
bytes: [0, 0, 1, 0]
|
|
2900
|
+
}, {
|
|
2901
|
+
ext: ["svg"],
|
|
2902
|
+
bytes: []
|
|
2903
|
+
},
|
|
2904
|
+
// SVG 是文本,单独处理
|
|
2905
|
+
// 视频
|
|
2906
|
+
{
|
|
2907
|
+
ext: ["mp4", "m4v"],
|
|
2908
|
+
bytes: [102, 116, 121, 112],
|
|
2909
|
+
offset: 4
|
|
2910
|
+
}, {
|
|
2911
|
+
ext: ["webm"],
|
|
2912
|
+
bytes: [26, 69, 223, 163]
|
|
2913
|
+
}, {
|
|
2914
|
+
ext: ["avi"],
|
|
2915
|
+
bytes: [82, 73, 70, 70]
|
|
2916
|
+
}, {
|
|
2917
|
+
ext: ["mov"],
|
|
2918
|
+
bytes: [102, 116, 121, 112],
|
|
2919
|
+
offset: 4
|
|
2920
|
+
}, {
|
|
2921
|
+
ext: ["flv"],
|
|
2922
|
+
bytes: [70, 76, 86]
|
|
2923
|
+
}, {
|
|
2924
|
+
ext: ["mkv"],
|
|
2925
|
+
bytes: [26, 69, 223, 163]
|
|
2926
|
+
},
|
|
2927
|
+
// 文档
|
|
2928
|
+
{
|
|
2929
|
+
ext: ["pdf"],
|
|
2930
|
+
bytes: [37, 80, 68, 70]
|
|
2931
|
+
}];
|
|
2932
|
+
var DEFAULT_ALLOWED_EXTENSIONS = /* @__PURE__ */new Set([
|
|
2933
|
+
// 图片
|
|
2934
|
+
"jpg", "jpeg", "png", "gif", "webp", "bmp", "ico", "svg",
|
|
2935
|
+
// 视频
|
|
2936
|
+
"mp4", "webm", "mov", "avi", "mkv", "flv", "wmv", "m4v",
|
|
2937
|
+
// 文档
|
|
2938
|
+
"pdf",
|
|
2939
|
+
// 代码/文本
|
|
2940
|
+
"html", "css", "js", "ts", "json", "xml", "txt", "md", "csv"]);
|
|
2903
2941
|
function getExt(fileName) {
|
|
2904
2942
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
2905
2943
|
}
|
|
2906
2944
|
function validateExtension(fileName, allowedExtensions) {
|
|
2907
|
-
|
|
2908
|
-
|
|
2945
|
+
var ext = getExt(fileName);
|
|
2946
|
+
var whitelist = allowedExtensions !== null && allowedExtensions !== void 0 ? allowedExtensions : DEFAULT_ALLOWED_EXTENSIONS;
|
|
2909
2947
|
if (!ext) {
|
|
2910
|
-
throw new OssError(ErrorCode.INVALID_PARAMS,
|
|
2948
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u7F3A\u5C11\u6269\u5C55\u540D"));
|
|
2911
2949
|
}
|
|
2912
2950
|
if (!whitelist.has(ext)) {
|
|
2913
|
-
throw new OssError(
|
|
2914
|
-
ErrorCode.INVALID_PARAMS,
|
|
2915
|
-
`\u6587\u4EF6\u7C7B\u578B ".${ext}" \u4E0D\u5728\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u5141\u8BB8\u7684\u7C7B\u578B\uFF1A${[...whitelist].join(", ")}`
|
|
2916
|
-
);
|
|
2951
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6\u7C7B\u578B \".".concat(ext, "\" \u4E0D\u5728\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u5141\u8BB8\u7684\u7C7B\u578B\uFF1A").concat(_toConsumableArray(whitelist).join(", ")));
|
|
2917
2952
|
}
|
|
2918
2953
|
}
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2954
|
+
function validateMagicBytes(_x, _x2) {
|
|
2955
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
2956
|
+
} // src/request.ts
|
|
2957
|
+
function _validateMagicBytes() {
|
|
2958
|
+
_validateMagicBytes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, fileName) {
|
|
2959
|
+
var _rule$offset;
|
|
2960
|
+
var ext, textExts, text, rule, offset, needed, headerBuf, header, matched;
|
|
2961
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
2962
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
2963
|
+
case 0:
|
|
2964
|
+
ext = getExt(fileName);
|
|
2965
|
+
textExts = /* @__PURE__ */new Set(["html", "css", "js", "ts", "json", "xml", "txt", "md", "csv", "svg"]);
|
|
2966
|
+
if (!textExts.has(ext)) {
|
|
2967
|
+
_context6.next = 3;
|
|
2968
|
+
break;
|
|
2969
|
+
}
|
|
2970
|
+
if (!(ext === "svg")) {
|
|
2971
|
+
_context6.next = 2;
|
|
2972
|
+
break;
|
|
2973
|
+
}
|
|
2974
|
+
_context6.next = 1;
|
|
2975
|
+
return blob.slice(0, 1024).text();
|
|
2976
|
+
case 1:
|
|
2977
|
+
text = _context6.sent;
|
|
2978
|
+
if (!(!text.includes("<svg") && !text.includes("<?xml"))) {
|
|
2979
|
+
_context6.next = 2;
|
|
2980
|
+
break;
|
|
2981
|
+
}
|
|
2982
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u4E0D\u662F\u6709\u6548\u7684 SVG \u6587\u4EF6"));
|
|
2983
|
+
case 2:
|
|
2984
|
+
return _context6.abrupt("return");
|
|
2985
|
+
case 3:
|
|
2986
|
+
rule = MAGIC_BYTES.find(function (r) {
|
|
2987
|
+
return r.ext.includes(ext);
|
|
2988
|
+
});
|
|
2989
|
+
if (!(!rule || rule.bytes.length === 0)) {
|
|
2990
|
+
_context6.next = 4;
|
|
2991
|
+
break;
|
|
2992
|
+
}
|
|
2993
|
+
return _context6.abrupt("return");
|
|
2994
|
+
case 4:
|
|
2995
|
+
offset = (_rule$offset = rule.offset) !== null && _rule$offset !== void 0 ? _rule$offset : 0;
|
|
2996
|
+
needed = offset + rule.bytes.length;
|
|
2997
|
+
if (!(blob.size < needed)) {
|
|
2998
|
+
_context6.next = 5;
|
|
2999
|
+
break;
|
|
3000
|
+
}
|
|
3001
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B"));
|
|
3002
|
+
case 5:
|
|
3003
|
+
_context6.next = 6;
|
|
3004
|
+
return blob.slice(0, needed).arrayBuffer();
|
|
3005
|
+
case 6:
|
|
3006
|
+
headerBuf = _context6.sent;
|
|
3007
|
+
header = new Uint8Array(headerBuf);
|
|
3008
|
+
matched = rule.bytes.every(function (_byte, i) {
|
|
3009
|
+
return header[offset + i] === _byte;
|
|
3010
|
+
});
|
|
3011
|
+
if (matched) {
|
|
3012
|
+
_context6.next = 7;
|
|
3013
|
+
break;
|
|
3014
|
+
}
|
|
3015
|
+
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"));
|
|
3016
|
+
case 7:
|
|
3017
|
+
case "end":
|
|
3018
|
+
return _context6.stop();
|
|
2927
3019
|
}
|
|
2928
|
-
}
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
const rule = MAGIC_BYTES.find((r) => r.ext.includes(ext));
|
|
2932
|
-
if (!rule || rule.bytes.length === 0) return;
|
|
2933
|
-
const offset = rule.offset ?? 0;
|
|
2934
|
-
const needed = offset + rule.bytes.length;
|
|
2935
|
-
if (blob.size < needed) {
|
|
2936
|
-
throw new OssError(ErrorCode.INVALID_PARAMS, `\u6587\u4EF6 "${fileName}" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B`);
|
|
2937
|
-
}
|
|
2938
|
-
const headerBuf = await blob.slice(0, needed).arrayBuffer();
|
|
2939
|
-
const header = new Uint8Array(headerBuf);
|
|
2940
|
-
const matched = rule.bytes.every((byte, i) => header[offset + i] === byte);
|
|
2941
|
-
if (!matched) {
|
|
2942
|
-
throw new OssError(
|
|
2943
|
-
ErrorCode.INVALID_PARAMS,
|
|
2944
|
-
`\u6587\u4EF6 "${fileName}" \u5B9E\u9645\u5185\u5BB9\u4E0E\u6269\u5C55\u540D ".${ext}" \u4E0D\u5339\u914D\uFF0C\u7591\u4F3C\u4F2A\u9020\u6587\u4EF6`
|
|
2945
|
-
);
|
|
2946
|
-
}
|
|
3020
|
+
}, _callee6);
|
|
3021
|
+
}));
|
|
3022
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
2947
3023
|
}
|
|
2948
|
-
|
|
2949
|
-
// src/request.ts
|
|
2950
3024
|
function sleep(ms) {
|
|
2951
|
-
return new Promise((resolve)
|
|
3025
|
+
return new Promise(function (resolve) {
|
|
3026
|
+
return setTimeout(resolve, ms);
|
|
3027
|
+
});
|
|
2952
3028
|
}
|
|
2953
3029
|
function parseJson(json) {
|
|
2954
3030
|
if (json.code !== 200) {
|
|
@@ -2956,160 +3032,327 @@ function parseJson(json) {
|
|
|
2956
3032
|
}
|
|
2957
3033
|
return json.data;
|
|
2958
3034
|
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
const controller = new AbortController();
|
|
2962
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
2963
|
-
let res;
|
|
2964
|
-
try {
|
|
2965
|
-
res = await fetch(url, {
|
|
2966
|
-
method: "POST",
|
|
2967
|
-
headers: { "Content-Type": "application/json" },
|
|
2968
|
-
body: JSON.stringify(body),
|
|
2969
|
-
signal: controller.signal
|
|
2970
|
-
});
|
|
2971
|
-
} catch (err) {
|
|
2972
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
2973
|
-
throw new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`);
|
|
2974
|
-
}
|
|
2975
|
-
throw new OssError(ErrorCode.NETWORK, `\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
2976
|
-
} finally {
|
|
2977
|
-
clearTimeout(timer);
|
|
2978
|
-
}
|
|
2979
|
-
let json;
|
|
2980
|
-
try {
|
|
2981
|
-
json = await res.json();
|
|
2982
|
-
} catch {
|
|
2983
|
-
throw new OssError(res.status, `\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ${res.status}\uFF09`);
|
|
2984
|
-
}
|
|
2985
|
-
return parseJson(json);
|
|
3035
|
+
function fetchJson(_x3, _x4, _x5, _x6) {
|
|
3036
|
+
return _fetchJson.apply(this, arguments);
|
|
2986
3037
|
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3038
|
+
function _fetchJson() {
|
|
3039
|
+
_fetchJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(baseURL, timeout, path, body) {
|
|
3040
|
+
var url, controller, timer, res, json, _t;
|
|
3041
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
3042
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3043
|
+
case 0:
|
|
3044
|
+
url = "".concat(baseURL).concat(path);
|
|
3045
|
+
controller = new AbortController();
|
|
3046
|
+
timer = setTimeout(function () {
|
|
3047
|
+
return controller.abort();
|
|
3048
|
+
}, timeout);
|
|
3049
|
+
_context7.prev = 1;
|
|
3050
|
+
_context7.next = 2;
|
|
3051
|
+
return fetch(url, {
|
|
3052
|
+
method: "POST",
|
|
3053
|
+
headers: {
|
|
3054
|
+
"Content-Type": "application/json"
|
|
3055
|
+
},
|
|
3056
|
+
body: JSON.stringify(body),
|
|
3057
|
+
signal: controller.signal
|
|
3058
|
+
});
|
|
3059
|
+
case 2:
|
|
3060
|
+
res = _context7.sent;
|
|
3061
|
+
_context7.next = 5;
|
|
3062
|
+
break;
|
|
3063
|
+
case 3:
|
|
3064
|
+
_context7.prev = 3;
|
|
3065
|
+
_t = _context7["catch"](1);
|
|
3066
|
+
if (!(_t instanceof DOMException && _t.name === "AbortError")) {
|
|
3067
|
+
_context7.next = 4;
|
|
3068
|
+
break;
|
|
3069
|
+
}
|
|
3070
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3071
|
+
case 4:
|
|
3072
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t instanceof Error ? _t.message : String(_t)));
|
|
3073
|
+
case 5:
|
|
3074
|
+
_context7.prev = 5;
|
|
3075
|
+
clearTimeout(timer);
|
|
3076
|
+
return _context7.finish(5);
|
|
3077
|
+
case 6:
|
|
3078
|
+
_context7.prev = 6;
|
|
3079
|
+
_context7.next = 7;
|
|
3080
|
+
return res.json();
|
|
3081
|
+
case 7:
|
|
3082
|
+
json = _context7.sent;
|
|
3083
|
+
_context7.next = 9;
|
|
3084
|
+
break;
|
|
3085
|
+
case 8:
|
|
3086
|
+
_context7.prev = 8;
|
|
3087
|
+
_context7["catch"](6);
|
|
3088
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3089
|
+
case 9:
|
|
3090
|
+
return _context7.abrupt("return", parseJson(json));
|
|
3091
|
+
case 10:
|
|
3092
|
+
case "end":
|
|
3093
|
+
return _context7.stop();
|
|
3094
|
+
}
|
|
3095
|
+
}, _callee7, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3096
|
+
}));
|
|
3097
|
+
return _fetchJson.apply(this, arguments);
|
|
3013
3098
|
}
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3099
|
+
function fetchFormData(_x7, _x8, _x9, _x0) {
|
|
3100
|
+
return _fetchFormData.apply(this, arguments);
|
|
3101
|
+
}
|
|
3102
|
+
function _fetchFormData() {
|
|
3103
|
+
_fetchFormData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(baseURL, timeout, path, formData) {
|
|
3104
|
+
var url, controller, timer, res, json, _t3;
|
|
3105
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
3106
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3107
|
+
case 0:
|
|
3108
|
+
url = "".concat(baseURL).concat(path);
|
|
3109
|
+
controller = new AbortController();
|
|
3110
|
+
timer = setTimeout(function () {
|
|
3111
|
+
return controller.abort();
|
|
3112
|
+
}, timeout);
|
|
3113
|
+
_context8.prev = 1;
|
|
3114
|
+
_context8.next = 2;
|
|
3115
|
+
return fetch(url, {
|
|
3116
|
+
method: "POST",
|
|
3117
|
+
body: formData,
|
|
3118
|
+
signal: controller.signal
|
|
3119
|
+
});
|
|
3120
|
+
case 2:
|
|
3121
|
+
res = _context8.sent;
|
|
3122
|
+
_context8.next = 5;
|
|
3123
|
+
break;
|
|
3124
|
+
case 3:
|
|
3125
|
+
_context8.prev = 3;
|
|
3126
|
+
_t3 = _context8["catch"](1);
|
|
3127
|
+
if (!(_t3 instanceof DOMException && _t3.name === "AbortError")) {
|
|
3128
|
+
_context8.next = 4;
|
|
3129
|
+
break;
|
|
3130
|
+
}
|
|
3131
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3132
|
+
case 4:
|
|
3133
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t3 instanceof Error ? _t3.message : String(_t3)));
|
|
3134
|
+
case 5:
|
|
3135
|
+
_context8.prev = 5;
|
|
3136
|
+
clearTimeout(timer);
|
|
3137
|
+
return _context8.finish(5);
|
|
3138
|
+
case 6:
|
|
3139
|
+
_context8.prev = 6;
|
|
3140
|
+
_context8.next = 7;
|
|
3141
|
+
return res.json();
|
|
3142
|
+
case 7:
|
|
3143
|
+
json = _context8.sent;
|
|
3144
|
+
_context8.next = 9;
|
|
3145
|
+
break;
|
|
3146
|
+
case 8:
|
|
3147
|
+
_context8.prev = 8;
|
|
3148
|
+
_context8["catch"](6);
|
|
3149
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3150
|
+
case 9:
|
|
3151
|
+
return _context8.abrupt("return", parseJson(json));
|
|
3152
|
+
case 10:
|
|
3153
|
+
case "end":
|
|
3154
|
+
return _context8.stop();
|
|
3030
3155
|
}
|
|
3031
|
-
};
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3156
|
+
}, _callee8, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3157
|
+
}));
|
|
3158
|
+
return _fetchFormData.apply(this, arguments);
|
|
3159
|
+
}
|
|
3160
|
+
function fetchFormDataWithProgress(_x1, _x10, _x11, _x12, _x13) {
|
|
3161
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
3162
|
+
}
|
|
3163
|
+
function _fetchFormDataWithProgress() {
|
|
3164
|
+
_fetchFormDataWithProgress = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(baseURL, timeout, path, formData, onProgress) {
|
|
3165
|
+
var url;
|
|
3166
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
3167
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3168
|
+
case 0:
|
|
3169
|
+
if (!(typeof XMLHttpRequest === "undefined")) {
|
|
3170
|
+
_context9.next = 1;
|
|
3171
|
+
break;
|
|
3172
|
+
}
|
|
3173
|
+
return _context9.abrupt("return", fetchFormData(baseURL, timeout, path, formData));
|
|
3174
|
+
case 1:
|
|
3175
|
+
url = "".concat(baseURL).concat(path);
|
|
3176
|
+
return _context9.abrupt("return", new Promise(function (resolve, reject) {
|
|
3177
|
+
var xhr = new XMLHttpRequest();
|
|
3178
|
+
xhr.open("POST", url, true);
|
|
3179
|
+
xhr.timeout = timeout;
|
|
3180
|
+
xhr.upload.onprogress = function (e) {
|
|
3181
|
+
if (e.lengthComputable) {
|
|
3182
|
+
onProgress({
|
|
3183
|
+
loaded: e.loaded,
|
|
3184
|
+
total: e.total,
|
|
3185
|
+
percent: Math.round(e.loaded / e.total * 100)
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
};
|
|
3189
|
+
xhr.onload = function () {
|
|
3190
|
+
try {
|
|
3191
|
+
var json = JSON.parse(xhr.responseText);
|
|
3192
|
+
if (json.code !== 200) {
|
|
3193
|
+
reject(new OssError(json.code, json.message || json.error || "Unknown error"));
|
|
3194
|
+
} else {
|
|
3195
|
+
resolve(json.data);
|
|
3196
|
+
}
|
|
3197
|
+
} catch (_unused3) {
|
|
3198
|
+
reject(new OssError(xhr.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(xhr.status, "\uFF09")));
|
|
3199
|
+
}
|
|
3200
|
+
};
|
|
3201
|
+
xhr.onerror = function () {
|
|
3202
|
+
reject(new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25"));
|
|
3203
|
+
};
|
|
3204
|
+
xhr.ontimeout = function () {
|
|
3205
|
+
reject(new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09")));
|
|
3206
|
+
};
|
|
3207
|
+
xhr.send(formData);
|
|
3208
|
+
}));
|
|
3209
|
+
case 2:
|
|
3210
|
+
case "end":
|
|
3211
|
+
return _context9.stop();
|
|
3042
3212
|
}
|
|
3043
|
-
};
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
};
|
|
3047
|
-
xhr.ontimeout = () => {
|
|
3048
|
-
reject(new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`));
|
|
3049
|
-
};
|
|
3050
|
-
xhr.send(formData);
|
|
3051
|
-
});
|
|
3213
|
+
}, _callee9);
|
|
3214
|
+
}));
|
|
3215
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
3052
3216
|
}
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3217
|
+
function fetchGet(_x14, _x15, _x16) {
|
|
3218
|
+
return _fetchGet.apply(this, arguments);
|
|
3219
|
+
}
|
|
3220
|
+
function _fetchGet() {
|
|
3221
|
+
_fetchGet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(baseURL, timeout, path) {
|
|
3222
|
+
var url, controller, timer, res, json, _t5;
|
|
3223
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
3224
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
3225
|
+
case 0:
|
|
3226
|
+
url = "".concat(baseURL).concat(path);
|
|
3227
|
+
controller = new AbortController();
|
|
3228
|
+
timer = setTimeout(function () {
|
|
3229
|
+
return controller.abort();
|
|
3230
|
+
}, timeout);
|
|
3231
|
+
_context0.prev = 1;
|
|
3232
|
+
_context0.next = 2;
|
|
3233
|
+
return fetch(url, {
|
|
3234
|
+
method: "GET",
|
|
3235
|
+
signal: controller.signal
|
|
3236
|
+
});
|
|
3237
|
+
case 2:
|
|
3238
|
+
res = _context0.sent;
|
|
3239
|
+
_context0.next = 5;
|
|
3240
|
+
break;
|
|
3241
|
+
case 3:
|
|
3242
|
+
_context0.prev = 3;
|
|
3243
|
+
_t5 = _context0["catch"](1);
|
|
3244
|
+
if (!(_t5 instanceof DOMException && _t5.name === "AbortError")) {
|
|
3245
|
+
_context0.next = 4;
|
|
3246
|
+
break;
|
|
3247
|
+
}
|
|
3248
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3249
|
+
case 4:
|
|
3250
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t5 instanceof Error ? _t5.message : String(_t5)));
|
|
3251
|
+
case 5:
|
|
3252
|
+
_context0.prev = 5;
|
|
3253
|
+
clearTimeout(timer);
|
|
3254
|
+
return _context0.finish(5);
|
|
3255
|
+
case 6:
|
|
3256
|
+
_context0.prev = 6;
|
|
3257
|
+
_context0.next = 7;
|
|
3258
|
+
return res.json();
|
|
3259
|
+
case 7:
|
|
3260
|
+
json = _context0.sent;
|
|
3261
|
+
_context0.next = 9;
|
|
3262
|
+
break;
|
|
3263
|
+
case 8:
|
|
3264
|
+
_context0.prev = 8;
|
|
3265
|
+
_context0["catch"](6);
|
|
3266
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3267
|
+
case 9:
|
|
3268
|
+
return _context0.abrupt("return", parseJson(json));
|
|
3269
|
+
case 10:
|
|
3270
|
+
case "end":
|
|
3271
|
+
return _context0.stop();
|
|
3272
|
+
}
|
|
3273
|
+
}, _callee0, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3274
|
+
}));
|
|
3275
|
+
return _fetchGet.apply(this, arguments);
|
|
3276
|
+
}
|
|
3277
|
+
function withRetry(_x17, _x18) {
|
|
3278
|
+
return _withRetry.apply(this, arguments);
|
|
3279
|
+
}
|
|
3280
|
+
function _withRetry() {
|
|
3281
|
+
_withRetry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(fn, retry) {
|
|
3282
|
+
var _retry$retries, _retry$delay, _retry$backoff;
|
|
3283
|
+
var maxRetries, baseDelay, backoff, lastError, attempt, waitMs, _t7;
|
|
3284
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
3285
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
3286
|
+
case 0:
|
|
3287
|
+
maxRetries = (_retry$retries = retry === null || retry === void 0 ? void 0 : retry.retries) !== null && _retry$retries !== void 0 ? _retry$retries : 2;
|
|
3288
|
+
baseDelay = (_retry$delay = retry === null || retry === void 0 ? void 0 : retry.delay) !== null && _retry$delay !== void 0 ? _retry$delay : 1e3;
|
|
3289
|
+
backoff = (_retry$backoff = retry === null || retry === void 0 ? void 0 : retry.backoff) !== null && _retry$backoff !== void 0 ? _retry$backoff : 2;
|
|
3290
|
+
attempt = 0;
|
|
3291
|
+
case 1:
|
|
3292
|
+
if (!(attempt <= maxRetries)) {
|
|
3293
|
+
_context1.next = 8;
|
|
3294
|
+
break;
|
|
3295
|
+
}
|
|
3296
|
+
_context1.prev = 2;
|
|
3297
|
+
_context1.next = 3;
|
|
3298
|
+
return fn();
|
|
3299
|
+
case 3:
|
|
3300
|
+
return _context1.abrupt("return", _context1.sent);
|
|
3301
|
+
case 4:
|
|
3302
|
+
_context1.prev = 4;
|
|
3303
|
+
_t7 = _context1["catch"](2);
|
|
3304
|
+
lastError = _t7;
|
|
3305
|
+
if (lastError.isRetryable) {
|
|
3306
|
+
_context1.next = 5;
|
|
3307
|
+
break;
|
|
3308
|
+
}
|
|
3309
|
+
throw lastError;
|
|
3310
|
+
case 5:
|
|
3311
|
+
if (!(attempt >= maxRetries)) {
|
|
3312
|
+
_context1.next = 6;
|
|
3313
|
+
break;
|
|
3314
|
+
}
|
|
3315
|
+
return _context1.abrupt("continue", 8);
|
|
3316
|
+
case 6:
|
|
3317
|
+
waitMs = baseDelay * Math.pow(backoff, attempt);
|
|
3318
|
+
_context1.next = 7;
|
|
3319
|
+
return sleep(waitMs);
|
|
3320
|
+
case 7:
|
|
3321
|
+
attempt++;
|
|
3322
|
+
_context1.next = 1;
|
|
3323
|
+
break;
|
|
3324
|
+
case 8:
|
|
3325
|
+
throw lastError;
|
|
3326
|
+
case 9:
|
|
3327
|
+
case "end":
|
|
3328
|
+
return _context1.stop();
|
|
3329
|
+
}
|
|
3330
|
+
}, _callee1, null, [[2, 4]]);
|
|
3331
|
+
}));
|
|
3332
|
+
return _withRetry.apply(this, arguments);
|
|
3096
3333
|
}
|
|
3097
3334
|
function requestJsonWithRetry(baseURL, timeout, path, body, retry) {
|
|
3098
|
-
return withRetry(
|
|
3335
|
+
return withRetry(function () {
|
|
3336
|
+
return fetchJson(baseURL, timeout, path, body);
|
|
3337
|
+
}, retry);
|
|
3099
3338
|
}
|
|
3100
3339
|
function requestFormDataWithRetry(baseURL, timeout, path, formData, retry, onProgress) {
|
|
3101
3340
|
if (onProgress) {
|
|
3102
3341
|
return fetchFormDataWithProgress(baseURL, timeout, path, formData, onProgress);
|
|
3103
3342
|
}
|
|
3104
|
-
return withRetry(
|
|
3343
|
+
return withRetry(function () {
|
|
3344
|
+
return fetchFormData(baseURL, timeout, path, formData);
|
|
3345
|
+
}, retry);
|
|
3105
3346
|
}
|
|
3106
3347
|
function requestGetWithRetry(baseURL, timeout, path, retry) {
|
|
3107
|
-
return withRetry(
|
|
3348
|
+
return withRetry(function () {
|
|
3349
|
+
return fetchGet(baseURL, timeout, path);
|
|
3350
|
+
}, retry);
|
|
3108
3351
|
}
|
|
3109
3352
|
|
|
3110
3353
|
// src/compress.ts
|
|
3111
|
-
var IMAGE_EXTENSIONS = /* @__PURE__ */
|
|
3112
|
-
var VIDEO_EXTENSIONS = /* @__PURE__ */
|
|
3354
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */new Set(["jpg", "jpeg", "png", "webp", "bmp"]);
|
|
3355
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */new Set(["mp4", "webm", "mov", "avi", "mkv", "flv", "wmv"]);
|
|
3113
3356
|
function getExtension(fileName) {
|
|
3114
3357
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
3115
3358
|
}
|
|
@@ -3128,19 +3371,17 @@ var DEFAULT_LIMITS = {
|
|
|
3128
3371
|
other: 10 * 1024 * 1024
|
|
3129
3372
|
};
|
|
3130
3373
|
function getSizeLimit(fileName, limits) {
|
|
3131
|
-
|
|
3374
|
+
var merged = _objectSpread$3(_objectSpread$3({}, DEFAULT_LIMITS), limits);
|
|
3132
3375
|
if (isImage(fileName)) return merged.image;
|
|
3133
3376
|
if (isVideo(fileName)) return merged.video;
|
|
3134
3377
|
return merged.other;
|
|
3135
3378
|
}
|
|
3136
3379
|
function validateFileSize(blob, fileName, limits) {
|
|
3137
|
-
|
|
3380
|
+
var maxSize = getSizeLimit(fileName, limits);
|
|
3138
3381
|
if (blob.size > maxSize) {
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
throw new Error(
|
|
3142
|
-
`\u6587\u4EF6 "${fileName}" \u5927\u5C0F ${sizeMB}MB \u8D85\u8FC7\u9650\u5236 ${limitMB}MB`
|
|
3143
|
-
);
|
|
3382
|
+
var sizeMB = (blob.size / 1024 / 1024).toFixed(1);
|
|
3383
|
+
var limitMB = (maxSize / 1024 / 1024).toFixed(1);
|
|
3384
|
+
throw new Error("\u6587\u4EF6 \"".concat(fileName, "\" \u5927\u5C0F ").concat(sizeMB, "MB \u8D85\u8FC7\u9650\u5236 ").concat(limitMB, "MB"));
|
|
3144
3385
|
}
|
|
3145
3386
|
}
|
|
3146
3387
|
var DEFAULT_COMPRESS = {
|
|
@@ -3149,71 +3390,119 @@ var DEFAULT_COMPRESS = {
|
|
|
3149
3390
|
imageMaxWidth: 1920,
|
|
3150
3391
|
imageMaxHeight: 1080
|
|
3151
3392
|
};
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3393
|
+
function compressImageBlob(_x19, _x20) {
|
|
3394
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3395
|
+
}
|
|
3396
|
+
function _compressImageBlob() {
|
|
3397
|
+
_compressImageBlob = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(blob, options) {
|
|
3398
|
+
var opts, bitmap, srcW, srcH, targetW, targetH, canvas, ctx, ext, outputType, compressed;
|
|
3399
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
3400
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3401
|
+
case 0:
|
|
3402
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), options);
|
|
3403
|
+
if (!(typeof createImageBitmap === "undefined" || typeof OffscreenCanvas === "undefined")) {
|
|
3404
|
+
_context10.next = 1;
|
|
3405
|
+
break;
|
|
3406
|
+
}
|
|
3407
|
+
return _context10.abrupt("return", blob);
|
|
3408
|
+
case 1:
|
|
3409
|
+
_context10.prev = 1;
|
|
3410
|
+
_context10.next = 2;
|
|
3411
|
+
return createImageBitmap(blob);
|
|
3412
|
+
case 2:
|
|
3413
|
+
bitmap = _context10.sent;
|
|
3414
|
+
srcW = bitmap.width, srcH = bitmap.height;
|
|
3415
|
+
targetW = srcW;
|
|
3416
|
+
targetH = srcH;
|
|
3417
|
+
if (targetW > opts.imageMaxWidth) {
|
|
3418
|
+
targetH = Math.round(targetH * (opts.imageMaxWidth / targetW));
|
|
3419
|
+
targetW = opts.imageMaxWidth;
|
|
3420
|
+
}
|
|
3421
|
+
if (targetH > opts.imageMaxHeight) {
|
|
3422
|
+
targetW = Math.round(targetW * (opts.imageMaxHeight / targetH));
|
|
3423
|
+
targetH = opts.imageMaxHeight;
|
|
3424
|
+
}
|
|
3425
|
+
canvas = new OffscreenCanvas(targetW, targetH);
|
|
3426
|
+
ctx = canvas.getContext("2d");
|
|
3427
|
+
if (ctx) {
|
|
3428
|
+
_context10.next = 3;
|
|
3429
|
+
break;
|
|
3430
|
+
}
|
|
3431
|
+
bitmap.close();
|
|
3432
|
+
return _context10.abrupt("return", blob);
|
|
3433
|
+
case 3:
|
|
3434
|
+
ctx.drawImage(bitmap, 0, 0, targetW, targetH);
|
|
3435
|
+
bitmap.close();
|
|
3436
|
+
ext = getExtension(blob.name || "");
|
|
3437
|
+
outputType = "image/webp";
|
|
3438
|
+
if (ext === "png") outputType = "image/png";else if (ext === "jpg" || ext === "jpeg") outputType = "image/jpeg";
|
|
3439
|
+
_context10.next = 4;
|
|
3440
|
+
return canvas.convertToBlob({
|
|
3441
|
+
type: outputType,
|
|
3442
|
+
quality: opts.imageQuality
|
|
3443
|
+
});
|
|
3444
|
+
case 4:
|
|
3445
|
+
compressed = _context10.sent;
|
|
3446
|
+
return _context10.abrupt("return", compressed.size < blob.size ? compressed : blob);
|
|
3447
|
+
case 5:
|
|
3448
|
+
_context10.prev = 5;
|
|
3449
|
+
_context10["catch"](1);
|
|
3450
|
+
return _context10.abrupt("return", blob);
|
|
3451
|
+
case 6:
|
|
3452
|
+
case "end":
|
|
3453
|
+
return _context10.stop();
|
|
3454
|
+
}
|
|
3455
|
+
}, _callee10, null, [[1, 5]]);
|
|
3456
|
+
}));
|
|
3457
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3458
|
+
}
|
|
3459
|
+
function processFile(_x21, _x22, _x23, _x24) {
|
|
3460
|
+
return _processFile.apply(this, arguments);
|
|
3461
|
+
} // src/client.ts
|
|
3462
|
+
function _processFile() {
|
|
3463
|
+
_processFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(blob, fileName, compress, limits) {
|
|
3464
|
+
var opts;
|
|
3465
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
3466
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
3467
|
+
case 0:
|
|
3468
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), compress);
|
|
3469
|
+
if (!(opts.enabled && isImage(fileName))) {
|
|
3470
|
+
_context11.next = 2;
|
|
3471
|
+
break;
|
|
3472
|
+
}
|
|
3473
|
+
_context11.next = 1;
|
|
3474
|
+
return compressImageBlob(blob, opts);
|
|
3475
|
+
case 1:
|
|
3476
|
+
blob = _context11.sent;
|
|
3477
|
+
case 2:
|
|
3478
|
+
validateFileSize(blob, fileName, limits);
|
|
3479
|
+
return _context11.abrupt("return", blob);
|
|
3480
|
+
case 3:
|
|
3481
|
+
case "end":
|
|
3482
|
+
return _context11.stop();
|
|
3483
|
+
}
|
|
3484
|
+
}, _callee11);
|
|
3485
|
+
}));
|
|
3486
|
+
return _processFile.apply(this, arguments);
|
|
3198
3487
|
}
|
|
3199
|
-
|
|
3200
|
-
// src/client.ts
|
|
3201
3488
|
var DEFAULT_BASE_URL = "https://we0.ai";
|
|
3202
3489
|
var DEFAULT_TIMEOUT = 3e4;
|
|
3203
3490
|
function uuid() {
|
|
3204
3491
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
3205
3492
|
return crypto.randomUUID();
|
|
3206
3493
|
}
|
|
3207
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c)
|
|
3208
|
-
|
|
3494
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
3495
|
+
var r = Math.random() * 16 | 0;
|
|
3209
3496
|
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
3210
3497
|
});
|
|
3211
3498
|
}
|
|
3212
3499
|
function toBlob(input) {
|
|
3213
3500
|
if (input instanceof Blob) return input;
|
|
3214
|
-
if (typeof input === "string") return new Blob([input], {
|
|
3501
|
+
if (typeof input === "string") return new Blob([input], {
|
|
3502
|
+
type: "text/plain"
|
|
3503
|
+
});
|
|
3215
3504
|
if (input instanceof ArrayBuffer) return new Blob([input]);
|
|
3216
|
-
|
|
3505
|
+
var copy = input.slice().buffer;
|
|
3217
3506
|
return new Blob([copy]);
|
|
3218
3507
|
}
|
|
3219
3508
|
function getExt2(fileName) {
|
|
@@ -3222,144 +3511,246 @@ function getExt2(fileName) {
|
|
|
3222
3511
|
function resolveFileName(originalName, rename) {
|
|
3223
3512
|
if (!rename) return originalName;
|
|
3224
3513
|
if (rename === true) {
|
|
3225
|
-
|
|
3226
|
-
return ext ?
|
|
3514
|
+
var ext = getExt2(originalName);
|
|
3515
|
+
return ext ? "".concat(uuid(), ".").concat(ext) : uuid();
|
|
3227
3516
|
}
|
|
3228
3517
|
if (typeof rename === "string") return rename;
|
|
3229
3518
|
if (typeof rename === "function") return rename(originalName);
|
|
3230
3519
|
return originalName;
|
|
3231
3520
|
}
|
|
3232
|
-
function createOssClient(
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3521
|
+
function createOssClient() {
|
|
3522
|
+
var _options$baseURL, _options$timeout;
|
|
3523
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3524
|
+
var baseURL = (_options$baseURL = options.baseURL) !== null && _options$baseURL !== void 0 ? _options$baseURL : DEFAULT_BASE_URL;
|
|
3525
|
+
var timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : DEFAULT_TIMEOUT;
|
|
3526
|
+
var defaultRetry = options.retry;
|
|
3527
|
+
var defaultCompress = options.compress;
|
|
3528
|
+
var defaultLimits = options.limits;
|
|
3529
|
+
var allowedExtensions = options.allowedExtensions;
|
|
3239
3530
|
function mergeRetry(override) {
|
|
3240
3531
|
if (!defaultRetry && !override) return void 0;
|
|
3241
|
-
return {
|
|
3532
|
+
return _objectSpread$3(_objectSpread$3({}, defaultRetry), override);
|
|
3242
3533
|
}
|
|
3243
3534
|
function resolveCompress(override) {
|
|
3244
|
-
if (override === false) return {
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3535
|
+
if (override === false) return {
|
|
3536
|
+
enabled: false
|
|
3537
|
+
};
|
|
3538
|
+
if (defaultCompress === false && override === void 0) return {
|
|
3539
|
+
enabled: false
|
|
3540
|
+
};
|
|
3541
|
+
var base = _typeof$1(defaultCompress) === "object" ? defaultCompress : {};
|
|
3542
|
+
return override ? _objectSpread$3(_objectSpread$3({}, base), override) : Object.keys(base).length ? base : void 0;
|
|
3248
3543
|
}
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3544
|
+
function uploadOne(_x25, _x26, _x27, _x28) {
|
|
3545
|
+
return _uploadOne.apply(this, arguments);
|
|
3546
|
+
}
|
|
3547
|
+
function _uploadOne() {
|
|
3548
|
+
_uploadOne = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(sessionId, file, fileName, opts) {
|
|
3549
|
+
var finalName, blob, compress, formData;
|
|
3550
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
3551
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
3552
|
+
case 0:
|
|
3553
|
+
if (sessionId) {
|
|
3554
|
+
_context5.next = 1;
|
|
3555
|
+
break;
|
|
3556
|
+
}
|
|
3557
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3558
|
+
case 1:
|
|
3559
|
+
if (fileName) {
|
|
3560
|
+
_context5.next = 2;
|
|
3561
|
+
break;
|
|
3562
|
+
}
|
|
3563
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3564
|
+
case 2:
|
|
3565
|
+
finalName = resolveFileName(fileName, opts === null || opts === void 0 ? void 0 : opts.rename);
|
|
3566
|
+
blob = toBlob(file);
|
|
3567
|
+
if (opts !== null && opts !== void 0 && opts.skipValidation) {
|
|
3568
|
+
_context5.next = 3;
|
|
3569
|
+
break;
|
|
3570
|
+
}
|
|
3571
|
+
validateExtension(finalName, allowedExtensions);
|
|
3572
|
+
_context5.next = 3;
|
|
3573
|
+
return validateMagicBytes(blob, finalName);
|
|
3574
|
+
case 3:
|
|
3575
|
+
compress = resolveCompress(opts === null || opts === void 0 ? void 0 : opts.compress);
|
|
3576
|
+
_context5.next = 4;
|
|
3577
|
+
return processFile(blob, finalName, compress, defaultLimits);
|
|
3578
|
+
case 4:
|
|
3579
|
+
blob = _context5.sent;
|
|
3580
|
+
formData = new FormData();
|
|
3581
|
+
formData.append("file", blob, finalName);
|
|
3582
|
+
formData.append("sessionId", sessionId);
|
|
3583
|
+
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));
|
|
3584
|
+
case 5:
|
|
3585
|
+
case "end":
|
|
3586
|
+
return _context5.stop();
|
|
3587
|
+
}
|
|
3588
|
+
}, _callee5);
|
|
3589
|
+
}));
|
|
3590
|
+
return _uploadOne.apply(this, arguments);
|
|
3275
3591
|
}
|
|
3276
3592
|
return {
|
|
3277
3593
|
upload: uploadOne,
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
return new Promise((resolve, reject) => {
|
|
3289
|
-
function next() {
|
|
3290
|
-
if (results.length === files.length) {
|
|
3291
|
-
resolve(results);
|
|
3292
|
-
return;
|
|
3293
|
-
}
|
|
3294
|
-
while (running < concurrency && index < files.length) {
|
|
3295
|
-
const i = index++;
|
|
3296
|
-
const item = files[i];
|
|
3297
|
-
running++;
|
|
3298
|
-
const fileOpts = {
|
|
3299
|
-
retry: opts?.retry,
|
|
3300
|
-
compress: opts?.compress,
|
|
3301
|
-
...item.options
|
|
3302
|
-
};
|
|
3303
|
-
uploadOne(sessionId, item.file, item.fileName, fileOpts).then((result) => {
|
|
3304
|
-
results[i] = { fileName: item.fileName, success: true, result };
|
|
3305
|
-
}).catch((error) => {
|
|
3306
|
-
results[i] = { fileName: item.fileName, success: false, error };
|
|
3307
|
-
if (!continueOnError) {
|
|
3308
|
-
reject(error);
|
|
3309
|
-
return;
|
|
3594
|
+
uploadBatch: function uploadBatch(sessionId, files, opts) {
|
|
3595
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
3596
|
+
var _opts$concurrency, _opts$continueOnError;
|
|
3597
|
+
var concurrency, continueOnError, results, running, index;
|
|
3598
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
3599
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3600
|
+
case 0:
|
|
3601
|
+
if (sessionId) {
|
|
3602
|
+
_context.next = 1;
|
|
3603
|
+
break;
|
|
3310
3604
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3605
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3606
|
+
case 1:
|
|
3607
|
+
if (files.length) {
|
|
3608
|
+
_context.next = 2;
|
|
3609
|
+
break;
|
|
3610
|
+
}
|
|
3611
|
+
return _context.abrupt("return", []);
|
|
3612
|
+
case 2:
|
|
3613
|
+
concurrency = (_opts$concurrency = opts === null || opts === void 0 ? void 0 : opts.concurrency) !== null && _opts$concurrency !== void 0 ? _opts$concurrency : 3;
|
|
3614
|
+
continueOnError = (_opts$continueOnError = opts === null || opts === void 0 ? void 0 : opts.continueOnError) !== null && _opts$continueOnError !== void 0 ? _opts$continueOnError : true;
|
|
3615
|
+
results = [];
|
|
3616
|
+
running = 0;
|
|
3617
|
+
index = 0;
|
|
3618
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
3619
|
+
function next() {
|
|
3620
|
+
if (results.length === files.length) {
|
|
3621
|
+
resolve(results);
|
|
3622
|
+
return;
|
|
3623
|
+
}
|
|
3624
|
+
var _loop = function _loop() {
|
|
3625
|
+
var i = index++;
|
|
3626
|
+
var item = files[i];
|
|
3627
|
+
running++;
|
|
3628
|
+
var fileOpts = _objectSpread$3({
|
|
3629
|
+
retry: opts === null || opts === void 0 ? void 0 : opts.retry,
|
|
3630
|
+
compress: opts === null || opts === void 0 ? void 0 : opts.compress
|
|
3631
|
+
}, item.options);
|
|
3632
|
+
uploadOne(sessionId, item.file, item.fileName, fileOpts).then(function (result) {
|
|
3633
|
+
results[i] = {
|
|
3634
|
+
fileName: item.fileName,
|
|
3635
|
+
success: true,
|
|
3636
|
+
result: result
|
|
3637
|
+
};
|
|
3638
|
+
})["catch"](function (error) {
|
|
3639
|
+
results[i] = {
|
|
3640
|
+
fileName: item.fileName,
|
|
3641
|
+
success: false,
|
|
3642
|
+
error: error
|
|
3643
|
+
};
|
|
3644
|
+
if (!continueOnError) {
|
|
3645
|
+
reject(error);
|
|
3646
|
+
return;
|
|
3647
|
+
}
|
|
3648
|
+
})["finally"](function () {
|
|
3649
|
+
running--;
|
|
3650
|
+
next();
|
|
3651
|
+
});
|
|
3652
|
+
};
|
|
3653
|
+
while (running < concurrency && index < files.length) {
|
|
3654
|
+
_loop();
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
next();
|
|
3658
|
+
}));
|
|
3659
|
+
case 3:
|
|
3660
|
+
case "end":
|
|
3661
|
+
return _context.stop();
|
|
3315
3662
|
}
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
});
|
|
3663
|
+
}, _callee);
|
|
3664
|
+
}))();
|
|
3319
3665
|
},
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3666
|
+
"delete": function _delete(sessionId, fileName, opts) {
|
|
3667
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
3668
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
3669
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3670
|
+
case 0:
|
|
3671
|
+
if (sessionId) {
|
|
3672
|
+
_context2.next = 1;
|
|
3673
|
+
break;
|
|
3674
|
+
}
|
|
3675
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3676
|
+
case 1:
|
|
3677
|
+
if (fileName) {
|
|
3678
|
+
_context2.next = 2;
|
|
3679
|
+
break;
|
|
3680
|
+
}
|
|
3681
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3682
|
+
case 2:
|
|
3683
|
+
return _context2.abrupt("return", requestJsonWithRetry(baseURL, timeout, "/api/oss/delete", {
|
|
3684
|
+
sessionId: sessionId,
|
|
3685
|
+
fileName: fileName
|
|
3686
|
+
}, mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry)));
|
|
3687
|
+
case 3:
|
|
3688
|
+
case "end":
|
|
3689
|
+
return _context2.stop();
|
|
3690
|
+
}
|
|
3691
|
+
}, _callee2);
|
|
3692
|
+
}))();
|
|
3334
3693
|
},
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3694
|
+
getFileUrl: function getFileUrl(sessionId, fileName, opts) {
|
|
3695
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
3696
|
+
var params, result;
|
|
3697
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
3698
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3699
|
+
case 0:
|
|
3700
|
+
if (sessionId) {
|
|
3701
|
+
_context3.next = 1;
|
|
3702
|
+
break;
|
|
3703
|
+
}
|
|
3704
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3705
|
+
case 1:
|
|
3706
|
+
if (fileName) {
|
|
3707
|
+
_context3.next = 2;
|
|
3708
|
+
break;
|
|
3709
|
+
}
|
|
3710
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3711
|
+
case 2:
|
|
3712
|
+
params = new URLSearchParams({
|
|
3713
|
+
sessionId: sessionId,
|
|
3714
|
+
fileName: fileName
|
|
3715
|
+
});
|
|
3716
|
+
_context3.next = 3;
|
|
3717
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
3718
|
+
case 3:
|
|
3719
|
+
result = _context3.sent;
|
|
3720
|
+
return _context3.abrupt("return", result.url || "");
|
|
3721
|
+
case 4:
|
|
3722
|
+
case "end":
|
|
3723
|
+
return _context3.stop();
|
|
3724
|
+
}
|
|
3725
|
+
}, _callee3);
|
|
3726
|
+
}))();
|
|
3350
3727
|
},
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3728
|
+
listFiles: function listFiles(sessionId, opts) {
|
|
3729
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
3730
|
+
var params, result;
|
|
3731
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
3732
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
3733
|
+
case 0:
|
|
3734
|
+
if (sessionId) {
|
|
3735
|
+
_context4.next = 1;
|
|
3736
|
+
break;
|
|
3737
|
+
}
|
|
3738
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3739
|
+
case 1:
|
|
3740
|
+
params = new URLSearchParams({
|
|
3741
|
+
sessionId: sessionId
|
|
3742
|
+
});
|
|
3743
|
+
_context4.next = 2;
|
|
3744
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
3745
|
+
case 2:
|
|
3746
|
+
result = _context4.sent;
|
|
3747
|
+
return _context4.abrupt("return", result.files);
|
|
3748
|
+
case 3:
|
|
3749
|
+
case "end":
|
|
3750
|
+
return _context4.stop();
|
|
3751
|
+
}
|
|
3752
|
+
}, _callee4);
|
|
3753
|
+
}))();
|
|
3363
3754
|
}
|
|
3364
3755
|
};
|
|
3365
3756
|
}
|
|
@@ -3679,9 +4070,9 @@ function _isUserSessionAdmin() {
|
|
|
3679
4070
|
return _isUserSessionAdmin.apply(this, arguments);
|
|
3680
4071
|
}
|
|
3681
4072
|
|
|
3682
|
-
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$
|
|
3683
|
-
function _unsupportedIterableToArray$
|
|
3684
|
-
function _arrayLikeToArray$
|
|
4073
|
+
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; } } }; }
|
|
4074
|
+
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; } }
|
|
4075
|
+
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; }
|
|
3685
4076
|
var RESERVED_STATUS_FIELD = "status";
|
|
3686
4077
|
var PUBLISH_STATUS_VALUES = new Set(["draft", "published"]);
|
|
3687
4078
|
// 初始化Supabase连接和CMS系统
|
|
@@ -4199,26 +4590,12 @@ function _iterableToArrayLimit(r, l) {
|
|
|
4199
4590
|
}
|
|
4200
4591
|
}
|
|
4201
4592
|
|
|
4202
|
-
function _arrayLikeToArray$1(r, a) {
|
|
4203
|
-
(null == a || a > r.length) && (a = r.length);
|
|
4204
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4205
|
-
return n;
|
|
4206
|
-
}
|
|
4207
|
-
|
|
4208
|
-
function _unsupportedIterableToArray$1(r, a) {
|
|
4209
|
-
if (r) {
|
|
4210
|
-
if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
|
|
4211
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
4212
|
-
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;
|
|
4213
|
-
}
|
|
4214
|
-
}
|
|
4215
|
-
|
|
4216
4593
|
function _nonIterableRest() {
|
|
4217
4594
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4218
4595
|
}
|
|
4219
4596
|
|
|
4220
4597
|
function _slicedToArray(r, e) {
|
|
4221
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$
|
|
4598
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
4222
4599
|
}
|
|
4223
4600
|
|
|
4224
4601
|
var _excluded = ["id", "created_at", "updated_at"],
|
|
@@ -4227,8 +4604,8 @@ var _excluded = ["id", "created_at", "updated_at"],
|
|
|
4227
4604
|
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; } } }; }
|
|
4228
4605
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4229
4606
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4230
|
-
function ownKeys$
|
|
4231
|
-
function _objectSpread$
|
|
4607
|
+
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; }
|
|
4608
|
+
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; }
|
|
4232
4609
|
function normalizeJsonLikeFields(schemaFields, payload) {
|
|
4233
4610
|
if (!schemaFields || schemaFields.length === 0) return payload;
|
|
4234
4611
|
var jsonLikeFieldNames = new Set(schemaFields.filter(function (f) {
|
|
@@ -4237,7 +4614,7 @@ function normalizeJsonLikeFields(schemaFields, payload) {
|
|
|
4237
4614
|
return f.name;
|
|
4238
4615
|
}));
|
|
4239
4616
|
if (jsonLikeFieldNames.size === 0) return payload;
|
|
4240
|
-
var normalized = _objectSpread$
|
|
4617
|
+
var normalized = _objectSpread$2({}, payload);
|
|
4241
4618
|
for (var _i = 0, _Object$entries = Object.entries(payload); _i < _Object$entries.length; _i++) {
|
|
4242
4619
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
4243
4620
|
key = _Object$entries$_i[0],
|
|
@@ -5333,8 +5710,8 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5333
5710
|
}]);
|
|
5334
5711
|
}();
|
|
5335
5712
|
|
|
5336
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5337
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5713
|
+
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; }
|
|
5714
|
+
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; }
|
|
5338
5715
|
function getRoleFromSupabaseUser$2(user) {
|
|
5339
5716
|
var _user$app_metadata, _user$user_metadata;
|
|
5340
5717
|
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;
|
|
@@ -5360,7 +5737,7 @@ function toSupabaseEmail(account, sessionId) {
|
|
|
5360
5737
|
return "".concat(sid, "_").concat(localPart, "@").concat(domain);
|
|
5361
5738
|
}
|
|
5362
5739
|
function buildAdminMetadata(existingMetadata, sessionId, account) {
|
|
5363
|
-
return _objectSpread(_objectSpread({}, existingMetadata || {}), {}, {
|
|
5740
|
+
return _objectSpread$1(_objectSpread$1({}, existingMetadata || {}), {}, {
|
|
5364
5741
|
role: "admin",
|
|
5365
5742
|
session_id: normalizeSessionId(sessionId),
|
|
5366
5743
|
original_username: account
|
|
@@ -6242,6 +6619,262 @@ function _uploadToOss() {
|
|
|
6242
6619
|
return _uploadToOss.apply(this, arguments);
|
|
6243
6620
|
}
|
|
6244
6621
|
|
|
6622
|
+
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; }
|
|
6623
|
+
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; }
|
|
6624
|
+
var CONFIG_NAMESPACE_RE = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;
|
|
6625
|
+
var CONFIG_SESSION_RE = /^[a-zA-Z0-9_]{1,128}$/;
|
|
6626
|
+
function getConfigSessionId(c) {
|
|
6627
|
+
return normalizeSessionId(c.req.header("X-Session-Id") || c.req.header("x-session-id"));
|
|
6628
|
+
}
|
|
6629
|
+
function validateConfigSessionId(sessionId) {
|
|
6630
|
+
if (!sessionId) return "缺少 X-Session-Id,无法访问配置中心";
|
|
6631
|
+
if (!CONFIG_SESSION_RE.test(sessionId)) {
|
|
6632
|
+
return "X-Session-Id 格式不合法";
|
|
6633
|
+
}
|
|
6634
|
+
return null;
|
|
6635
|
+
}
|
|
6636
|
+
function getConfigsTableName(sessionId) {
|
|
6637
|
+
return "".concat(sessionId, "__config__");
|
|
6638
|
+
}
|
|
6639
|
+
function normalizeValues(values) {
|
|
6640
|
+
if (!values || _typeof$1(values) !== "object" || Array.isArray(values)) {
|
|
6641
|
+
return {};
|
|
6642
|
+
}
|
|
6643
|
+
return values;
|
|
6644
|
+
}
|
|
6645
|
+
function buildFieldStatus(values) {
|
|
6646
|
+
return Object.fromEntries(Object.entries(values).map(function (_ref) {
|
|
6647
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
6648
|
+
key = _ref2[0],
|
|
6649
|
+
value = _ref2[1];
|
|
6650
|
+
return [key, {
|
|
6651
|
+
configured: value !== null && value !== undefined && String(value).trim() !== ""
|
|
6652
|
+
}];
|
|
6653
|
+
}));
|
|
6654
|
+
}
|
|
6655
|
+
function ensureConfigsTable(_x) {
|
|
6656
|
+
return _ensureConfigsTable.apply(this, arguments);
|
|
6657
|
+
}
|
|
6658
|
+
function _ensureConfigsTable() {
|
|
6659
|
+
_ensureConfigsTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(tableName) {
|
|
6660
|
+
var supabase, createTableSQL, _yield$supabase$rpc, error;
|
|
6661
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
6662
|
+
while (1) switch (_context.prev = _context.next) {
|
|
6663
|
+
case 0:
|
|
6664
|
+
supabase = getSupabase();
|
|
6665
|
+
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 ");
|
|
6666
|
+
_context.next = 1;
|
|
6667
|
+
return supabase.rpc("execute_sql", {
|
|
6668
|
+
sql_query: createTableSQL
|
|
6669
|
+
});
|
|
6670
|
+
case 1:
|
|
6671
|
+
_yield$supabase$rpc = _context.sent;
|
|
6672
|
+
error = _yield$supabase$rpc.error;
|
|
6673
|
+
if (!error) {
|
|
6674
|
+
_context.next = 2;
|
|
6675
|
+
break;
|
|
6676
|
+
}
|
|
6677
|
+
throw error;
|
|
6678
|
+
case 2:
|
|
6679
|
+
case "end":
|
|
6680
|
+
return _context.stop();
|
|
6681
|
+
}
|
|
6682
|
+
}, _callee);
|
|
6683
|
+
}));
|
|
6684
|
+
return _ensureConfigsTable.apply(this, arguments);
|
|
6685
|
+
}
|
|
6686
|
+
function validateNamespace(namespace) {
|
|
6687
|
+
if (!namespace) return "缺少 namespace";
|
|
6688
|
+
if (!CONFIG_NAMESPACE_RE.test(namespace)) {
|
|
6689
|
+
return "namespace 只能包含字母、数字、下划线和连字符,且必须以字母开头";
|
|
6690
|
+
}
|
|
6691
|
+
return null;
|
|
6692
|
+
}
|
|
6693
|
+
function toConfigResponse(row, fallbackNamespace) {
|
|
6694
|
+
var values = normalizeValues(row === null || row === void 0 ? void 0 : row.values);
|
|
6695
|
+
return {
|
|
6696
|
+
id: row === null || row === void 0 ? void 0 : row.id,
|
|
6697
|
+
namespace: (row === null || row === void 0 ? void 0 : row.namespace) || fallbackNamespace,
|
|
6698
|
+
values: values,
|
|
6699
|
+
fields: buildFieldStatus(values),
|
|
6700
|
+
created_at: row === null || row === void 0 ? void 0 : row.created_at,
|
|
6701
|
+
updated_at: row === null || row === void 0 ? void 0 : row.updated_at
|
|
6702
|
+
};
|
|
6703
|
+
}
|
|
6704
|
+
function getConfig(_x2) {
|
|
6705
|
+
return _getConfig.apply(this, arguments);
|
|
6706
|
+
}
|
|
6707
|
+
function _getConfig() {
|
|
6708
|
+
_getConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
6709
|
+
var namespace, namespaceError, _response, sessionId, sessionError, _response2, tableName, supabase, _yield$supabase$from$, data, error, response, _response3, _t;
|
|
6710
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
6711
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
6712
|
+
case 0:
|
|
6713
|
+
_context2.prev = 0;
|
|
6714
|
+
namespace = (c.req.query("namespace") || "").trim();
|
|
6715
|
+
namespaceError = validateNamespace(namespace);
|
|
6716
|
+
if (!namespaceError) {
|
|
6717
|
+
_context2.next = 1;
|
|
6718
|
+
break;
|
|
6719
|
+
}
|
|
6720
|
+
_response = {
|
|
6721
|
+
success: false,
|
|
6722
|
+
message: namespaceError
|
|
6723
|
+
};
|
|
6724
|
+
return _context2.abrupt("return", c.json(_response, 200));
|
|
6725
|
+
case 1:
|
|
6726
|
+
sessionId = getConfigSessionId(c);
|
|
6727
|
+
sessionError = validateConfigSessionId(sessionId);
|
|
6728
|
+
if (!sessionError) {
|
|
6729
|
+
_context2.next = 2;
|
|
6730
|
+
break;
|
|
6731
|
+
}
|
|
6732
|
+
_response2 = {
|
|
6733
|
+
success: false,
|
|
6734
|
+
message: sessionError
|
|
6735
|
+
};
|
|
6736
|
+
return _context2.abrupt("return", c.json(_response2, 200));
|
|
6737
|
+
case 2:
|
|
6738
|
+
tableName = getConfigsTableName(sessionId);
|
|
6739
|
+
_context2.next = 3;
|
|
6740
|
+
return ensureConfigsTable(tableName);
|
|
6741
|
+
case 3:
|
|
6742
|
+
supabase = getSupabase();
|
|
6743
|
+
_context2.next = 4;
|
|
6744
|
+
return supabase.from(tableName).select("*").eq("namespace", namespace).maybeSingle();
|
|
6745
|
+
case 4:
|
|
6746
|
+
_yield$supabase$from$ = _context2.sent;
|
|
6747
|
+
data = _yield$supabase$from$.data;
|
|
6748
|
+
error = _yield$supabase$from$.error;
|
|
6749
|
+
if (!error) {
|
|
6750
|
+
_context2.next = 5;
|
|
6751
|
+
break;
|
|
6752
|
+
}
|
|
6753
|
+
throw error;
|
|
6754
|
+
case 5:
|
|
6755
|
+
response = {
|
|
6756
|
+
success: true,
|
|
6757
|
+
data: toConfigResponse(data, namespace)
|
|
6758
|
+
};
|
|
6759
|
+
return _context2.abrupt("return", c.json(response, 200));
|
|
6760
|
+
case 6:
|
|
6761
|
+
_context2.prev = 6;
|
|
6762
|
+
_t = _context2["catch"](0);
|
|
6763
|
+
console.error("获取配置失败:", _t);
|
|
6764
|
+
_response3 = {
|
|
6765
|
+
success: false,
|
|
6766
|
+
message: "获取配置失败",
|
|
6767
|
+
error: _t.message
|
|
6768
|
+
};
|
|
6769
|
+
return _context2.abrupt("return", c.json(_response3, 500));
|
|
6770
|
+
case 7:
|
|
6771
|
+
case "end":
|
|
6772
|
+
return _context2.stop();
|
|
6773
|
+
}
|
|
6774
|
+
}, _callee2, null, [[0, 6]]);
|
|
6775
|
+
}));
|
|
6776
|
+
return _getConfig.apply(this, arguments);
|
|
6777
|
+
}
|
|
6778
|
+
function updateConfig(_x3) {
|
|
6779
|
+
return _updateConfig.apply(this, arguments);
|
|
6780
|
+
}
|
|
6781
|
+
function _updateConfig() {
|
|
6782
|
+
_updateConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c) {
|
|
6783
|
+
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;
|
|
6784
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
6785
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
6786
|
+
case 0:
|
|
6787
|
+
_context3.prev = 0;
|
|
6788
|
+
namespace = (c.req.param("namespace") || "").trim();
|
|
6789
|
+
namespaceError = validateNamespace(namespace);
|
|
6790
|
+
if (!namespaceError) {
|
|
6791
|
+
_context3.next = 1;
|
|
6792
|
+
break;
|
|
6793
|
+
}
|
|
6794
|
+
_response4 = {
|
|
6795
|
+
success: false,
|
|
6796
|
+
message: namespaceError
|
|
6797
|
+
};
|
|
6798
|
+
return _context3.abrupt("return", c.json(_response4, 200));
|
|
6799
|
+
case 1:
|
|
6800
|
+
_context3.next = 2;
|
|
6801
|
+
return c.req.json();
|
|
6802
|
+
case 2:
|
|
6803
|
+
body = _context3.sent;
|
|
6804
|
+
values = normalizeValues(body === null || body === void 0 ? void 0 : body.values);
|
|
6805
|
+
sessionId = getConfigSessionId(c);
|
|
6806
|
+
sessionError = validateConfigSessionId(sessionId);
|
|
6807
|
+
if (!sessionError) {
|
|
6808
|
+
_context3.next = 3;
|
|
6809
|
+
break;
|
|
6810
|
+
}
|
|
6811
|
+
_response5 = {
|
|
6812
|
+
success: false,
|
|
6813
|
+
message: sessionError
|
|
6814
|
+
};
|
|
6815
|
+
return _context3.abrupt("return", c.json(_response5, 200));
|
|
6816
|
+
case 3:
|
|
6817
|
+
tableName = getConfigsTableName(sessionId);
|
|
6818
|
+
_context3.next = 4;
|
|
6819
|
+
return ensureConfigsTable(tableName);
|
|
6820
|
+
case 4:
|
|
6821
|
+
supabase = getSupabase();
|
|
6822
|
+
_context3.next = 5;
|
|
6823
|
+
return supabase.from(tableName).select("values").eq("namespace", namespace).maybeSingle();
|
|
6824
|
+
case 5:
|
|
6825
|
+
_yield$supabase$from$2 = _context3.sent;
|
|
6826
|
+
existing = _yield$supabase$from$2.data;
|
|
6827
|
+
existingError = _yield$supabase$from$2.error;
|
|
6828
|
+
if (!existingError) {
|
|
6829
|
+
_context3.next = 6;
|
|
6830
|
+
break;
|
|
6831
|
+
}
|
|
6832
|
+
throw existingError;
|
|
6833
|
+
case 6:
|
|
6834
|
+
nextValues = _objectSpread(_objectSpread({}, normalizeValues(existing === null || existing === void 0 ? void 0 : existing.values)), values);
|
|
6835
|
+
_context3.next = 7;
|
|
6836
|
+
return supabase.from(tableName).upsert({
|
|
6837
|
+
namespace: namespace,
|
|
6838
|
+
values: nextValues,
|
|
6839
|
+
updated_at: new Date().toISOString()
|
|
6840
|
+
}, {
|
|
6841
|
+
onConflict: "namespace"
|
|
6842
|
+
}).select("*").single();
|
|
6843
|
+
case 7:
|
|
6844
|
+
_yield$supabase$from$3 = _context3.sent;
|
|
6845
|
+
data = _yield$supabase$from$3.data;
|
|
6846
|
+
error = _yield$supabase$from$3.error;
|
|
6847
|
+
if (!error) {
|
|
6848
|
+
_context3.next = 8;
|
|
6849
|
+
break;
|
|
6850
|
+
}
|
|
6851
|
+
throw error;
|
|
6852
|
+
case 8:
|
|
6853
|
+
response = {
|
|
6854
|
+
success: true,
|
|
6855
|
+
message: "配置保存成功",
|
|
6856
|
+
data: toConfigResponse(data, namespace)
|
|
6857
|
+
};
|
|
6858
|
+
return _context3.abrupt("return", c.json(response, 200));
|
|
6859
|
+
case 9:
|
|
6860
|
+
_context3.prev = 9;
|
|
6861
|
+
_t2 = _context3["catch"](0);
|
|
6862
|
+
console.error("保存配置失败:", _t2);
|
|
6863
|
+
_response6 = {
|
|
6864
|
+
success: false,
|
|
6865
|
+
message: "保存配置失败",
|
|
6866
|
+
error: _t2.message
|
|
6867
|
+
};
|
|
6868
|
+
return _context3.abrupt("return", c.json(_response6, 500));
|
|
6869
|
+
case 10:
|
|
6870
|
+
case "end":
|
|
6871
|
+
return _context3.stop();
|
|
6872
|
+
}
|
|
6873
|
+
}, _callee3, null, [[0, 9]]);
|
|
6874
|
+
}));
|
|
6875
|
+
return _updateConfig.apply(this, arguments);
|
|
6876
|
+
}
|
|
6877
|
+
|
|
6245
6878
|
var AUTH_REQUIRED = "CMS_AUTH_REQUIRED";
|
|
6246
6879
|
var AUTH_INVALID = "CMS_AUTH_INVALID";
|
|
6247
6880
|
var CMS_FORBIDDEN = "CMS_FORBIDDEN";
|
|
@@ -6737,9 +7370,17 @@ function createOssUploadRoute(app) {
|
|
|
6737
7370
|
app.post("/upload", requireJwtAuth, requireAdminRole, uploadToOss);
|
|
6738
7371
|
return app;
|
|
6739
7372
|
}
|
|
7373
|
+
function createConfigRoute(app) {
|
|
7374
|
+
app.get("/configs", requireJwtAuth, requireAdminRole, getConfig);
|
|
7375
|
+
app.put("/configs/:namespace", requireJwtAuth, requireAdminRole, function (c) {
|
|
7376
|
+
return updateConfig(c);
|
|
7377
|
+
});
|
|
7378
|
+
return app;
|
|
7379
|
+
}
|
|
6740
7380
|
// 一键创建所有CMS路由
|
|
6741
7381
|
function createCmsRoutes(app) {
|
|
6742
7382
|
createModelRoute(app);
|
|
7383
|
+
createConfigRoute(app);
|
|
6743
7384
|
createDynamicDataRoute(app);
|
|
6744
7385
|
createDynamicAuthRoute(app);
|
|
6745
7386
|
return app;
|
|
@@ -6755,6 +7396,7 @@ exports.closeDatabase = closeSupabase;
|
|
|
6755
7396
|
exports.closeSupabase = closeSupabase;
|
|
6756
7397
|
exports.createAuthRoute = createAuthRoute;
|
|
6757
7398
|
exports.createCmsRoutes = createCmsRoutes;
|
|
7399
|
+
exports.createConfigRoute = createConfigRoute;
|
|
6758
7400
|
exports.createDataRoute = createDataRoute;
|
|
6759
7401
|
exports.createDynamicAuthRoute = createDynamicAuthRoute;
|
|
6760
7402
|
exports.createDynamicDataRoute = createDynamicDataRoute;
|
|
@@ -6768,6 +7410,7 @@ exports.dropForeignKeys = dropForeignKeys;
|
|
|
6768
7410
|
exports.executeSupabaseSetup = executeSupabaseSetup;
|
|
6769
7411
|
exports.getAuthService = getAuthService;
|
|
6770
7412
|
exports.getCmsModelService = getCmsModelService;
|
|
7413
|
+
exports.getConfig = getConfig;
|
|
6771
7414
|
exports.getCurrentUser = getCurrentUser;
|
|
6772
7415
|
exports.getDatabase = getSupabase;
|
|
6773
7416
|
exports.getDynamicTableService = getDynamicTableService;
|
|
@@ -6789,6 +7432,7 @@ exports.signup = signup;
|
|
|
6789
7432
|
exports.signupStatus = signupStatus;
|
|
6790
7433
|
exports.syncDatabase = initializeCmsSystem;
|
|
6791
7434
|
exports.testConnection = testConnection;
|
|
7435
|
+
exports.updateConfig = updateConfig;
|
|
6792
7436
|
exports.updateModel = updateModel;
|
|
6793
7437
|
exports.updateTableData = updateTableData;
|
|
6794
7438
|
exports.uploadToOss = uploadToOss;
|