@kevisual/api 0.0.62 → 0.0.63
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 +10 -0
- package/dist/query-resources.js +7 -1
- 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 +15 -0
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,6 +14,10 @@ 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>;
|
|
@@ -28,6 +32,12 @@ declare class QueryResources {
|
|
|
28
32
|
uploadChunkedFile(filepath: string, file: Blob, hash: string, opts?: DataOpts & {
|
|
29
33
|
chunkSize?: number;
|
|
30
34
|
}): Promise<Result<any>>;
|
|
35
|
+
/**
|
|
36
|
+
* 移除 prefix,获取相对路径
|
|
37
|
+
* @param filepath
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
getRelativePath(filepath: string): string;
|
|
31
41
|
getStat(filepath: string, opts?: DataOpts): Promise<Result<Stat>>;
|
|
32
42
|
/**
|
|
33
43
|
* @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;
|
|
@@ -1162,6 +1162,12 @@ class QueryResources {
|
|
|
1162
1162
|
this.onProcess?.({ type: "uploadFinish", filename, size: file.size, process: 100 });
|
|
1163
1163
|
return { code: 200, message: "上传成功" };
|
|
1164
1164
|
}
|
|
1165
|
+
getRelativePath(filepath) {
|
|
1166
|
+
if (filepath.startsWith(this.prefix)) {
|
|
1167
|
+
return filepath.slice(this.prefix.length);
|
|
1168
|
+
}
|
|
1169
|
+
return filepath;
|
|
1170
|
+
}
|
|
1165
1171
|
async getStat(filepath, opts) {
|
|
1166
1172
|
const url = `${this.prefix}${filepath}`;
|
|
1167
1173
|
return adapter({
|
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.63",
|
|
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
|
}
|
|
@@ -166,6 +170,17 @@ export class QueryResources {
|
|
|
166
170
|
this.onProcess?.({ type: 'uploadFinish', filename, size: file.size, process: 100 });
|
|
167
171
|
return { code: 200, message: '上传成功' };
|
|
168
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* 移除 prefix,获取相对路径
|
|
175
|
+
* @param filepath
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
getRelativePath(filepath: string): string {
|
|
179
|
+
if (filepath.startsWith(this.prefix)) {
|
|
180
|
+
return filepath.slice(this.prefix.length);
|
|
181
|
+
}
|
|
182
|
+
return filepath;
|
|
183
|
+
}
|
|
169
184
|
|
|
170
185
|
async getStat(filepath: string, opts?: DataOpts): Promise<Result<Stat>> {
|
|
171
186
|
const url = `${this.prefix}${filepath}`;
|