@kevisual/api 0.0.61 → 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.d.ts +5 -2
- package/dist/query-login-node.js +243 -21
- package/dist/query-login.d.ts +5 -2
- package/dist/query-login.js +248 -25
- package/dist/query-mark.js +11 -7
- package/dist/query-proxy.d.ts +20 -0
- package/dist/query-proxy.js +270 -31
- 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 +11 -7
- package/package.json +9 -9
- package/query/query-resources/index.ts +15 -0
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/@kevisual/query/dist/query-browser.js
|
|
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/@kevisual/router/dist/router-browser.js
|
|
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;
|
|
@@ -14655,7 +14659,7 @@ class Route {
|
|
|
14655
14659
|
if (opts) {
|
|
14656
14660
|
this.id = opts.id || randomId(12, "rand-");
|
|
14657
14661
|
if (!opts.id && opts.idUsePath) {
|
|
14658
|
-
const delimiter = opts.delimiter ?? "
|
|
14662
|
+
const delimiter = opts.delimiter ?? "$$";
|
|
14659
14663
|
this.id = path + delimiter + key;
|
|
14660
14664
|
}
|
|
14661
14665
|
this.run = opts.run;
|
|
@@ -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;
|
|
@@ -14778,6 +14785,7 @@ class QueryRouter {
|
|
|
14778
14785
|
const maxNextRoute = this.maxNextRoute;
|
|
14779
14786
|
ctx = ctx || {};
|
|
14780
14787
|
ctx.currentPath = path;
|
|
14788
|
+
ctx.currentId = route?.id;
|
|
14781
14789
|
ctx.currentKey = key;
|
|
14782
14790
|
ctx.currentRoute = route;
|
|
14783
14791
|
ctx.index = (ctx.index || 0) + 1;
|
|
@@ -14791,7 +14799,7 @@ class QueryRouter {
|
|
|
14791
14799
|
ctx.code = 500;
|
|
14792
14800
|
ctx.message = "Too many nextRoute";
|
|
14793
14801
|
ctx.body = null;
|
|
14794
|
-
return;
|
|
14802
|
+
return ctx;
|
|
14795
14803
|
}
|
|
14796
14804
|
if (route && route.middleware && route.middleware.length > 0) {
|
|
14797
14805
|
const errorMiddleware = [];
|
|
@@ -14866,7 +14874,9 @@ class QueryRouter {
|
|
|
14866
14874
|
}
|
|
14867
14875
|
return ctx;
|
|
14868
14876
|
}
|
|
14869
|
-
if (ctx.end) {
|
|
14877
|
+
if (ctx.end) {
|
|
14878
|
+
return ctx;
|
|
14879
|
+
}
|
|
14870
14880
|
}
|
|
14871
14881
|
}
|
|
14872
14882
|
}
|
|
@@ -15060,7 +15070,7 @@ class QueryRouter {
|
|
|
15060
15070
|
description: "列出当前应用下的所有的路由信息",
|
|
15061
15071
|
middleware: opts?.middleware || [],
|
|
15062
15072
|
run: async (ctx) => {
|
|
15063
|
-
const tokenUser = ctx.state
|
|
15073
|
+
const tokenUser = ctx.state;
|
|
15064
15074
|
let isUser = !!tokenUser;
|
|
15065
15075
|
const list = this.getList(opts?.filter).filter((item) => {
|
|
15066
15076
|
if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
|
|
@@ -15095,7 +15105,10 @@ class QueryRouterServer extends QueryRouter {
|
|
|
15095
15105
|
handle;
|
|
15096
15106
|
constructor(opts) {
|
|
15097
15107
|
super();
|
|
15098
|
-
|
|
15108
|
+
const initHandle = opts?.initHandle ?? true;
|
|
15109
|
+
if (initHandle || opts?.handleFn) {
|
|
15110
|
+
this.handle = this.getHandle(this, opts?.handleFn, opts?.context);
|
|
15111
|
+
}
|
|
15099
15112
|
this.setContext({ needSerialize: false, ...opts?.context });
|
|
15100
15113
|
if (opts?.appId) {
|
|
15101
15114
|
this.appId = opts.appId;
|
|
@@ -15126,15 +15139,8 @@ class QueryRouterServer extends QueryRouter {
|
|
|
15126
15139
|
}
|
|
15127
15140
|
return new Route(path, key, opts);
|
|
15128
15141
|
}
|
|
15129
|
-
prompt(
|
|
15130
|
-
|
|
15131
|
-
let description = "";
|
|
15132
|
-
if (typeof desc === "string") {
|
|
15133
|
-
description = desc;
|
|
15134
|
-
} else if (typeof desc === "function") {
|
|
15135
|
-
description = desc() || "";
|
|
15136
|
-
}
|
|
15137
|
-
return new Route("", "", { description });
|
|
15142
|
+
prompt(description) {
|
|
15143
|
+
return new Route(undefined, undefined, { description });
|
|
15138
15144
|
}
|
|
15139
15145
|
async run(msg, ctx) {
|
|
15140
15146
|
const handle = this.handle;
|
|
@@ -15143,9 +15149,13 @@ class QueryRouterServer extends QueryRouter {
|
|
|
15143
15149
|
}
|
|
15144
15150
|
return super.run(msg, ctx);
|
|
15145
15151
|
}
|
|
15152
|
+
async runAction(api2, payload, ctx) {
|
|
15153
|
+
const { path, key, id } = api2;
|
|
15154
|
+
return this.run({ path, key, id, payload }, ctx);
|
|
15155
|
+
}
|
|
15146
15156
|
}
|
|
15147
15157
|
|
|
15148
|
-
// 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
|
|
15149
15159
|
class Lexer {
|
|
15150
15160
|
constructor(input) {
|
|
15151
15161
|
this.pos = 0;
|
|
@@ -15491,7 +15501,221 @@ function filter(data, query) {
|
|
|
15491
15501
|
// node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
|
|
15492
15502
|
var import__2 = __toESM(require_eventemitter32(), 1);
|
|
15493
15503
|
|
|
15494
|
-
// node_modules/.pnpm/es-toolkit@1.
|
|
15504
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
|
|
15505
|
+
function isPrimitive(value) {
|
|
15506
|
+
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
15507
|
+
}
|
|
15508
|
+
|
|
15509
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
|
|
15510
|
+
function isTypedArray(x) {
|
|
15511
|
+
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
15512
|
+
}
|
|
15513
|
+
|
|
15514
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
|
|
15515
|
+
function getSymbols(object2) {
|
|
15516
|
+
return Object.getOwnPropertySymbols(object2).filter((symbol2) => Object.prototype.propertyIsEnumerable.call(object2, symbol2));
|
|
15517
|
+
}
|
|
15518
|
+
|
|
15519
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
|
|
15520
|
+
function getTag(value) {
|
|
15521
|
+
if (value == null) {
|
|
15522
|
+
return value === undefined ? "[object Undefined]" : "[object Null]";
|
|
15523
|
+
}
|
|
15524
|
+
return Object.prototype.toString.call(value);
|
|
15525
|
+
}
|
|
15526
|
+
|
|
15527
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/tags.mjs
|
|
15528
|
+
var regexpTag = "[object RegExp]";
|
|
15529
|
+
var stringTag = "[object String]";
|
|
15530
|
+
var numberTag = "[object Number]";
|
|
15531
|
+
var booleanTag = "[object Boolean]";
|
|
15532
|
+
var argumentsTag = "[object Arguments]";
|
|
15533
|
+
var symbolTag = "[object Symbol]";
|
|
15534
|
+
var dateTag = "[object Date]";
|
|
15535
|
+
var mapTag = "[object Map]";
|
|
15536
|
+
var setTag = "[object Set]";
|
|
15537
|
+
var arrayTag = "[object Array]";
|
|
15538
|
+
var arrayBufferTag = "[object ArrayBuffer]";
|
|
15539
|
+
var objectTag = "[object Object]";
|
|
15540
|
+
var dataViewTag = "[object DataView]";
|
|
15541
|
+
var uint8ArrayTag = "[object Uint8Array]";
|
|
15542
|
+
var uint8ClampedArrayTag = "[object Uint8ClampedArray]";
|
|
15543
|
+
var uint16ArrayTag = "[object Uint16Array]";
|
|
15544
|
+
var uint32ArrayTag = "[object Uint32Array]";
|
|
15545
|
+
var int8ArrayTag = "[object Int8Array]";
|
|
15546
|
+
var int16ArrayTag = "[object Int16Array]";
|
|
15547
|
+
var int32ArrayTag = "[object Int32Array]";
|
|
15548
|
+
var float32ArrayTag = "[object Float32Array]";
|
|
15549
|
+
var float64ArrayTag = "[object Float64Array]";
|
|
15550
|
+
|
|
15551
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs
|
|
15552
|
+
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map, cloneValue = undefined) {
|
|
15553
|
+
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
|
|
15554
|
+
if (cloned !== undefined) {
|
|
15555
|
+
return cloned;
|
|
15556
|
+
}
|
|
15557
|
+
if (isPrimitive(valueToClone)) {
|
|
15558
|
+
return valueToClone;
|
|
15559
|
+
}
|
|
15560
|
+
if (stack.has(valueToClone)) {
|
|
15561
|
+
return stack.get(valueToClone);
|
|
15562
|
+
}
|
|
15563
|
+
if (Array.isArray(valueToClone)) {
|
|
15564
|
+
const result = new Array(valueToClone.length);
|
|
15565
|
+
stack.set(valueToClone, result);
|
|
15566
|
+
for (let i = 0;i < valueToClone.length; i++) {
|
|
15567
|
+
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
15568
|
+
}
|
|
15569
|
+
if (Object.hasOwn(valueToClone, "index")) {
|
|
15570
|
+
result.index = valueToClone.index;
|
|
15571
|
+
}
|
|
15572
|
+
if (Object.hasOwn(valueToClone, "input")) {
|
|
15573
|
+
result.input = valueToClone.input;
|
|
15574
|
+
}
|
|
15575
|
+
return result;
|
|
15576
|
+
}
|
|
15577
|
+
if (valueToClone instanceof Date) {
|
|
15578
|
+
return new Date(valueToClone.getTime());
|
|
15579
|
+
}
|
|
15580
|
+
if (valueToClone instanceof RegExp) {
|
|
15581
|
+
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
|
15582
|
+
result.lastIndex = valueToClone.lastIndex;
|
|
15583
|
+
return result;
|
|
15584
|
+
}
|
|
15585
|
+
if (valueToClone instanceof Map) {
|
|
15586
|
+
const result = new Map;
|
|
15587
|
+
stack.set(valueToClone, result);
|
|
15588
|
+
for (const [key, value] of valueToClone) {
|
|
15589
|
+
result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
|
|
15590
|
+
}
|
|
15591
|
+
return result;
|
|
15592
|
+
}
|
|
15593
|
+
if (valueToClone instanceof Set) {
|
|
15594
|
+
const result = new Set;
|
|
15595
|
+
stack.set(valueToClone, result);
|
|
15596
|
+
for (const value of valueToClone) {
|
|
15597
|
+
result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
|
|
15598
|
+
}
|
|
15599
|
+
return result;
|
|
15600
|
+
}
|
|
15601
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(valueToClone)) {
|
|
15602
|
+
return valueToClone.subarray();
|
|
15603
|
+
}
|
|
15604
|
+
if (isTypedArray(valueToClone)) {
|
|
15605
|
+
const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length);
|
|
15606
|
+
stack.set(valueToClone, result);
|
|
15607
|
+
for (let i = 0;i < valueToClone.length; i++) {
|
|
15608
|
+
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
15609
|
+
}
|
|
15610
|
+
return result;
|
|
15611
|
+
}
|
|
15612
|
+
if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) {
|
|
15613
|
+
return valueToClone.slice(0);
|
|
15614
|
+
}
|
|
15615
|
+
if (valueToClone instanceof DataView) {
|
|
15616
|
+
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
|
15617
|
+
stack.set(valueToClone, result);
|
|
15618
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15619
|
+
return result;
|
|
15620
|
+
}
|
|
15621
|
+
if (typeof File !== "undefined" && valueToClone instanceof File) {
|
|
15622
|
+
const result = new File([valueToClone], valueToClone.name, {
|
|
15623
|
+
type: valueToClone.type
|
|
15624
|
+
});
|
|
15625
|
+
stack.set(valueToClone, result);
|
|
15626
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15627
|
+
return result;
|
|
15628
|
+
}
|
|
15629
|
+
if (typeof Blob !== "undefined" && valueToClone instanceof Blob) {
|
|
15630
|
+
const result = new Blob([valueToClone], { type: valueToClone.type });
|
|
15631
|
+
stack.set(valueToClone, result);
|
|
15632
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15633
|
+
return result;
|
|
15634
|
+
}
|
|
15635
|
+
if (valueToClone instanceof Error) {
|
|
15636
|
+
const result = structuredClone(valueToClone);
|
|
15637
|
+
stack.set(valueToClone, result);
|
|
15638
|
+
result.message = valueToClone.message;
|
|
15639
|
+
result.name = valueToClone.name;
|
|
15640
|
+
result.stack = valueToClone.stack;
|
|
15641
|
+
result.cause = valueToClone.cause;
|
|
15642
|
+
result.constructor = valueToClone.constructor;
|
|
15643
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15644
|
+
return result;
|
|
15645
|
+
}
|
|
15646
|
+
if (valueToClone instanceof Boolean) {
|
|
15647
|
+
const result = new Boolean(valueToClone.valueOf());
|
|
15648
|
+
stack.set(valueToClone, result);
|
|
15649
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15650
|
+
return result;
|
|
15651
|
+
}
|
|
15652
|
+
if (valueToClone instanceof Number) {
|
|
15653
|
+
const result = new Number(valueToClone.valueOf());
|
|
15654
|
+
stack.set(valueToClone, result);
|
|
15655
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15656
|
+
return result;
|
|
15657
|
+
}
|
|
15658
|
+
if (valueToClone instanceof String) {
|
|
15659
|
+
const result = new String(valueToClone.valueOf());
|
|
15660
|
+
stack.set(valueToClone, result);
|
|
15661
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15662
|
+
return result;
|
|
15663
|
+
}
|
|
15664
|
+
if (typeof valueToClone === "object" && isCloneableObject(valueToClone)) {
|
|
15665
|
+
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
|
15666
|
+
stack.set(valueToClone, result);
|
|
15667
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15668
|
+
return result;
|
|
15669
|
+
}
|
|
15670
|
+
return valueToClone;
|
|
15671
|
+
}
|
|
15672
|
+
function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
|
|
15673
|
+
const keys = [...Object.keys(source), ...getSymbols(source)];
|
|
15674
|
+
for (let i = 0;i < keys.length; i++) {
|
|
15675
|
+
const key = keys[i];
|
|
15676
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
15677
|
+
if (descriptor == null || descriptor.writable) {
|
|
15678
|
+
target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
|
15679
|
+
}
|
|
15680
|
+
}
|
|
15681
|
+
}
|
|
15682
|
+
function isCloneableObject(object2) {
|
|
15683
|
+
switch (getTag(object2)) {
|
|
15684
|
+
case argumentsTag:
|
|
15685
|
+
case arrayTag:
|
|
15686
|
+
case arrayBufferTag:
|
|
15687
|
+
case dataViewTag:
|
|
15688
|
+
case booleanTag:
|
|
15689
|
+
case dateTag:
|
|
15690
|
+
case float32ArrayTag:
|
|
15691
|
+
case float64ArrayTag:
|
|
15692
|
+
case int8ArrayTag:
|
|
15693
|
+
case int16ArrayTag:
|
|
15694
|
+
case int32ArrayTag:
|
|
15695
|
+
case mapTag:
|
|
15696
|
+
case numberTag:
|
|
15697
|
+
case objectTag:
|
|
15698
|
+
case regexpTag:
|
|
15699
|
+
case setTag:
|
|
15700
|
+
case stringTag:
|
|
15701
|
+
case symbolTag:
|
|
15702
|
+
case uint8ArrayTag:
|
|
15703
|
+
case uint8ClampedArrayTag:
|
|
15704
|
+
case uint16ArrayTag:
|
|
15705
|
+
case uint32ArrayTag: {
|
|
15706
|
+
return true;
|
|
15707
|
+
}
|
|
15708
|
+
default: {
|
|
15709
|
+
return false;
|
|
15710
|
+
}
|
|
15711
|
+
}
|
|
15712
|
+
}
|
|
15713
|
+
|
|
15714
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/cloneDeep.mjs
|
|
15715
|
+
function cloneDeep(obj) {
|
|
15716
|
+
return cloneDeepWithImpl(obj, undefined, obj, new Map, undefined);
|
|
15717
|
+
}
|
|
15718
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isBrowser.mjs
|
|
15495
15719
|
function isBrowser() {
|
|
15496
15720
|
return typeof window !== "undefined" && window?.document != null;
|
|
15497
15721
|
}
|
|
@@ -15502,6 +15726,9 @@ var initApi = async (opts) => {
|
|
|
15502
15726
|
const token = opts?.token;
|
|
15503
15727
|
const query = item?.api?.query || new Query({ url: item?.api?.url || "/api/router" });
|
|
15504
15728
|
const res = await query.post({ path: "router", key: "list", token });
|
|
15729
|
+
if (item) {
|
|
15730
|
+
item.routerStatus = res?.code === 200 ? "active" : "error";
|
|
15731
|
+
}
|
|
15505
15732
|
if (res.code !== 200) {
|
|
15506
15733
|
return {
|
|
15507
15734
|
code: res.code,
|
|
@@ -15548,7 +15775,7 @@ var initApi = async (opts) => {
|
|
|
15548
15775
|
|
|
15549
15776
|
// node_modules/.pnpm/fuse.js@7.1.0/node_modules/fuse.js/dist/fuse.mjs
|
|
15550
15777
|
function isArray(value) {
|
|
15551
|
-
return !Array.isArray ?
|
|
15778
|
+
return !Array.isArray ? getTag2(value) === "[object Array]" : Array.isArray(value);
|
|
15552
15779
|
}
|
|
15553
15780
|
var INFINITY = 1 / 0;
|
|
15554
15781
|
function baseToString(value) {
|
|
@@ -15568,7 +15795,7 @@ function isNumber(value) {
|
|
|
15568
15795
|
return typeof value === "number";
|
|
15569
15796
|
}
|
|
15570
15797
|
function isBoolean(value) {
|
|
15571
|
-
return value === true || value === false || isObjectLike(value) &&
|
|
15798
|
+
return value === true || value === false || isObjectLike(value) && getTag2(value) == "[object Boolean]";
|
|
15572
15799
|
}
|
|
15573
15800
|
function isObject2(value) {
|
|
15574
15801
|
return typeof value === "object";
|
|
@@ -15582,7 +15809,7 @@ function isDefined(value) {
|
|
|
15582
15809
|
function isBlank(value) {
|
|
15583
15810
|
return !value.trim().length;
|
|
15584
15811
|
}
|
|
15585
|
-
function
|
|
15812
|
+
function getTag2(value) {
|
|
15586
15813
|
return value == null ? value === undefined ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
|
|
15587
15814
|
}
|
|
15588
15815
|
var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
|
|
@@ -16843,7 +17070,7 @@ Fuse.config = Config;
|
|
|
16843
17070
|
// query/query-proxy/proxy.ts
|
|
16844
17071
|
var RouteTypeList = ["api", "context", "worker", "page"];
|
|
16845
17072
|
var pickRouterViewData = (item) => {
|
|
16846
|
-
const { action, response, _id, ...rest } = item;
|
|
17073
|
+
const { action, response, _id, ...rest } = cloneDeep(item);
|
|
16847
17074
|
if (rest.type === "api") {
|
|
16848
17075
|
if (rest.api) {
|
|
16849
17076
|
delete rest.api.query;
|
|
@@ -16859,6 +17086,7 @@ var pickRouterViewData = (item) => {
|
|
|
16859
17086
|
delete rest.context.router;
|
|
16860
17087
|
}
|
|
16861
17088
|
}
|
|
17089
|
+
delete rest.routerStatus;
|
|
16862
17090
|
return rest;
|
|
16863
17091
|
};
|
|
16864
17092
|
|
|
@@ -16894,6 +17122,7 @@ class QueryProxy {
|
|
|
16894
17122
|
});
|
|
16895
17123
|
}
|
|
16896
17124
|
initRouterView(item) {
|
|
17125
|
+
item.routerStatus = "loading";
|
|
16897
17126
|
if (item.type === "api" && item.api?.url) {
|
|
16898
17127
|
const url2 = item.api.url;
|
|
16899
17128
|
if (item?.api?.query)
|
|
@@ -16983,6 +17212,9 @@ class QueryProxy {
|
|
|
16983
17212
|
async initContext(item) {
|
|
16984
17213
|
const context = globalThis["context"] || {};
|
|
16985
17214
|
const router = item?.context?.router || context[item?.context?.key];
|
|
17215
|
+
if (item) {
|
|
17216
|
+
item.routerStatus = router ? "active" : "error";
|
|
17217
|
+
}
|
|
16986
17218
|
if (!router) {
|
|
16987
17219
|
console.warn(`未发现Context router ${item?.context?.key}`);
|
|
16988
17220
|
return;
|
|
@@ -17044,6 +17276,9 @@ class QueryProxy {
|
|
|
17044
17276
|
}
|
|
17045
17277
|
const viewItem = item.worker;
|
|
17046
17278
|
const worker = viewItem?.worker;
|
|
17279
|
+
if (item) {
|
|
17280
|
+
item.routerStatus = worker ? "active" : "error";
|
|
17281
|
+
}
|
|
17047
17282
|
if (!worker) {
|
|
17048
17283
|
console.warn("Worker not initialized");
|
|
17049
17284
|
return;
|
|
@@ -17111,11 +17346,15 @@ class QueryProxy {
|
|
|
17111
17346
|
const url2 = item.page.url;
|
|
17112
17347
|
try {
|
|
17113
17348
|
if (typeof window !== "undefined") {
|
|
17114
|
-
await import(url2)
|
|
17115
|
-
|
|
17116
|
-
|
|
17349
|
+
await import(url2);
|
|
17350
|
+
if (item) {
|
|
17351
|
+
item.routerStatus = "active";
|
|
17352
|
+
}
|
|
17117
17353
|
}
|
|
17118
17354
|
} catch (e) {
|
|
17355
|
+
if (item) {
|
|
17356
|
+
item.routerStatus = "error";
|
|
17357
|
+
}
|
|
17119
17358
|
console.warn("引入Page脚本失败:", url2, e);
|
|
17120
17359
|
return;
|
|
17121
17360
|
}
|
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/@kevisual/query/dist/query-browser.js
|
|
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/@kevisual/query/dist/query-browser.js
|
|
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 {
|