@kevisual/api 0.0.62 → 0.0.64
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/query-ai.js +13 -9
- package/dist/query-app.js +13 -9
- package/dist/query-config.js +11 -7
- package/dist/query-login-node.js +11 -7
- package/dist/query-login.js +11 -7
- package/dist/query-mark.js +11 -7
- package/dist/query-proxy.js +20 -9
- package/dist/query-remote.js +36 -5
- package/dist/query-resources.d.ts +11 -0
- package/dist/query-resources.js +21 -10
- package/dist/query-secret.js +11 -7
- package/dist/query-shop.js +13 -9
- package/dist/store-mark.js +10 -6
- package/package.json +7 -7
- package/query/query-resources/index.ts +30 -9
package/dist/query-ai.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -201,6 +201,10 @@ class Query {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const headers2 = req.headers || {};
|
|
205
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
206
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
207
|
+
}
|
|
204
208
|
} catch (e) {
|
|
205
209
|
console.error("request beforeFn error", e, req);
|
|
206
210
|
return wrapperError({
|
|
@@ -261,20 +265,20 @@ class Query {
|
|
|
261
265
|
this.afterResponse = fn;
|
|
262
266
|
}
|
|
263
267
|
async fetchText(urlOrOptions, options) {
|
|
264
|
-
let _options = { ...options };
|
|
268
|
+
let _options = { method: "GET", ...options };
|
|
265
269
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
266
270
|
_options.url = urlOrOptions;
|
|
267
271
|
}
|
|
268
272
|
if (typeof urlOrOptions === "object") {
|
|
269
273
|
_options = { ...urlOrOptions, ..._options };
|
|
270
274
|
}
|
|
275
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
276
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
277
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
278
|
+
}
|
|
271
279
|
const res = await adapter({
|
|
272
|
-
method: "GET",
|
|
273
280
|
..._options,
|
|
274
|
-
headers
|
|
275
|
-
...this.headers,
|
|
276
|
-
..._options?.headers || {}
|
|
277
|
-
}
|
|
281
|
+
headers
|
|
278
282
|
});
|
|
279
283
|
if (res && !res.code) {
|
|
280
284
|
return {
|
|
@@ -286,7 +290,7 @@ class Query {
|
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
// node_modules/.pnpm/@kevisual+router@0.
|
|
293
|
+
// node_modules/.pnpm/@kevisual+router@0.1.1/node_modules/@kevisual/router/dist/router-define.js
|
|
290
294
|
class Chain {
|
|
291
295
|
object;
|
|
292
296
|
app;
|
|
@@ -420,7 +424,7 @@ var appDefine = QueryUtil.create({
|
|
|
420
424
|
}
|
|
421
425
|
});
|
|
422
426
|
|
|
423
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
427
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query.js
|
|
424
428
|
class BaseQuery {
|
|
425
429
|
query;
|
|
426
430
|
queryDefine;
|
package/dist/query-app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -201,6 +201,10 @@ class Query {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const headers2 = req.headers || {};
|
|
205
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
206
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
207
|
+
}
|
|
204
208
|
} catch (e) {
|
|
205
209
|
console.error("request beforeFn error", e, req);
|
|
206
210
|
return wrapperError({
|
|
@@ -261,20 +265,20 @@ class Query {
|
|
|
261
265
|
this.afterResponse = fn;
|
|
262
266
|
}
|
|
263
267
|
async fetchText(urlOrOptions, options) {
|
|
264
|
-
let _options = { ...options };
|
|
268
|
+
let _options = { method: "GET", ...options };
|
|
265
269
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
266
270
|
_options.url = urlOrOptions;
|
|
267
271
|
}
|
|
268
272
|
if (typeof urlOrOptions === "object") {
|
|
269
273
|
_options = { ...urlOrOptions, ..._options };
|
|
270
274
|
}
|
|
275
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
276
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
277
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
278
|
+
}
|
|
271
279
|
const res = await adapter({
|
|
272
|
-
method: "GET",
|
|
273
280
|
..._options,
|
|
274
|
-
headers
|
|
275
|
-
...this.headers,
|
|
276
|
-
..._options?.headers || {}
|
|
277
|
-
}
|
|
281
|
+
headers
|
|
278
282
|
});
|
|
279
283
|
if (res && !res.code) {
|
|
280
284
|
return {
|
|
@@ -286,7 +290,7 @@ class Query {
|
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
// node_modules/.pnpm/@kevisual+router@0.
|
|
293
|
+
// node_modules/.pnpm/@kevisual+router@0.1.1/node_modules/@kevisual/router/dist/router-define.js
|
|
290
294
|
class Chain {
|
|
291
295
|
object;
|
|
292
296
|
app;
|
|
@@ -494,7 +498,7 @@ var userAppDefine = QueryUtil.create({
|
|
|
494
498
|
}
|
|
495
499
|
});
|
|
496
500
|
|
|
497
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
501
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query.js
|
|
498
502
|
class BaseQuery {
|
|
499
503
|
query;
|
|
500
504
|
queryDefine;
|
package/dist/query-config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -201,6 +201,10 @@ class Query {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const headers2 = req.headers || {};
|
|
205
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
206
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
207
|
+
}
|
|
204
208
|
} catch (e) {
|
|
205
209
|
console.error("request beforeFn error", e, req);
|
|
206
210
|
return wrapperError({
|
|
@@ -261,20 +265,20 @@ class Query {
|
|
|
261
265
|
this.afterResponse = fn;
|
|
262
266
|
}
|
|
263
267
|
async fetchText(urlOrOptions, options) {
|
|
264
|
-
let _options = { ...options };
|
|
268
|
+
let _options = { method: "GET", ...options };
|
|
265
269
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
266
270
|
_options.url = urlOrOptions;
|
|
267
271
|
}
|
|
268
272
|
if (typeof urlOrOptions === "object") {
|
|
269
273
|
_options = { ...urlOrOptions, ..._options };
|
|
270
274
|
}
|
|
275
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
276
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
277
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
278
|
+
}
|
|
271
279
|
const res = await adapter({
|
|
272
|
-
method: "GET",
|
|
273
280
|
..._options,
|
|
274
|
-
headers
|
|
275
|
-
...this.headers,
|
|
276
|
-
..._options?.headers || {}
|
|
277
|
-
}
|
|
281
|
+
headers
|
|
278
282
|
});
|
|
279
283
|
if (res && !res.code) {
|
|
280
284
|
return {
|
package/dist/query-login-node.js
CHANGED
|
@@ -194,7 +194,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
197
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
198
198
|
var isTextForContentType = (contentType) => {
|
|
199
199
|
if (!contentType)
|
|
200
200
|
return false;
|
|
@@ -397,6 +397,10 @@ class Query {
|
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
+
const headers2 = req.headers || {};
|
|
401
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
402
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
403
|
+
}
|
|
400
404
|
} catch (e) {
|
|
401
405
|
console.error("request beforeFn error", e, req);
|
|
402
406
|
return wrapperError({
|
|
@@ -457,20 +461,20 @@ class Query {
|
|
|
457
461
|
this.afterResponse = fn;
|
|
458
462
|
}
|
|
459
463
|
async fetchText(urlOrOptions, options) {
|
|
460
|
-
let _options = { ...options };
|
|
464
|
+
let _options = { method: "GET", ...options };
|
|
461
465
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
462
466
|
_options.url = urlOrOptions;
|
|
463
467
|
}
|
|
464
468
|
if (typeof urlOrOptions === "object") {
|
|
465
469
|
_options = { ...urlOrOptions, ..._options };
|
|
466
470
|
}
|
|
471
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
472
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
473
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
474
|
+
}
|
|
467
475
|
const res = await adapter({
|
|
468
|
-
method: "GET",
|
|
469
476
|
..._options,
|
|
470
|
-
headers
|
|
471
|
-
...this.headers,
|
|
472
|
-
..._options?.headers || {}
|
|
473
|
-
}
|
|
477
|
+
headers
|
|
474
478
|
});
|
|
475
479
|
if (res && !res.code) {
|
|
476
480
|
return {
|
package/dist/query-login.js
CHANGED
|
@@ -194,7 +194,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
197
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
198
198
|
var isTextForContentType = (contentType) => {
|
|
199
199
|
if (!contentType)
|
|
200
200
|
return false;
|
|
@@ -397,6 +397,10 @@ class Query {
|
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
+
const headers2 = req.headers || {};
|
|
401
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
402
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
403
|
+
}
|
|
400
404
|
} catch (e) {
|
|
401
405
|
console.error("request beforeFn error", e, req);
|
|
402
406
|
return wrapperError({
|
|
@@ -457,20 +461,20 @@ class Query {
|
|
|
457
461
|
this.afterResponse = fn;
|
|
458
462
|
}
|
|
459
463
|
async fetchText(urlOrOptions, options) {
|
|
460
|
-
let _options = { ...options };
|
|
464
|
+
let _options = { method: "GET", ...options };
|
|
461
465
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
462
466
|
_options.url = urlOrOptions;
|
|
463
467
|
}
|
|
464
468
|
if (typeof urlOrOptions === "object") {
|
|
465
469
|
_options = { ...urlOrOptions, ..._options };
|
|
466
470
|
}
|
|
471
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
472
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
473
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
474
|
+
}
|
|
467
475
|
const res = await adapter({
|
|
468
|
-
method: "GET",
|
|
469
476
|
..._options,
|
|
470
|
-
headers
|
|
471
|
-
...this.headers,
|
|
472
|
-
..._options?.headers || {}
|
|
473
|
-
}
|
|
477
|
+
headers
|
|
474
478
|
});
|
|
475
479
|
if (res && !res.code) {
|
|
476
480
|
return {
|
package/dist/query-mark.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -201,6 +201,10 @@ class Query {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const headers2 = req.headers || {};
|
|
205
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
206
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
207
|
+
}
|
|
204
208
|
} catch (e) {
|
|
205
209
|
console.error("request beforeFn error", e, req);
|
|
206
210
|
return wrapperError({
|
|
@@ -261,20 +265,20 @@ class Query {
|
|
|
261
265
|
this.afterResponse = fn;
|
|
262
266
|
}
|
|
263
267
|
async fetchText(urlOrOptions, options) {
|
|
264
|
-
let _options = { ...options };
|
|
268
|
+
let _options = { method: "GET", ...options };
|
|
265
269
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
266
270
|
_options.url = urlOrOptions;
|
|
267
271
|
}
|
|
268
272
|
if (typeof urlOrOptions === "object") {
|
|
269
273
|
_options = { ...urlOrOptions, ..._options };
|
|
270
274
|
}
|
|
275
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
276
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
277
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
278
|
+
}
|
|
271
279
|
const res = await adapter({
|
|
272
|
-
method: "GET",
|
|
273
280
|
..._options,
|
|
274
|
-
headers
|
|
275
|
-
...this.headers,
|
|
276
|
-
..._options?.headers || {}
|
|
277
|
-
}
|
|
281
|
+
headers
|
|
278
282
|
});
|
|
279
283
|
if (res && !res.code) {
|
|
280
284
|
return {
|
package/dist/query-proxy.js
CHANGED
|
@@ -194,7 +194,7 @@ var require_eventemitter32 = __commonJS((exports, module) => {
|
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
197
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
198
198
|
var isTextForContentType = (contentType) => {
|
|
199
199
|
if (!contentType)
|
|
200
200
|
return false;
|
|
@@ -589,6 +589,10 @@ class Query {
|
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
+
const headers2 = req.headers || {};
|
|
593
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
594
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
595
|
+
}
|
|
592
596
|
} catch (e) {
|
|
593
597
|
console.error("request beforeFn error", e, req);
|
|
594
598
|
return wrapperError({
|
|
@@ -649,20 +653,20 @@ class Query {
|
|
|
649
653
|
this.afterResponse = fn;
|
|
650
654
|
}
|
|
651
655
|
async fetchText(urlOrOptions, options) {
|
|
652
|
-
let _options = { ...options };
|
|
656
|
+
let _options = { method: "GET", ...options };
|
|
653
657
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
654
658
|
_options.url = urlOrOptions;
|
|
655
659
|
}
|
|
656
660
|
if (typeof urlOrOptions === "object") {
|
|
657
661
|
_options = { ...urlOrOptions, ..._options };
|
|
658
662
|
}
|
|
663
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
664
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
665
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
666
|
+
}
|
|
659
667
|
const res = await adapter({
|
|
660
|
-
method: "GET",
|
|
661
668
|
..._options,
|
|
662
|
-
headers
|
|
663
|
-
...this.headers,
|
|
664
|
-
..._options?.headers || {}
|
|
665
|
-
}
|
|
669
|
+
headers
|
|
666
670
|
});
|
|
667
671
|
if (res && !res.code) {
|
|
668
672
|
return {
|
|
@@ -685,7 +689,7 @@ class QueryClient extends Query {
|
|
|
685
689
|
}
|
|
686
690
|
}
|
|
687
691
|
|
|
688
|
-
// node_modules/.pnpm/@kevisual+router@0.
|
|
692
|
+
// node_modules/.pnpm/@kevisual+router@0.1.1/node_modules/@kevisual/router/dist/router-browser.js
|
|
689
693
|
var __create2 = Object.create;
|
|
690
694
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
691
695
|
var __defProp2 = Object.defineProperty;
|
|
@@ -14743,6 +14747,9 @@ var toJSONSchemaRoute = (route) => {
|
|
|
14743
14747
|
if (pickValues?.metadata?.args) {
|
|
14744
14748
|
pickValues.metadata.args = toJSONSchema3(pickValues?.metadata?.args, { mergeObject: false });
|
|
14745
14749
|
}
|
|
14750
|
+
if (pickValues?.metadata?.returns) {
|
|
14751
|
+
pickValues.metadata.returns = toJSONSchema3(pickValues?.metadata?.returns, { mergeObject: false });
|
|
14752
|
+
}
|
|
14746
14753
|
return pickValues;
|
|
14747
14754
|
};
|
|
14748
14755
|
var toJSONSchema3 = toJSONSchema2;
|
|
@@ -15142,9 +15149,13 @@ class QueryRouterServer extends QueryRouter {
|
|
|
15142
15149
|
}
|
|
15143
15150
|
return super.run(msg, ctx);
|
|
15144
15151
|
}
|
|
15152
|
+
async runAction(api2, payload, ctx) {
|
|
15153
|
+
const { path, key, id } = api2;
|
|
15154
|
+
return this.run({ path, key, id, payload }, ctx);
|
|
15155
|
+
}
|
|
15145
15156
|
}
|
|
15146
15157
|
|
|
15147
|
-
// node_modules/.pnpm/@kevisual+js-filter@0.0.
|
|
15158
|
+
// node_modules/.pnpm/@kevisual+js-filter@0.0.6/node_modules/@kevisual/js-filter/dist/index.js
|
|
15148
15159
|
class Lexer {
|
|
15149
15160
|
constructor(input) {
|
|
15150
15161
|
this.pos = 0;
|
package/dist/query-remote.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+remote-app@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+remote-app@0.0.6/node_modules/@kevisual/remote-app/dist/app.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -198,8 +198,10 @@ class RemoteApp {
|
|
|
198
198
|
mainApp;
|
|
199
199
|
url;
|
|
200
200
|
id;
|
|
201
|
+
username;
|
|
201
202
|
emitter;
|
|
202
203
|
isConnected;
|
|
204
|
+
isVerified;
|
|
203
205
|
ws;
|
|
204
206
|
remoteIsConnected;
|
|
205
207
|
isError = false;
|
|
@@ -216,12 +218,17 @@ class RemoteApp {
|
|
|
216
218
|
const token = opts.token;
|
|
217
219
|
const url = opts.url;
|
|
218
220
|
const id = opts.id;
|
|
221
|
+
const username = opts.username;
|
|
222
|
+
this.username = username;
|
|
219
223
|
this.emitter = opts?.emitter || new import__.default;
|
|
220
224
|
const _url = new URL(url);
|
|
221
225
|
if (token) {
|
|
222
226
|
_url.searchParams.set("token", token);
|
|
223
227
|
}
|
|
224
228
|
_url.searchParams.set("id", id);
|
|
229
|
+
if (!token && !username) {
|
|
230
|
+
console.error(`[remote-app] 不存在用户名和token ${id}. 权限认证会失败。`);
|
|
231
|
+
}
|
|
225
232
|
this.url = _url.toString();
|
|
226
233
|
this.id = id;
|
|
227
234
|
this.autoReconnect = opts?.autoReconnect ?? true;
|
|
@@ -253,8 +260,23 @@ class RemoteApp {
|
|
|
253
260
|
that.emitter.once("open", listenOnce);
|
|
254
261
|
});
|
|
255
262
|
}
|
|
263
|
+
async waitVerify() {
|
|
264
|
+
if (this.isVerified) {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
return new Promise((resolve) => {
|
|
268
|
+
const listenOnce = () => {
|
|
269
|
+
this.isVerified = true;
|
|
270
|
+
resolve(true);
|
|
271
|
+
};
|
|
272
|
+
this.emitter.once("verified", listenOnce);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
256
275
|
getWsURL(url) {
|
|
257
276
|
const { protocol } = new URL(url);
|
|
277
|
+
if (protocol.startsWith("ws")) {
|
|
278
|
+
return url.toString();
|
|
279
|
+
}
|
|
258
280
|
const wsProtocol = protocol === "https:" ? "wss:" : "ws:";
|
|
259
281
|
const wsURL = url.toString().replace(protocol, wsProtocol);
|
|
260
282
|
return wsURL;
|
|
@@ -275,6 +297,7 @@ class RemoteApp {
|
|
|
275
297
|
ws.onopen = function() {
|
|
276
298
|
that.isConnected = true;
|
|
277
299
|
that.onOpen();
|
|
300
|
+
console.log("[remote-app] WebSocket connection opened");
|
|
278
301
|
};
|
|
279
302
|
ws.onclose = function() {
|
|
280
303
|
that.isConnected = false;
|
|
@@ -359,7 +382,7 @@ class RemoteApp {
|
|
|
359
382
|
this.emitter.emit("message", data);
|
|
360
383
|
}
|
|
361
384
|
onError(error) {
|
|
362
|
-
console.error(
|
|
385
|
+
console.error(`[remote-app] 远程应用错误: ${this.id}`, error);
|
|
363
386
|
this.isError = true;
|
|
364
387
|
this.emitter.emit("error", error);
|
|
365
388
|
}
|
|
@@ -375,6 +398,7 @@ class RemoteApp {
|
|
|
375
398
|
listenProxy() {
|
|
376
399
|
const remoteApp = this;
|
|
377
400
|
const app = this.mainApp;
|
|
401
|
+
const username = this.username;
|
|
378
402
|
const listenFn = async (event) => {
|
|
379
403
|
try {
|
|
380
404
|
const data = event.toString();
|
|
@@ -382,11 +406,16 @@ class RemoteApp {
|
|
|
382
406
|
const bodyData = body?.data;
|
|
383
407
|
const message = bodyData?.message || {};
|
|
384
408
|
const context = bodyData?.context || {};
|
|
409
|
+
console.log("[remote-app] 远程应用收到消息:", body);
|
|
385
410
|
if (body?.code === 401) {
|
|
386
|
-
console.error("远程应用认证失败,请检查 token 是否正确");
|
|
411
|
+
console.error("[remote-app] 远程应用认证失败,请检查 token 是否正确");
|
|
387
412
|
this.isError = true;
|
|
388
413
|
return;
|
|
389
414
|
}
|
|
415
|
+
if (body?.type === "verified") {
|
|
416
|
+
remoteApp.emitter.emit("verified");
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
390
419
|
if (body?.type !== "proxy")
|
|
391
420
|
return;
|
|
392
421
|
if (!body.id) {
|
|
@@ -409,13 +438,15 @@ class RemoteApp {
|
|
|
409
438
|
}
|
|
410
439
|
});
|
|
411
440
|
} catch (error) {
|
|
412
|
-
console.error("处理远程代理请求出错:", error);
|
|
441
|
+
console.error("[remote-app] 处理远程代理请求出错:", error);
|
|
413
442
|
}
|
|
414
443
|
};
|
|
415
444
|
remoteApp.json({
|
|
416
445
|
id: this.id,
|
|
417
|
-
type: "registryClient"
|
|
446
|
+
type: "registryClient",
|
|
447
|
+
username
|
|
418
448
|
});
|
|
449
|
+
console.log(`[remote-app] 远程应用 ${this.id} (${username}) 已注册到主应用,等待消息...`);
|
|
419
450
|
remoteApp.emitter.on("message", listenFn);
|
|
420
451
|
const closeMessage = () => {
|
|
421
452
|
remoteApp.emitter.off("message", listenFn);
|
|
@@ -14,9 +14,14 @@ declare class QueryResources {
|
|
|
14
14
|
onProcess?: (opts?: Process) => void;
|
|
15
15
|
constructor(opts: QueryResourcesOptions);
|
|
16
16
|
setUsername(username: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* 设置prefix,类似 /{username}/resources/;
|
|
19
|
+
* @param prefix
|
|
20
|
+
*/
|
|
17
21
|
setPrefix(prefix: string): void;
|
|
18
22
|
header(headers?: Record<string, string>, json?: boolean): Record<string, string>;
|
|
19
23
|
get(data: any, opts: DataOpts): Promise<any>;
|
|
24
|
+
getUrl(prefix: string): string;
|
|
20
25
|
getList(prefix: string, data?: {
|
|
21
26
|
recursive?: boolean;
|
|
22
27
|
}, opts?: DataOpts): Promise<Result<any[]>>;
|
|
@@ -28,6 +33,12 @@ declare class QueryResources {
|
|
|
28
33
|
uploadChunkedFile(filepath: string, file: Blob, hash: string, opts?: DataOpts & {
|
|
29
34
|
chunkSize?: number;
|
|
30
35
|
}): Promise<Result<any>>;
|
|
36
|
+
/**
|
|
37
|
+
* 移除 prefix,获取相对路径
|
|
38
|
+
* @param filepath
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
getRelativePath(filepath: string): string;
|
|
31
42
|
getStat(filepath: string, opts?: DataOpts): Promise<Result<Stat>>;
|
|
32
43
|
/**
|
|
33
44
|
* @deprecated use getStat instead
|
package/dist/query-resources.js
CHANGED
|
@@ -446,7 +446,7 @@ var require_spark_md5 = __commonJS((exports, module) => {
|
|
|
446
446
|
});
|
|
447
447
|
});
|
|
448
448
|
|
|
449
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
449
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
450
450
|
var isTextForContentType = (contentType) => {
|
|
451
451
|
if (!contentType)
|
|
452
452
|
return false;
|
|
@@ -1061,19 +1061,25 @@ class QueryResources {
|
|
|
1061
1061
|
headers: this.header(opts?.headers)
|
|
1062
1062
|
});
|
|
1063
1063
|
}
|
|
1064
|
+
getUrl(prefix) {
|
|
1065
|
+
if (prefix.startsWith("http")) {
|
|
1066
|
+
return prefix;
|
|
1067
|
+
}
|
|
1068
|
+
return `${this.prefix}${prefix}`;
|
|
1069
|
+
}
|
|
1064
1070
|
async getList(prefix, data, opts) {
|
|
1065
1071
|
return this.get(data, {
|
|
1066
|
-
url:
|
|
1072
|
+
url: this.getUrl(prefix),
|
|
1067
1073
|
body: data,
|
|
1068
1074
|
...opts
|
|
1069
1075
|
});
|
|
1070
1076
|
}
|
|
1071
1077
|
async fetchFile(filepath, opts) {
|
|
1072
|
-
const url =
|
|
1078
|
+
const url = this.getUrl(filepath);
|
|
1073
1079
|
return this.get({}, { url, method: "GET", ...opts, headers: this.header(opts?.headers, false), isText: true });
|
|
1074
1080
|
}
|
|
1075
1081
|
async uploadFile(filepath, content, opts) {
|
|
1076
|
-
const pathname =
|
|
1082
|
+
const pathname = this.getUrl(filepath);
|
|
1077
1083
|
const filename = posix.basename(pathname);
|
|
1078
1084
|
const type = getContentType(filename);
|
|
1079
1085
|
const url = new URL(pathname, window.location.origin);
|
|
@@ -1111,12 +1117,11 @@ class QueryResources {
|
|
|
1111
1117
|
return res;
|
|
1112
1118
|
}
|
|
1113
1119
|
async uploadChunkedFile(filepath, file, hash, opts) {
|
|
1114
|
-
const pathname =
|
|
1120
|
+
const pathname = this.getUrl(filepath);
|
|
1115
1121
|
const filename = posix.basename(pathname);
|
|
1116
1122
|
const url = new URL(pathname, window.location.origin);
|
|
1117
1123
|
url.searchParams.set("hash", hash);
|
|
1118
1124
|
url.searchParams.set("chunk", "1");
|
|
1119
|
-
console.log(`url,`, url, hash);
|
|
1120
1125
|
const { chunkSize: _chunkSize, ...restOpts } = opts || {};
|
|
1121
1126
|
const chunkSize = _chunkSize ?? 5 * 1024 * 1024;
|
|
1122
1127
|
const totalChunks = Math.ceil(file.size / chunkSize);
|
|
@@ -1162,8 +1167,14 @@ class QueryResources {
|
|
|
1162
1167
|
this.onProcess?.({ type: "uploadFinish", filename, size: file.size, process: 100 });
|
|
1163
1168
|
return { code: 200, message: "上传成功" };
|
|
1164
1169
|
}
|
|
1170
|
+
getRelativePath(filepath) {
|
|
1171
|
+
if (filepath.startsWith(this.prefix)) {
|
|
1172
|
+
return filepath.slice(this.prefix.length);
|
|
1173
|
+
}
|
|
1174
|
+
return filepath;
|
|
1175
|
+
}
|
|
1165
1176
|
async getStat(filepath, opts) {
|
|
1166
|
-
const url =
|
|
1177
|
+
const url = this.getUrl(filepath);
|
|
1167
1178
|
return adapter({
|
|
1168
1179
|
url,
|
|
1169
1180
|
params: {
|
|
@@ -1181,8 +1192,8 @@ class QueryResources {
|
|
|
1181
1192
|
return this.uploadFile(filepath, "文件夹占位,其他文件不存在,文件夹不存在,如果有其他文件夹,删除当前文件夹占位文件即可", opts);
|
|
1182
1193
|
}
|
|
1183
1194
|
async rename(oldpath, newpath, opts) {
|
|
1184
|
-
const pathname =
|
|
1185
|
-
const newName =
|
|
1195
|
+
const pathname = this.getUrl(oldpath);
|
|
1196
|
+
const newName = this.getUrl(newpath);
|
|
1186
1197
|
const params = {
|
|
1187
1198
|
newName
|
|
1188
1199
|
};
|
|
@@ -1195,7 +1206,7 @@ class QueryResources {
|
|
|
1195
1206
|
});
|
|
1196
1207
|
}
|
|
1197
1208
|
async deleteFile(filepath, opts) {
|
|
1198
|
-
const url =
|
|
1209
|
+
const url = this.getUrl(filepath);
|
|
1199
1210
|
return adapter({
|
|
1200
1211
|
url,
|
|
1201
1212
|
method: "DELETE",
|
package/dist/query-secret.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -201,6 +201,10 @@ class Query {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const headers2 = req.headers || {};
|
|
205
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
206
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
207
|
+
}
|
|
204
208
|
} catch (e) {
|
|
205
209
|
console.error("request beforeFn error", e, req);
|
|
206
210
|
return wrapperError({
|
|
@@ -261,20 +265,20 @@ class Query {
|
|
|
261
265
|
this.afterResponse = fn;
|
|
262
266
|
}
|
|
263
267
|
async fetchText(urlOrOptions, options) {
|
|
264
|
-
let _options = { ...options };
|
|
268
|
+
let _options = { method: "GET", ...options };
|
|
265
269
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
266
270
|
_options.url = urlOrOptions;
|
|
267
271
|
}
|
|
268
272
|
if (typeof urlOrOptions === "object") {
|
|
269
273
|
_options = { ...urlOrOptions, ..._options };
|
|
270
274
|
}
|
|
275
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
276
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
277
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
278
|
+
}
|
|
271
279
|
const res = await adapter({
|
|
272
|
-
method: "GET",
|
|
273
280
|
..._options,
|
|
274
|
-
headers
|
|
275
|
-
...this.headers,
|
|
276
|
-
..._options?.headers || {}
|
|
277
|
-
}
|
|
281
|
+
headers
|
|
278
282
|
});
|
|
279
283
|
if (res && !res.code) {
|
|
280
284
|
return {
|
package/dist/query-shop.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -201,6 +201,10 @@ class Query {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const headers2 = req.headers || {};
|
|
205
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
206
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
207
|
+
}
|
|
204
208
|
} catch (e) {
|
|
205
209
|
console.error("request beforeFn error", e, req);
|
|
206
210
|
return wrapperError({
|
|
@@ -261,20 +265,20 @@ class Query {
|
|
|
261
265
|
this.afterResponse = fn;
|
|
262
266
|
}
|
|
263
267
|
async fetchText(urlOrOptions, options) {
|
|
264
|
-
let _options = { ...options };
|
|
268
|
+
let _options = { method: "GET", ...options };
|
|
265
269
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
266
270
|
_options.url = urlOrOptions;
|
|
267
271
|
}
|
|
268
272
|
if (typeof urlOrOptions === "object") {
|
|
269
273
|
_options = { ...urlOrOptions, ..._options };
|
|
270
274
|
}
|
|
275
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
276
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
277
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
278
|
+
}
|
|
271
279
|
const res = await adapter({
|
|
272
|
-
method: "GET",
|
|
273
280
|
..._options,
|
|
274
|
-
headers
|
|
275
|
-
...this.headers,
|
|
276
|
-
..._options?.headers || {}
|
|
277
|
-
}
|
|
281
|
+
headers
|
|
278
282
|
});
|
|
279
283
|
if (res && !res.code) {
|
|
280
284
|
return {
|
|
@@ -286,7 +290,7 @@ class Query {
|
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
// node_modules/.pnpm/@kevisual+router@0.
|
|
293
|
+
// node_modules/.pnpm/@kevisual+router@0.1.1/node_modules/@kevisual/router/dist/router-define.js
|
|
290
294
|
class Chain {
|
|
291
295
|
object;
|
|
292
296
|
app;
|
|
@@ -435,7 +439,7 @@ var shopDefine = QueryUtil.create({
|
|
|
435
439
|
}
|
|
436
440
|
});
|
|
437
441
|
|
|
438
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
442
|
+
// node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query.js
|
|
439
443
|
class BaseQuery {
|
|
440
444
|
query;
|
|
441
445
|
queryDefine;
|
package/dist/store-mark.js
CHANGED
|
@@ -204,6 +204,10 @@ class Query {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
+
const headers2 = req.headers || {};
|
|
208
|
+
if (options?.token && !headers2["Authorization"]) {
|
|
209
|
+
headers2["Authorization"] = `Bearer ${options.token}`;
|
|
210
|
+
}
|
|
207
211
|
} catch (e) {
|
|
208
212
|
console.error("request beforeFn error", e, req);
|
|
209
213
|
return wrapperError({
|
|
@@ -264,20 +268,20 @@ class Query {
|
|
|
264
268
|
this.afterResponse = fn;
|
|
265
269
|
}
|
|
266
270
|
async fetchText(urlOrOptions, options) {
|
|
267
|
-
let _options = { ...options };
|
|
271
|
+
let _options = { method: "GET", ...options };
|
|
268
272
|
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
269
273
|
_options.url = urlOrOptions;
|
|
270
274
|
}
|
|
271
275
|
if (typeof urlOrOptions === "object") {
|
|
272
276
|
_options = { ...urlOrOptions, ..._options };
|
|
273
277
|
}
|
|
278
|
+
const headers = { ...this.headers, ..._options.headers };
|
|
279
|
+
if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
|
|
280
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
281
|
+
}
|
|
274
282
|
const res = await adapter({
|
|
275
|
-
method: "GET",
|
|
276
283
|
..._options,
|
|
277
|
-
headers
|
|
278
|
-
...this.headers,
|
|
279
|
-
..._options?.headers || {}
|
|
280
|
-
}
|
|
284
|
+
headers
|
|
281
285
|
});
|
|
282
286
|
if (res && !res.code) {
|
|
283
287
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "mod.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"packageManager": "pnpm@10.
|
|
21
|
+
"packageManager": "pnpm@10.32.1",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@kevisual/cache": "^0.0.5",
|
|
25
25
|
"@kevisual/code-builder": "^0.0.6",
|
|
26
|
-
"@kevisual/query": "^0.0.
|
|
27
|
-
"@kevisual/remote-app": "^0.0.
|
|
28
|
-
"@kevisual/router": "^0.
|
|
26
|
+
"@kevisual/query": "^0.0.53",
|
|
27
|
+
"@kevisual/remote-app": "^0.0.6",
|
|
28
|
+
"@kevisual/router": "^0.1.1",
|
|
29
29
|
"@kevisual/types": "^0.0.12",
|
|
30
30
|
"@kevisual/use-config": "^1.0.30",
|
|
31
31
|
"@types/bun": "^1.3.10",
|
|
32
|
-
"@types/node": "^25.
|
|
32
|
+
"@types/node": "^25.4.0",
|
|
33
33
|
"@types/spark-md5": "^3.0.5",
|
|
34
34
|
"dotenv": "^17.3.1",
|
|
35
35
|
"fast-glob": "^3.3.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@kevisual/context": "^0.0.8",
|
|
40
|
-
"@kevisual/js-filter": "^0.0.
|
|
40
|
+
"@kevisual/js-filter": "^0.0.6",
|
|
41
41
|
"@kevisual/load": "^0.0.6",
|
|
42
42
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
43
43
|
"es-toolkit": "^1.45.1",
|
|
@@ -26,6 +26,10 @@ export class QueryResources {
|
|
|
26
26
|
setUsername(username: string) {
|
|
27
27
|
this.prefix = `/${username}/resources/`;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 设置prefix,类似 /{username}/resources/;
|
|
31
|
+
* @param prefix
|
|
32
|
+
*/
|
|
29
33
|
setPrefix(prefix: string) {
|
|
30
34
|
this.prefix = prefix;
|
|
31
35
|
}
|
|
@@ -55,19 +59,25 @@ export class QueryResources {
|
|
|
55
59
|
headers: this.header(opts?.headers),
|
|
56
60
|
});
|
|
57
61
|
}
|
|
62
|
+
getUrl(prefix: string): string {
|
|
63
|
+
if (prefix.startsWith('http')) {
|
|
64
|
+
return prefix;
|
|
65
|
+
}
|
|
66
|
+
return `${this.prefix}${prefix}`;
|
|
67
|
+
}
|
|
58
68
|
async getList(prefix: string, data?: { recursive?: boolean }, opts?: DataOpts): Promise<Result<any[]>> {
|
|
59
69
|
return this.get(data, {
|
|
60
|
-
url:
|
|
70
|
+
url: this.getUrl(prefix),
|
|
61
71
|
body: data,
|
|
62
72
|
...opts,
|
|
63
73
|
});
|
|
64
74
|
}
|
|
65
75
|
async fetchFile(filepath: string, opts?: DataOpts): Promise<Result<any>> {
|
|
66
|
-
const url =
|
|
76
|
+
const url = this.getUrl(filepath);
|
|
67
77
|
return this.get({}, { url, method: 'GET', ...opts, headers: this.header(opts?.headers, false), isText: true });
|
|
68
78
|
}
|
|
69
79
|
async uploadFile(filepath: string, content: string | Blob, opts?: DataOpts & { chunkSize?: number, maxSize?: number }): Promise<Result<any>> {
|
|
70
|
-
const pathname =
|
|
80
|
+
const pathname = this.getUrl(filepath);
|
|
71
81
|
const filename = path.basename(pathname);
|
|
72
82
|
const type = getContentType(filename);
|
|
73
83
|
const url = new URL(pathname, window.location.origin);
|
|
@@ -110,12 +120,12 @@ export class QueryResources {
|
|
|
110
120
|
return res;
|
|
111
121
|
}
|
|
112
122
|
async uploadChunkedFile(filepath: string, file: Blob, hash: string, opts?: DataOpts & { chunkSize?: number }): Promise<Result<any>> {
|
|
113
|
-
const pathname =
|
|
123
|
+
const pathname = this.getUrl(filepath);
|
|
114
124
|
const filename = path.basename(pathname);
|
|
115
125
|
const url = new URL(pathname, window.location.origin);
|
|
116
126
|
url.searchParams.set('hash', hash);
|
|
117
127
|
url.searchParams.set('chunk', '1');
|
|
118
|
-
console.log(`url,`, url, hash);
|
|
128
|
+
// console.log(`url,`, url, hash);
|
|
119
129
|
// 预留 eventSource 支持(暂不处理)
|
|
120
130
|
// const createEventSource = opts?.createEventSource;
|
|
121
131
|
const { chunkSize: _chunkSize, ...restOpts } = opts || {};
|
|
@@ -166,9 +176,20 @@ export class QueryResources {
|
|
|
166
176
|
this.onProcess?.({ type: 'uploadFinish', filename, size: file.size, process: 100 });
|
|
167
177
|
return { code: 200, message: '上传成功' };
|
|
168
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* 移除 prefix,获取相对路径
|
|
181
|
+
* @param filepath
|
|
182
|
+
* @returns
|
|
183
|
+
*/
|
|
184
|
+
getRelativePath(filepath: string): string {
|
|
185
|
+
if (filepath.startsWith(this.prefix)) {
|
|
186
|
+
return filepath.slice(this.prefix.length);
|
|
187
|
+
}
|
|
188
|
+
return filepath;
|
|
189
|
+
}
|
|
169
190
|
|
|
170
191
|
async getStat(filepath: string, opts?: DataOpts): Promise<Result<Stat>> {
|
|
171
|
-
const url =
|
|
192
|
+
const url = this.getUrl(filepath);
|
|
172
193
|
return adapter({
|
|
173
194
|
url,
|
|
174
195
|
params: {
|
|
@@ -192,8 +213,8 @@ export class QueryResources {
|
|
|
192
213
|
return this.uploadFile(filepath, '文件夹占位,其他文件不存在,文件夹不存在,如果有其他文件夹,删除当前文件夹占位文件即可', opts);
|
|
193
214
|
}
|
|
194
215
|
async rename(oldpath: string, newpath: string, opts?: DataOpts): Promise<Result<any>> {
|
|
195
|
-
const pathname =
|
|
196
|
-
const newName =
|
|
216
|
+
const pathname = this.getUrl(oldpath);
|
|
217
|
+
const newName = this.getUrl(newpath);
|
|
197
218
|
const params = {
|
|
198
219
|
newName: newName,
|
|
199
220
|
};
|
|
@@ -206,7 +227,7 @@ export class QueryResources {
|
|
|
206
227
|
});
|
|
207
228
|
}
|
|
208
229
|
async deleteFile(filepath: string, opts?: DataOpts): Promise<Result<any>> {
|
|
209
|
-
const url =
|
|
230
|
+
const url = this.getUrl(filepath);
|
|
210
231
|
return adapter({
|
|
211
232
|
url,
|
|
212
233
|
method: 'DELETE' as any,
|