@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 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
@@ -296,7 +296,11 @@ var FloatingButton = ({
296
296
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
297
297
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { width: 20, className: "pointer-events-auto", src: "https://sxwxqoixnnklnpeutjrj.supabase.co/storage/v1/object/public/create-x/logo/logo-sm.svg", alt: "" }),
298
298
  text,
299
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_iconify.Icon, { icon: "mdi:close", className: "w-5 h-5 font-bold pointer-events-auto" })
299
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_iconify.Icon, { icon: "mdi:close", onClick: (e) => {
300
+ e.stopPropagation();
301
+ const btn = document.getElementById("floating-howone-btn");
302
+ if (btn) btn.style.display = "none";
303
+ }, className: "w-5 h-5 font-bold pointer-events-auto", style: { cursor: "pointer" } })
300
304
  ] })
301
305
  }
302
306
  );
@@ -997,9 +1001,42 @@ var aiRequest = new request_default({
997
1001
  }
998
1002
  });
999
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
+ }
1000
1036
  function createClient(opts) {
1001
1037
  const biz = opts?.requestInstance || request;
1002
1038
  const ai = opts?.aiRequestInstance || aiRequest;
1039
+ const bizWrapped = wrapRequestWithProjectPrefix(biz, opts?.projectId);
1003
1040
  let token = null;
1004
1041
  try {
1005
1042
  if (opts?.projectId) {
@@ -1088,7 +1125,7 @@ function createClient(opts) {
1088
1125
  return {
1089
1126
  // expose projectId so consumers can read it from the client instance
1090
1127
  projectId: opts?.projectId ?? null,
1091
- request: biz,
1128
+ request: bizWrapped,
1092
1129
  aiRequest: ai,
1093
1130
  workflowRequest: ai,
1094
1131
  // artifact helpers using artifacts-client