@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 CHANGED
@@ -372,7 +372,7 @@ declare function createClient(opts?: {
372
372
  aiRequestInstance?: Request;
373
373
  }): {
374
374
  projectId: string | null;
375
- request: Request;
375
+ request: any;
376
376
  aiRequest: Request;
377
377
  workflowRequest: Request;
378
378
  artifacts: {
package/dist/index.d.ts CHANGED
@@ -372,7 +372,7 @@ declare function createClient(opts?: {
372
372
  aiRequestInstance?: Request;
373
373
  }): {
374
374
  projectId: string | null;
375
- request: Request;
375
+ request: any;
376
376
  aiRequest: Request;
377
377
  workflowRequest: Request;
378
378
  artifacts: {
package/dist/index.js CHANGED
@@ -299,8 +299,8 @@ var FloatingButton = ({
299
299
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_iconify.Icon, { icon: "mdi:close", onClick: (e) => {
300
300
  e.stopPropagation();
301
301
  const btn = document.getElementById("floating-howone-btn");
302
- btn?.parentElement?.removeChild(btn);
303
- }, className: "w-5 h-5 font-bold pointer-events-auto" })
302
+ if (btn) btn.style.display = "none";
303
+ }, className: "w-5 h-5 font-bold pointer-events-auto", style: { cursor: "pointer" } })
304
304
  ] })
305
305
  }
306
306
  );
@@ -1001,9 +1001,42 @@ var aiRequest = new request_default({
1001
1001
  }
1002
1002
  });
1003
1003
  var workflowRequest = aiRequest;
1004
+ function wrapRequestWithProjectPrefix(biz, projectId) {
1005
+ if (!projectId) return biz;
1006
+ const prefix = `/entities/apps/${String(projectId)}`;
1007
+ function shouldPrefix(url) {
1008
+ if (!url) return false;
1009
+ const u = String(url);
1010
+ if (u.startsWith(prefix)) return false;
1011
+ if (/^https?:\/\//.test(u) || u.startsWith("//")) return false;
1012
+ if (u.startsWith("/data")) return true;
1013
+ return false;
1014
+ }
1015
+ const wrapped = {
1016
+ instance: biz.instance,
1017
+ request: (config) => {
1018
+ try {
1019
+ if (config && typeof config.url === "string" && shouldPrefix(config.url)) {
1020
+ config = { ...config, url: `${prefix}${config.url}` };
1021
+ }
1022
+ } catch (_e) {
1023
+ }
1024
+ return biz.request(config);
1025
+ },
1026
+ get: (config) => wrapped.request({ ...config, method: "GET" }),
1027
+ post: (config) => wrapped.request({ ...config, method: "POST" }),
1028
+ put: (config) => wrapped.request({ ...config, method: "PUT" }),
1029
+ patch: (config) => wrapped.request({ ...config, method: "PATCH" }),
1030
+ delete: (config) => wrapped.request({ ...config, method: "DELETE" }),
1031
+ cancelRequest: (url) => biz.cancelRequest(url),
1032
+ cancelAllRequests: () => biz.cancelAllRequests()
1033
+ };
1034
+ return wrapped;
1035
+ }
1004
1036
  function createClient(opts) {
1005
1037
  const biz = opts?.requestInstance || request;
1006
1038
  const ai = opts?.aiRequestInstance || aiRequest;
1039
+ const bizWrapped = wrapRequestWithProjectPrefix(biz, opts?.projectId);
1007
1040
  let token = null;
1008
1041
  try {
1009
1042
  if (opts?.projectId) {
@@ -1092,7 +1125,7 @@ function createClient(opts) {
1092
1125
  return {
1093
1126
  // expose projectId so consumers can read it from the client instance
1094
1127
  projectId: opts?.projectId ?? null,
1095
- request: biz,
1128
+ request: bizWrapped,
1096
1129
  aiRequest: ai,
1097
1130
  workflowRequest: ai,
1098
1131
  // artifact helpers using artifacts-client