@howone/sdk 0.1.24 → 0.1.26
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 +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -389,7 +389,15 @@ declare function createClient(opts?: {
|
|
|
389
389
|
cancelAllRequests: () => void;
|
|
390
390
|
};
|
|
391
391
|
aiRequest: Request;
|
|
392
|
-
workflowRequest:
|
|
392
|
+
workflowRequest: {
|
|
393
|
+
get: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
394
|
+
post: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
|
|
395
|
+
put: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
396
|
+
delete: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
397
|
+
request: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
398
|
+
cancelRequest: (url: string) => void;
|
|
399
|
+
cancelAllRequests: () => void;
|
|
400
|
+
};
|
|
393
401
|
artifacts: {
|
|
394
402
|
create(input: ArtifactCreateInput): Promise<Artifact>;
|
|
395
403
|
list(query?: ArtifactListQuery): Promise<Artifact[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -389,7 +389,15 @@ declare function createClient(opts?: {
|
|
|
389
389
|
cancelAllRequests: () => void;
|
|
390
390
|
};
|
|
391
391
|
aiRequest: Request;
|
|
392
|
-
workflowRequest:
|
|
392
|
+
workflowRequest: {
|
|
393
|
+
get: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
394
|
+
post: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
|
|
395
|
+
put: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
396
|
+
delete: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
397
|
+
request: <T = any>(config: RequestConfig<T>) => Promise<T>;
|
|
398
|
+
cancelRequest: (url: string) => void;
|
|
399
|
+
cancelAllRequests: () => void;
|
|
400
|
+
};
|
|
393
401
|
artifacts: {
|
|
394
402
|
create(input: ArtifactCreateInput): Promise<Artifact>;
|
|
395
403
|
list(query?: ArtifactListQuery): Promise<Artifact[]>;
|
package/dist/index.js
CHANGED
|
@@ -1283,12 +1283,32 @@ function createClient(opts) {
|
|
|
1283
1283
|
}
|
|
1284
1284
|
} catch (_e) {
|
|
1285
1285
|
}
|
|
1286
|
+
const workflowRequestWrapped = ai ? {
|
|
1287
|
+
get: ai.get.bind(ai),
|
|
1288
|
+
post: (config) => {
|
|
1289
|
+
const modifiedConfig = { ...config };
|
|
1290
|
+
if (opts?.projectId && modifiedConfig.url) {
|
|
1291
|
+
const workflowPattern = /^\/?(?:workflow\/)?([^\/]+)\/execute/;
|
|
1292
|
+
const match = modifiedConfig.url.match(workflowPattern);
|
|
1293
|
+
if (match) {
|
|
1294
|
+
const workflowId = match[1];
|
|
1295
|
+
modifiedConfig.url = `/workflow/${opts.projectId}/${workflowId}/execute`;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
return ai.post(modifiedConfig);
|
|
1299
|
+
},
|
|
1300
|
+
put: ai.put.bind(ai),
|
|
1301
|
+
delete: ai.delete.bind(ai),
|
|
1302
|
+
request: ai.request.bind(ai),
|
|
1303
|
+
cancelRequest: ai.cancelRequest?.bind(ai),
|
|
1304
|
+
cancelAllRequests: ai.cancelAllRequests?.bind(ai)
|
|
1305
|
+
} : ai;
|
|
1286
1306
|
return {
|
|
1287
1307
|
// expose projectId so consumers can read it from the client instance
|
|
1288
1308
|
projectId: opts?.projectId ?? null,
|
|
1289
1309
|
request: bizWrapped,
|
|
1290
1310
|
aiRequest: ai,
|
|
1291
|
-
workflowRequest:
|
|
1311
|
+
workflowRequest: workflowRequestWrapped,
|
|
1292
1312
|
// artifact helpers using artifacts-client
|
|
1293
1313
|
artifacts: createArtifactsClient(biz),
|
|
1294
1314
|
me: async () => {
|
|
@@ -1641,25 +1661,38 @@ var HowOneProvider = ({
|
|
|
1641
1661
|
}) => {
|
|
1642
1662
|
const [user, setUser] = (0, import_react5.useState)(() => parseUserFromToken(getToken()));
|
|
1643
1663
|
const [token, setTokenState] = (0, import_react5.useState)(() => getToken());
|
|
1664
|
+
const [hasCheckedUrlToken, setHasCheckedUrlToken] = (0, import_react5.useState)(false);
|
|
1644
1665
|
(0, import_react5.useEffect)(() => {
|
|
1645
1666
|
try {
|
|
1646
1667
|
const params = new URLSearchParams(window.location.search);
|
|
1647
|
-
|
|
1668
|
+
let urlToken = params.get("access_token") || params.get("token");
|
|
1669
|
+
if (!urlToken && window.location.hash) {
|
|
1670
|
+
const hashParams = new URLSearchParams(window.location.hash.slice(1));
|
|
1671
|
+
urlToken = hashParams.get("access_token") || hashParams.get("token");
|
|
1672
|
+
}
|
|
1648
1673
|
if (urlToken) {
|
|
1674
|
+
console.log("[HowOneProvider] Token captured from URL, storing to localStorage...");
|
|
1649
1675
|
setToken(urlToken);
|
|
1650
1676
|
setTokenState(urlToken);
|
|
1651
1677
|
setUser(parseUserFromToken(urlToken));
|
|
1652
1678
|
params.delete("access_token");
|
|
1653
1679
|
params.delete("token");
|
|
1680
|
+
params.delete("project_id");
|
|
1654
1681
|
const newSearch = params.toString();
|
|
1655
|
-
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "")
|
|
1682
|
+
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "");
|
|
1656
1683
|
window.history.replaceState({}, "", newUrl);
|
|
1684
|
+
console.log("[HowOneProvider] Token stored successfully, URL cleaned");
|
|
1657
1685
|
}
|
|
1658
1686
|
} catch (e) {
|
|
1659
1687
|
console.error("[HowOneProvider] Failed to capture token from URL:", e);
|
|
1688
|
+
} finally {
|
|
1689
|
+
setHasCheckedUrlToken(true);
|
|
1660
1690
|
}
|
|
1661
1691
|
}, []);
|
|
1662
1692
|
(0, import_react5.useEffect)(() => {
|
|
1693
|
+
if (!hasCheckedUrlToken) {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1663
1696
|
if (redirectOnUnauthenticated && !token && !user) {
|
|
1664
1697
|
const currentUrl = new URL(window.location.href);
|
|
1665
1698
|
if (!currentUrl.pathname.includes("/auth")) {
|
|
@@ -1679,7 +1712,7 @@ var HowOneProvider = ({
|
|
|
1679
1712
|
}
|
|
1680
1713
|
}
|
|
1681
1714
|
}
|
|
1682
|
-
}, [token, user, redirectOnUnauthenticated, authUrl, projectId]);
|
|
1715
|
+
}, [token, user, redirectOnUnauthenticated, authUrl, projectId, hasCheckedUrlToken]);
|
|
1683
1716
|
const logout = () => {
|
|
1684
1717
|
try {
|
|
1685
1718
|
setToken(null);
|