@isdk/ai-tool 0.0.2 → 0.0.4
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/{chunk-PKECBABP.mjs → chunk-ZXBTGYVX.mjs} +114 -127
- package/dist/funcs.js +112 -126
- package/dist/funcs.mjs +2 -2
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +114 -126
- package/dist/index.mjs +5 -2
- package/dist/test/util.js +1 -2
- package/dist/test/util.mjs +2 -3
- package/docs/classes/AbortError.md +11 -11
- package/docs/classes/AlreadyExistsError.md +11 -11
- package/docs/classes/BaseError.md +11 -11
- package/docs/classes/ClientTools.md +51 -51
- package/docs/classes/CommonError.md +11 -11
- package/docs/classes/EventClient.md +73 -73
- package/docs/classes/EventServer.md +71 -71
- package/docs/classes/EventToolFunc.md +41 -41
- package/docs/classes/FStringPromptTemplate.md +18 -18
- package/docs/classes/FewShotPromptTemplate.md +22 -22
- package/docs/classes/GolangPromptTemplate.md +18 -18
- package/docs/classes/HFEnvironment.md +9 -9
- package/docs/classes/HFInterpreter.md +17 -17
- package/docs/classes/HFTemplate.md +4 -4
- package/docs/classes/HfPromptTemplate.md +18 -18
- package/docs/classes/NotFoundError.md +11 -11
- package/docs/classes/NotImplementationError.md +11 -11
- package/docs/classes/PromptExampleSelector.md +8 -8
- package/docs/classes/PromptTemplate.md +17 -17
- package/docs/classes/ReadableStreamError.md +11 -11
- package/docs/classes/ResClientTools.md +57 -57
- package/docs/classes/ResServerTools.md +55 -55
- package/docs/classes/SSEChannel.md +15 -15
- package/docs/classes/ServerTools.md +48 -48
- package/docs/classes/ToolFunc.md +38 -38
- package/docs/enums/ErrorCode.md +19 -19
- package/docs/enums/XXHashAlgorithm.md +2 -2
- package/docs/interfaces/AIChatAssistantMessageParam.md +6 -6
- package/docs/interfaces/AIChatContentPartImage.md +2 -2
- package/docs/interfaces/AIChatContentPartText.md +2 -2
- package/docs/interfaces/AIChatMessageParamBase.md +1 -1
- package/docs/interfaces/AIChatMessageToolCall.md +3 -3
- package/docs/interfaces/AIChatSystemMessageParam.md +3 -3
- package/docs/interfaces/AIChatToolMessageParam.md +4 -4
- package/docs/interfaces/AIChatUserMessageParam.md +7 -7
- package/docs/interfaces/AIResult.md +4 -4
- package/docs/interfaces/AIStreamCallbacksAndOptions.md +6 -6
- package/docs/interfaces/AIStreamParser.md +1 -1
- package/docs/interfaces/AIStreamParserOptions.md +1 -1
- package/docs/interfaces/BaseFunc.md +7 -7
- package/docs/interfaces/BaseFuncItem.md +6 -6
- package/docs/interfaces/ClientFuncItem.md +10 -10
- package/docs/interfaces/DotenvExpandOptions.md +3 -3
- package/docs/interfaces/DotenvExpandOutput.md +2 -2
- package/docs/interfaces/EventClientFuncParams.md +4 -4
- package/docs/interfaces/EventServerFuncParams.md +5 -5
- package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
- package/docs/interfaces/FuncItem.md +7 -7
- package/docs/interfaces/FuncParam.md +5 -5
- package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
- package/docs/interfaces/PromptTemplateOptions.md +6 -6
- package/docs/interfaces/RemoteFuncItem.md +10 -10
- package/docs/interfaces/ResClientFuncParams.md +2 -2
- package/docs/interfaces/ResServerFuncParams.md +5 -5
- package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
- package/docs/interfaces/ServerFuncItem.md +11 -11
- package/docs/interfaces/ServerFuncParams.md +2 -2
- package/docs/modules.md +159 -109
- package/package.json +12 -13
- /package/dist/{chunk-EZFPVSGF.mjs → chunk-U5DDQYSF.mjs} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export,
|
|
3
3
|
__reExport
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U5DDQYSF.mjs";
|
|
5
5
|
|
|
6
6
|
// src/funcs/event.ts
|
|
7
7
|
import { EventEmitter } from "events-ex";
|
|
@@ -345,8 +345,7 @@ var ToolFunc = class _ToolFunc extends AdvancePropertyManager {
|
|
|
345
345
|
runSync(params) {
|
|
346
346
|
const isPosParams = this.params && Array.isArray(this.params);
|
|
347
347
|
if (Array.isArray(params)) {
|
|
348
|
-
if (isPosParams)
|
|
349
|
-
return this.func(...params);
|
|
348
|
+
if (isPosParams) return this.func(...params);
|
|
350
349
|
throwError2("the function is not support array params, the params must be object!", this.name);
|
|
351
350
|
}
|
|
352
351
|
if (isPosParams) {
|
|
@@ -554,22 +553,19 @@ var SSEChannel = class {
|
|
|
554
553
|
* @throws Will throw an error if the channel is closed.
|
|
555
554
|
*/
|
|
556
555
|
publish(data, eventName) {
|
|
557
|
-
if (!this.active)
|
|
558
|
-
throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
556
|
+
if (!this.active) throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
559
557
|
let output;
|
|
560
558
|
let id;
|
|
561
559
|
let _eventName = eventName;
|
|
562
560
|
if (!data && !eventName) {
|
|
563
|
-
if (!this.clients.size)
|
|
564
|
-
return;
|
|
561
|
+
if (!this.clients.size) return;
|
|
565
562
|
output = "data: \n\n";
|
|
566
563
|
} else {
|
|
567
564
|
id = this.nextID++;
|
|
568
565
|
if (typeof data === "object") {
|
|
569
566
|
if (data.event) {
|
|
570
567
|
_eventName = data.event;
|
|
571
|
-
if (data.data !== void 0)
|
|
572
|
-
data = JSON.stringify(data.data);
|
|
568
|
+
if (data.data !== void 0) data = JSON.stringify(data.data);
|
|
573
569
|
} else {
|
|
574
570
|
data = JSON.stringify(data);
|
|
575
571
|
}
|
|
@@ -596,8 +592,7 @@ var SSEChannel = class {
|
|
|
596
592
|
* @throws Will throw an error if the channel is closed.
|
|
597
593
|
*/
|
|
598
594
|
subscribe(req, res, events) {
|
|
599
|
-
if (!this.active)
|
|
600
|
-
throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
595
|
+
if (!this.active) throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
601
596
|
const c = { req, res, events };
|
|
602
597
|
const maxStreamDuration = this.options.maxStreamDuration;
|
|
603
598
|
let cacheControl = "max-age=0, stale-while-revalidate=0, stale-if-error=0, no-transform";
|
|
@@ -758,8 +753,7 @@ import { env as _env, pipeline as _pipeline, cos_sim as _cos_sim } from "@xenova
|
|
|
758
753
|
import { Cache as _Cache } from "secondary-cache";
|
|
759
754
|
function _lrucache({ key, value, options } = {}) {
|
|
760
755
|
if (key === void 0) {
|
|
761
|
-
if (options)
|
|
762
|
-
this.cache.setDefaultOptions(options);
|
|
756
|
+
if (options) this.cache.setDefaultOptions(options);
|
|
763
757
|
} else if (value === null) {
|
|
764
758
|
return this.cache.del(key);
|
|
765
759
|
} else if (value !== void 0) {
|
|
@@ -1012,8 +1006,7 @@ async function _splitSegments({ texts, model } = {}) {
|
|
|
1012
1006
|
}
|
|
1013
1007
|
}
|
|
1014
1008
|
}
|
|
1015
|
-
if (segment.length)
|
|
1016
|
-
segments2.push([...segment]);
|
|
1009
|
+
if (segment.length) segments2.push([...segment]);
|
|
1017
1010
|
return segments2;
|
|
1018
1011
|
}
|
|
1019
1012
|
var splitSegments = new ServerTools("splitSegments", {
|
|
@@ -1124,6 +1117,7 @@ __export(utils_exports, {
|
|
|
1124
1117
|
jsonFilterToWhere: () => jsonFilterToWhere,
|
|
1125
1118
|
loadFileFromPaths: () => loadFileFromPaths,
|
|
1126
1119
|
loadTextFromPaths: () => loadTextFromPaths,
|
|
1120
|
+
matchUrlProtocol: () => matchUrlProtocol,
|
|
1127
1121
|
mimeType: () => mimeType,
|
|
1128
1122
|
parseFString: () => parseFString,
|
|
1129
1123
|
parseJsJson: () => parseJsJson,
|
|
@@ -1620,8 +1614,7 @@ function tokenize(source, options = {}) {
|
|
|
1620
1614
|
while (predicate(src[cursorPosition])) {
|
|
1621
1615
|
if (src[cursorPosition] === "\\") {
|
|
1622
1616
|
++cursorPosition;
|
|
1623
|
-
if (cursorPosition >= src.length)
|
|
1624
|
-
throw new SyntaxError("Unexpected end of input");
|
|
1617
|
+
if (cursorPosition >= src.length) throw new SyntaxError("Unexpected end of input");
|
|
1625
1618
|
const escaped = src[cursorPosition++];
|
|
1626
1619
|
const unescaped = ESCAPE_CHARACTERS.get(escaped);
|
|
1627
1620
|
if (unescaped === void 0) {
|
|
@@ -1631,83 +1624,81 @@ function tokenize(source, options = {}) {
|
|
|
1631
1624
|
continue;
|
|
1632
1625
|
}
|
|
1633
1626
|
str += src[cursorPosition++];
|
|
1634
|
-
if (cursorPosition >= src.length)
|
|
1635
|
-
throw new SyntaxError("Unexpected end of input");
|
|
1627
|
+
if (cursorPosition >= src.length) throw new SyntaxError("Unexpected end of input");
|
|
1636
1628
|
}
|
|
1637
1629
|
return str;
|
|
1638
1630
|
};
|
|
1639
|
-
main:
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
continue;
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
consumeWhile((char2) => /\s/.test(char2));
|
|
1654
|
-
const char = src[cursorPosition];
|
|
1655
|
-
if (char === "-" || char === "+") {
|
|
1656
|
-
const lastTokenType2 = tokens.at(-1)?.type;
|
|
1657
|
-
if (lastTokenType2 === TOKEN_TYPES.Text || lastTokenType2 === void 0) {
|
|
1658
|
-
throw new SyntaxError(`Unexpected character: ${char}`);
|
|
1659
|
-
}
|
|
1660
|
-
switch (lastTokenType2) {
|
|
1661
|
-
case TOKEN_TYPES.Identifier:
|
|
1662
|
-
case TOKEN_TYPES.NumericLiteral:
|
|
1663
|
-
case TOKEN_TYPES.BooleanLiteral:
|
|
1664
|
-
case TOKEN_TYPES.StringLiteral:
|
|
1665
|
-
case TOKEN_TYPES.CloseParen:
|
|
1666
|
-
case TOKEN_TYPES.CloseSquareBracket:
|
|
1667
|
-
break;
|
|
1668
|
-
default: {
|
|
1669
|
-
++cursorPosition;
|
|
1670
|
-
const num = consumeWhile(isInteger);
|
|
1671
|
-
tokens.push(
|
|
1672
|
-
new Token(`${char}${num}`, num.length > 0 ? TOKEN_TYPES.NumericLiteral : TOKEN_TYPES.UnaryOperator)
|
|
1673
|
-
);
|
|
1674
|
-
continue;
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1631
|
+
main: while (cursorPosition < src.length) {
|
|
1632
|
+
const lastTokenType = tokens.at(-1)?.type;
|
|
1633
|
+
if (lastTokenType === void 0 || lastTokenType === TOKEN_TYPES.CloseStatement || lastTokenType === TOKEN_TYPES.CloseExpression) {
|
|
1634
|
+
let text = "";
|
|
1635
|
+
while (cursorPosition < src.length && // Keep going until we hit the next Jinja statement or expression
|
|
1636
|
+
!(src[cursorPosition] === "{" && (src[cursorPosition + 1] === "%" || src[cursorPosition + 1] === "{"))) {
|
|
1637
|
+
text += src[cursorPosition++];
|
|
1638
|
+
}
|
|
1639
|
+
if (text.length > 0) {
|
|
1640
|
+
tokens.push(new Token(text, TOKEN_TYPES.Text));
|
|
1641
|
+
continue;
|
|
1677
1642
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1643
|
+
}
|
|
1644
|
+
consumeWhile((char2) => /\s/.test(char2));
|
|
1645
|
+
const char = src[cursorPosition];
|
|
1646
|
+
if (char === "-" || char === "+") {
|
|
1647
|
+
const lastTokenType2 = tokens.at(-1)?.type;
|
|
1648
|
+
if (lastTokenType2 === TOKEN_TYPES.Text || lastTokenType2 === void 0) {
|
|
1649
|
+
throw new SyntaxError(`Unexpected character: ${char}`);
|
|
1650
|
+
}
|
|
1651
|
+
switch (lastTokenType2) {
|
|
1652
|
+
case TOKEN_TYPES.Identifier:
|
|
1653
|
+
case TOKEN_TYPES.NumericLiteral:
|
|
1654
|
+
case TOKEN_TYPES.BooleanLiteral:
|
|
1655
|
+
case TOKEN_TYPES.StringLiteral:
|
|
1656
|
+
case TOKEN_TYPES.CloseParen:
|
|
1657
|
+
case TOKEN_TYPES.CloseSquareBracket:
|
|
1658
|
+
break;
|
|
1659
|
+
default: {
|
|
1660
|
+
++cursorPosition;
|
|
1661
|
+
const num = consumeWhile(isInteger);
|
|
1662
|
+
tokens.push(
|
|
1663
|
+
new Token(`${char}${num}`, num.length > 0 ? TOKEN_TYPES.NumericLiteral : TOKEN_TYPES.UnaryOperator)
|
|
1664
|
+
);
|
|
1665
|
+
continue;
|
|
1684
1666
|
}
|
|
1685
1667
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
if (isInteger(char)) {
|
|
1694
|
-
const num = consumeWhile(isInteger);
|
|
1695
|
-
tokens.push(new Token(num, TOKEN_TYPES.NumericLiteral));
|
|
1696
|
-
continue;
|
|
1668
|
+
}
|
|
1669
|
+
for (const [char2, token] of ORDERED_MAPPING_TABLE) {
|
|
1670
|
+
const slice2 = src.slice(cursorPosition, cursorPosition + char2.length);
|
|
1671
|
+
if (slice2 === char2) {
|
|
1672
|
+
tokens.push(new Token(char2, token));
|
|
1673
|
+
cursorPosition += char2.length;
|
|
1674
|
+
continue main;
|
|
1697
1675
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1676
|
+
}
|
|
1677
|
+
if (char === "'" || char === '"') {
|
|
1678
|
+
++cursorPosition;
|
|
1679
|
+
const str = consumeWhile((c) => c !== char);
|
|
1680
|
+
tokens.push(new Token(str, TOKEN_TYPES.StringLiteral));
|
|
1681
|
+
++cursorPosition;
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
if (isInteger(char)) {
|
|
1685
|
+
const num = consumeWhile(isInteger);
|
|
1686
|
+
tokens.push(new Token(num, TOKEN_TYPES.NumericLiteral));
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
if (isWord(char)) {
|
|
1690
|
+
const word = consumeWhile(isWord);
|
|
1691
|
+
const type = Object.hasOwn(KEYWORDS, word) ? KEYWORDS[word] : TOKEN_TYPES.Identifier;
|
|
1692
|
+
if (type === TOKEN_TYPES.In && tokens.at(-1)?.type === TOKEN_TYPES.Not) {
|
|
1693
|
+
tokens.pop();
|
|
1694
|
+
tokens.push(new Token("not in", TOKEN_TYPES.NotIn));
|
|
1695
|
+
} else {
|
|
1696
|
+
tokens.push(new Token(word, type));
|
|
1708
1697
|
}
|
|
1709
|
-
|
|
1698
|
+
continue;
|
|
1710
1699
|
}
|
|
1700
|
+
throw new SyntaxError(`Unexpected character: ${char}`);
|
|
1701
|
+
}
|
|
1711
1702
|
return tokens;
|
|
1712
1703
|
}
|
|
1713
1704
|
|
|
@@ -3003,8 +2994,7 @@ var Interpreter = class {
|
|
|
3003
2994
|
return new StringValue(result);
|
|
3004
2995
|
}
|
|
3005
2996
|
evaluate(statement, environment) {
|
|
3006
|
-
if (statement === void 0)
|
|
3007
|
-
return new UndefinedValue();
|
|
2997
|
+
if (statement === void 0) return new UndefinedValue();
|
|
3008
2998
|
switch (statement.type) {
|
|
3009
2999
|
case "Program":
|
|
3010
3000
|
return this.evalProgram(statement, environment);
|
|
@@ -3823,8 +3813,7 @@ function createEventStreamTransformer(customParser) {
|
|
|
3823
3813
|
const parsedMessage = customParser ? customParser(event2.data, {
|
|
3824
3814
|
event: event2.event
|
|
3825
3815
|
}) : event2.data;
|
|
3826
|
-
if (parsedMessage)
|
|
3827
|
-
controller.enqueue(parsedMessage);
|
|
3816
|
+
if (parsedMessage) controller.enqueue(parsedMessage);
|
|
3828
3817
|
}
|
|
3829
3818
|
}
|
|
3830
3819
|
);
|
|
@@ -3840,15 +3829,13 @@ function createCallbacksTransformer(cb) {
|
|
|
3840
3829
|
const callbacks = cb || {};
|
|
3841
3830
|
return new TransformStream({
|
|
3842
3831
|
async start() {
|
|
3843
|
-
if (callbacks.onStart)
|
|
3844
|
-
await callbacks.onStart();
|
|
3832
|
+
if (callbacks.onStart) await callbacks.onStart();
|
|
3845
3833
|
},
|
|
3846
3834
|
async transform(message, controller) {
|
|
3847
3835
|
const content = typeof message === "string" ? message : message.content;
|
|
3848
3836
|
controller.enqueue(textEncoder.encode(content));
|
|
3849
3837
|
aggregatedResponse += content;
|
|
3850
|
-
if (callbacks.onToken)
|
|
3851
|
-
await callbacks.onToken(content);
|
|
3838
|
+
if (callbacks.onToken) await callbacks.onToken(content);
|
|
3852
3839
|
if (callbacks.onText && typeof message === "string") {
|
|
3853
3840
|
await callbacks.onText(message);
|
|
3854
3841
|
}
|
|
@@ -3868,8 +3855,7 @@ function trimStartOfStreamHelper() {
|
|
|
3868
3855
|
return (text) => {
|
|
3869
3856
|
if (isStreamStart) {
|
|
3870
3857
|
text = text.trimStart();
|
|
3871
|
-
if (text)
|
|
3872
|
-
isStreamStart = false;
|
|
3858
|
+
if (text) isStreamStart = false;
|
|
3873
3859
|
}
|
|
3874
3860
|
return text;
|
|
3875
3861
|
};
|
|
@@ -3896,10 +3882,8 @@ function readableFromAsyncIterable(iterable) {
|
|
|
3896
3882
|
return new ReadableStream({
|
|
3897
3883
|
async pull(controller) {
|
|
3898
3884
|
const { done, value } = await it.next();
|
|
3899
|
-
if (done)
|
|
3900
|
-
|
|
3901
|
-
else
|
|
3902
|
-
controller.enqueue(value);
|
|
3885
|
+
if (done) controller.close();
|
|
3886
|
+
else controller.enqueue(value);
|
|
3903
3887
|
},
|
|
3904
3888
|
async cancel(reason) {
|
|
3905
3889
|
await it.return?.(reason);
|
|
@@ -3973,8 +3957,7 @@ var XXHashAlgorithm = /* @__PURE__ */ ((XXHashAlgorithm2) => {
|
|
|
3973
3957
|
return XXHashAlgorithm2;
|
|
3974
3958
|
})(XXHashAlgorithm || {});
|
|
3975
3959
|
function xxhash(value, hashAlgo = 111 /* xxhash64 */, seed = SEED) {
|
|
3976
|
-
if (value.buffer)
|
|
3977
|
-
value = value.buffer;
|
|
3960
|
+
if (value.buffer) value = value.buffer;
|
|
3978
3961
|
let result;
|
|
3979
3962
|
if (hashAlgo !== 112 /* xxhash32 */) {
|
|
3980
3963
|
result = h64(value, seed);
|
|
@@ -4163,8 +4146,7 @@ function isObject(value) {
|
|
|
4163
4146
|
return !!value && value.constructor === Object;
|
|
4164
4147
|
}
|
|
4165
4148
|
function getKeysPath(value) {
|
|
4166
|
-
if (!value)
|
|
4167
|
-
return [];
|
|
4149
|
+
if (!value) return [];
|
|
4168
4150
|
return getKeys(value, [], "");
|
|
4169
4151
|
}
|
|
4170
4152
|
function getKeys(obj, paths, dot = ".") {
|
|
@@ -4386,31 +4368,38 @@ function jsonFilterToWhere(filter, wrapKey) {
|
|
|
4386
4368
|
}
|
|
4387
4369
|
if (Array.isArray(filter)) {
|
|
4388
4370
|
andQuery.push(generateAndClause(filter, wrapKey));
|
|
4389
|
-
} else
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4371
|
+
} else for (const [key, value] of Object.entries(filter)) {
|
|
4372
|
+
if (key === "$and") {
|
|
4373
|
+
andQuery.push(`(${generateAndClause(filter[key], wrapKey)})`);
|
|
4374
|
+
} else if (key === "$or") {
|
|
4375
|
+
andQuery.push(`(${generateOrClause(filter[key], wrapKey)})`);
|
|
4376
|
+
} else {
|
|
4377
|
+
const tValue = typeof value;
|
|
4378
|
+
if (value == null) {
|
|
4379
|
+
andQuery.push(`${wrapKey(key)} IS NULL`);
|
|
4380
|
+
} else if (tValue === "object" && !Array.isArray(value)) {
|
|
4381
|
+
andQuery.push(generateCondition(wrapKey(key), value));
|
|
4382
|
+
} else if (tValue === "string") {
|
|
4383
|
+
andQuery.push(`${wrapKey(key)}='${value}'`);
|
|
4384
|
+
} else if (tValue === "number" || tValue === "boolean") {
|
|
4385
|
+
andQuery.push(`${wrapKey(key)}=${value}`);
|
|
4395
4386
|
} else {
|
|
4396
|
-
|
|
4397
|
-
if (value == null) {
|
|
4398
|
-
andQuery.push(`${wrapKey(key)} IS NULL`);
|
|
4399
|
-
} else if (tValue === "object" && !Array.isArray(value)) {
|
|
4400
|
-
andQuery.push(generateCondition(wrapKey(key), value));
|
|
4401
|
-
} else if (tValue === "string") {
|
|
4402
|
-
andQuery.push(`${wrapKey(key)}='${value}'`);
|
|
4403
|
-
} else if (tValue === "number" || tValue === "boolean") {
|
|
4404
|
-
andQuery.push(`${wrapKey(key)}=${value}`);
|
|
4405
|
-
} else {
|
|
4406
|
-
throw new Error(`Unsupported value type for key ${key}`);
|
|
4407
|
-
}
|
|
4387
|
+
throw new Error(`Unsupported value type for key ${key}`);
|
|
4408
4388
|
}
|
|
4409
4389
|
}
|
|
4390
|
+
}
|
|
4410
4391
|
;
|
|
4411
4392
|
return andQuery.length > 1 ? andQuery.join(" AND ") : andQuery[0];
|
|
4412
4393
|
}
|
|
4413
4394
|
|
|
4395
|
+
// src/utils/match-url-protocol.ts
|
|
4396
|
+
function matchUrlProtocol(name) {
|
|
4397
|
+
const index = name.indexOf("://");
|
|
4398
|
+
if (index > 0) {
|
|
4399
|
+
return name.substring(0, index);
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4414
4403
|
// src/client-tools.ts
|
|
4415
4404
|
var ClientTools = class _ClientTools extends ToolFunc {
|
|
4416
4405
|
static get apiRoot() {
|
|
@@ -4426,8 +4415,7 @@ var ClientTools = class _ClientTools extends ToolFunc {
|
|
|
4426
4415
|
"Content-Type": "application/json"
|
|
4427
4416
|
} });
|
|
4428
4417
|
const items = await res.json();
|
|
4429
|
-
if (items)
|
|
4430
|
-
this.loadFromSync(items);
|
|
4418
|
+
if (items) this.loadFromSync(items);
|
|
4431
4419
|
} else {
|
|
4432
4420
|
throwError2("missing apiRoot to load tools", "ClientTools");
|
|
4433
4421
|
}
|
|
@@ -4733,8 +4721,7 @@ var EventClient = class extends ResClientTools {
|
|
|
4733
4721
|
for (const event2 of events) {
|
|
4734
4722
|
if (!this._forwardEvents.has(event2)) {
|
|
4735
4723
|
this._forwardEvents.add(event2);
|
|
4736
|
-
if (this.on)
|
|
4737
|
-
this.on(event2, this.ebListener);
|
|
4724
|
+
if (this.on) this.on(event2, this.ebListener);
|
|
4738
4725
|
}
|
|
4739
4726
|
}
|
|
4740
4727
|
}
|
|
@@ -4753,8 +4740,7 @@ var EventClient = class extends ResClientTools {
|
|
|
4753
4740
|
for (const event2 of events) {
|
|
4754
4741
|
if (this._forwardEvents.has(event2)) {
|
|
4755
4742
|
this._forwardEvents.delete(event2);
|
|
4756
|
-
if (this.off)
|
|
4757
|
-
this.off(event2, this.ebListener);
|
|
4743
|
+
if (this.off) this.off(event2, this.ebListener);
|
|
4758
4744
|
}
|
|
4759
4745
|
}
|
|
4760
4746
|
}
|
|
@@ -5055,6 +5041,7 @@ export {
|
|
|
5055
5041
|
saveConfigFile,
|
|
5056
5042
|
stringify2,
|
|
5057
5043
|
jsonFilterToWhere,
|
|
5044
|
+
matchUrlProtocol,
|
|
5058
5045
|
utils_exports,
|
|
5059
5046
|
ToolFunc,
|
|
5060
5047
|
ToolFuncSchema,
|