Skip to content

Commit 2d54a08

Browse files
committed
Merge pull request #2 from talkvalue/release-please--branches--main--components--cli
chore(main): release 1.1.0
2 parents 3e116d8 + 70b9f34 commit 2d54a08

6 files changed

Lines changed: 49 additions & 3 deletions

File tree

.omc/state/last-tool-error.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tool_name": "Bash",
3+
"tool_input_preview": "{\"command\":\"cd ~/Project/cli && cp dist/cli.js.bak dist/cli.js && sed -i '' 's/let request = new Request(url, requestInit);/let request = new Request(url, requestInit); console.error(\\\"DEBUG request:\\...",
4+
"error": "Exit code 1\n{\n \"error\": {\n \"message\": \"Request failed with status 401\"\n }\n}",
5+
"timestamp": "2026-03-24T02:03:45.762Z",
6+
"retry_count": 2
7+
}

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.0.1"
2+
".": "1.1.0"
33
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.1.0](https://github.com/talkvalue/cli/compare/v1.0.1...v1.1.0) (2026-03-23)
4+
5+
6+
### Features
7+
8+
* migrate to hey-api SDK, upgrade prompt UX, code fixes ([3e116d8](https://github.com/talkvalue/cli/commit/3e116d8021479865d7f5b0d9bc0adf6944fc5164))
9+
310
## [1.0.1](https://github.com/talkvalue/cli/compare/v1.0.0...v1.0.1) (2026-03-23)
411

512

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@talkvalue/cli",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "TalkValue CLI — manage your contacts and channels",
55
"type": "module",
66
"bin": {

src/api/interceptors.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import { client as authClient } from "./generated/auth/client.gen.js";
33
import { client as pathClient } from "./generated/path/client.gen.js";
44

55
let interceptorsRegistered = false;
6+
let refreshFn: (() => Promise<boolean>) | undefined;
7+
let authFn: (() => Promise<string | undefined>) | undefined;
68

79
export function configureClients(options: {
810
baseUrl: string;
911
auth: () => Promise<string | undefined>;
12+
onRefreshToken?: () => Promise<boolean>;
1013
}): void {
14+
authFn = options.auth;
15+
refreshFn = options.onRefreshToken;
16+
1117
for (const client of [authClient, pathClient]) {
1218
client.setConfig({
1319
baseUrl: options.baseUrl,
@@ -19,7 +25,23 @@ export function configureClients(options: {
1925
interceptorsRegistered = true;
2026

2127
for (const client of [authClient, pathClient]) {
22-
client.interceptors.response.use(async (response) => {
28+
// Interceptor signature: (response, request, opts) => response
29+
client.interceptors.response.use(async (response: Response, request: Request) => {
30+
// 401 retry with token refresh
31+
if (response.status === 401 && refreshFn) {
32+
const refreshed = await refreshFn();
33+
if (refreshed && authFn) {
34+
const newToken = await authFn();
35+
if (newToken) {
36+
const retryRequest = new Request(request, {
37+
headers: new Headers(request.headers),
38+
});
39+
retryRequest.headers.set("Authorization", `Bearer ${newToken}`);
40+
return fetch(retryRequest);
41+
}
42+
}
43+
}
44+
2345
if (!response.ok) {
2446
const contentType = response.headers.get("content-type");
2547
if (contentType?.includes("application/json")) {

src/shared/context.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Command } from "commander";
22

33
import { configureClients } from "../api/interceptors.js";
4+
import { createStoredTokenRefreshHandler } from "../auth/refresh.js";
45
import { getAccessToken } from "../auth/token.js";
56
import { loadConfig } from "../config/config.js";
67
import { resolveEnv } from "../config/env.js";
@@ -56,6 +57,15 @@ export async function resolveCommandContext(command: Command): Promise<CommandCo
5657
configureClients({
5758
baseUrl,
5859
auth: async () => env.token ?? (profile ? await getAccessToken(profile) : undefined),
60+
onRefreshToken: profile
61+
? createStoredTokenRefreshHandler({
62+
authApiUrl: env.authApiUrl,
63+
clientId: config.client_id,
64+
env,
65+
organizationId: config.profiles[profile]?.org_id,
66+
profile,
67+
})
68+
: undefined,
5969
});
6070

6171
return {

0 commit comments

Comments
 (0)