@howone/sdk 0.1.6 → 0.1.7
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -244,8 +244,8 @@ var FloatingButton = ({
|
|
|
244
244
|
/* @__PURE__ */ jsx(Icon, { icon: "mdi:close", onClick: (e) => {
|
|
245
245
|
e.stopPropagation();
|
|
246
246
|
const btn = document.getElementById("floating-howone-btn");
|
|
247
|
-
|
|
248
|
-
}, className: "w-5 h-5 font-bold pointer-events-auto" })
|
|
247
|
+
if (btn) btn.style.display = "none";
|
|
248
|
+
}, className: "w-5 h-5 font-bold pointer-events-auto", style: { cursor: "pointer" } })
|
|
249
249
|
] })
|
|
250
250
|
}
|
|
251
251
|
);
|
|
@@ -946,9 +946,42 @@ var aiRequest = new request_default({
|
|
|
946
946
|
}
|
|
947
947
|
});
|
|
948
948
|
var workflowRequest = aiRequest;
|
|
949
|
+
function wrapRequestWithProjectPrefix(biz, projectId) {
|
|
950
|
+
if (!projectId) return biz;
|
|
951
|
+
const prefix = `/entities/apps/${String(projectId)}`;
|
|
952
|
+
function shouldPrefix(url) {
|
|
953
|
+
if (!url) return false;
|
|
954
|
+
const u = String(url);
|
|
955
|
+
if (u.startsWith(prefix)) return false;
|
|
956
|
+
if (/^https?:\/\//.test(u) || u.startsWith("//")) return false;
|
|
957
|
+
if (u.startsWith("/data")) return true;
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
const wrapped = {
|
|
961
|
+
instance: biz.instance,
|
|
962
|
+
request: (config) => {
|
|
963
|
+
try {
|
|
964
|
+
if (config && typeof config.url === "string" && shouldPrefix(config.url)) {
|
|
965
|
+
config = { ...config, url: `${prefix}${config.url}` };
|
|
966
|
+
}
|
|
967
|
+
} catch (_e) {
|
|
968
|
+
}
|
|
969
|
+
return biz.request(config);
|
|
970
|
+
},
|
|
971
|
+
get: (config) => wrapped.request({ ...config, method: "GET" }),
|
|
972
|
+
post: (config) => wrapped.request({ ...config, method: "POST" }),
|
|
973
|
+
put: (config) => wrapped.request({ ...config, method: "PUT" }),
|
|
974
|
+
patch: (config) => wrapped.request({ ...config, method: "PATCH" }),
|
|
975
|
+
delete: (config) => wrapped.request({ ...config, method: "DELETE" }),
|
|
976
|
+
cancelRequest: (url) => biz.cancelRequest(url),
|
|
977
|
+
cancelAllRequests: () => biz.cancelAllRequests()
|
|
978
|
+
};
|
|
979
|
+
return wrapped;
|
|
980
|
+
}
|
|
949
981
|
function createClient(opts) {
|
|
950
982
|
const biz = opts?.requestInstance || request;
|
|
951
983
|
const ai = opts?.aiRequestInstance || aiRequest;
|
|
984
|
+
const bizWrapped = wrapRequestWithProjectPrefix(biz, opts?.projectId);
|
|
952
985
|
let token = null;
|
|
953
986
|
try {
|
|
954
987
|
if (opts?.projectId) {
|
|
@@ -1037,7 +1070,7 @@ function createClient(opts) {
|
|
|
1037
1070
|
return {
|
|
1038
1071
|
// expose projectId so consumers can read it from the client instance
|
|
1039
1072
|
projectId: opts?.projectId ?? null,
|
|
1040
|
-
request:
|
|
1073
|
+
request: bizWrapped,
|
|
1041
1074
|
aiRequest: ai,
|
|
1042
1075
|
workflowRequest: ai,
|
|
1043
1076
|
// artifact helpers using artifacts-client
|