@howone/sdk 0.1.5 → 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 +39 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -241,7 +241,11 @@ var FloatingButton = ({
|
|
|
241
241
|
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
242
242
|
/* @__PURE__ */ jsx("img", { width: 20, className: "pointer-events-auto", src: "https://sxwxqoixnnklnpeutjrj.supabase.co/storage/v1/object/public/create-x/logo/logo-sm.svg", alt: "" }),
|
|
243
243
|
text,
|
|
244
|
-
/* @__PURE__ */ jsx(Icon, { icon: "mdi:close",
|
|
244
|
+
/* @__PURE__ */ jsx(Icon, { icon: "mdi:close", onClick: (e) => {
|
|
245
|
+
e.stopPropagation();
|
|
246
|
+
const btn = document.getElementById("floating-howone-btn");
|
|
247
|
+
if (btn) btn.style.display = "none";
|
|
248
|
+
}, className: "w-5 h-5 font-bold pointer-events-auto", style: { cursor: "pointer" } })
|
|
245
249
|
] })
|
|
246
250
|
}
|
|
247
251
|
);
|
|
@@ -942,9 +946,42 @@ var aiRequest = new request_default({
|
|
|
942
946
|
}
|
|
943
947
|
});
|
|
944
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
|
+
}
|
|
945
981
|
function createClient(opts) {
|
|
946
982
|
const biz = opts?.requestInstance || request;
|
|
947
983
|
const ai = opts?.aiRequestInstance || aiRequest;
|
|
984
|
+
const bizWrapped = wrapRequestWithProjectPrefix(biz, opts?.projectId);
|
|
948
985
|
let token = null;
|
|
949
986
|
try {
|
|
950
987
|
if (opts?.projectId) {
|
|
@@ -1033,7 +1070,7 @@ function createClient(opts) {
|
|
|
1033
1070
|
return {
|
|
1034
1071
|
// expose projectId so consumers can read it from the client instance
|
|
1035
1072
|
projectId: opts?.projectId ?? null,
|
|
1036
|
-
request:
|
|
1073
|
+
request: bizWrapped,
|
|
1037
1074
|
aiRequest: ai,
|
|
1038
1075
|
workflowRequest: ai,
|
|
1039
1076
|
// artifact helpers using artifacts-client
|