@aigne/doc-smith 0.8.12-beta.5 → 0.8.12-beta.6

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.8.12-beta.5"
2
+ ".": "0.8.12-beta.6"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.12-beta.6](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.12-beta.5...v0.8.12-beta.6) (2025-10-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **publish:** enhance access token retrieval and session check logic ([#178](https://github.com/AIGNE-io/aigne-doc-smith/issues/178)) ([e19e9f5](https://github.com/AIGNE-io/aigne-doc-smith/commit/e19e9f52b1c80ba8eb725cfa945cd312d0690ef1))
9
+
3
10
  ## [0.8.12-beta.5](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.12-beta.4...v0.8.12-beta.5) (2025-10-11)
4
11
 
5
12
 
@@ -57,18 +57,20 @@ export default async function publishDocs(
57
57
  let token = "";
58
58
 
59
59
  if (!useEnvAppUrl && isDefaultAppUrl && !hasAppUrlInConfig) {
60
- const authToken = await getOfficialAccessToken(BASE_URL);
60
+ const authToken = await getOfficialAccessToken(BASE_URL, false);
61
61
 
62
- if (!authToken) {
63
- throw new Error("Failed to get official access token");
64
- }
65
-
66
- const client = new BrokerClient({ baseUrl: BASE_URL, authToken });
62
+ let sessionId = "";
63
+ let paymentLink = "";
67
64
 
68
- const { sessionId, paymentLink } = await client.checkCacheSession({
69
- needShortUrl: true,
70
- sessionId: config?.checkoutId,
71
- });
65
+ if (authToken) {
66
+ const client = new BrokerClient({ baseUrl: BASE_URL, authToken });
67
+ const info = await client.checkCacheSession({
68
+ needShortUrl: true,
69
+ sessionId: config?.checkoutId,
70
+ });
71
+ sessionId = info.sessionId;
72
+ paymentLink = info.paymentLink;
73
+ }
72
74
 
73
75
  const choice = await options.prompts.select({
74
76
  message: "Select platform to publish your documents:",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.8.12-beta.5",
3
+ "version": "0.8.12-beta.6",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -446,39 +446,6 @@ describe("publish-docs", () => {
446
446
  expect(saveValueToConfigSpy).not.toHaveBeenCalledWith("boardId", expect.anything());
447
447
  });
448
448
 
449
- // ERROR HANDLING TESTS
450
- test("should handle failed official access token (null)", async () => {
451
- loadConfigFromFileSpy.mockResolvedValue({});
452
- getOfficialAccessTokenSpy.mockResolvedValue(null);
453
- mockOptions.prompts.select.mockResolvedValue("default");
454
-
455
- const result = await publishDocs(
456
- {
457
- docsDir: "./docs",
458
- appUrl: "https://docsmith.aigne.io",
459
- },
460
- mockOptions,
461
- );
462
-
463
- expect(result.message).toBe("❌ Failed to publish docs: Failed to get official access token");
464
- });
465
-
466
- test("should handle failed official access token (undefined)", async () => {
467
- loadConfigFromFileSpy.mockResolvedValue({});
468
- getOfficialAccessTokenSpy.mockResolvedValue(undefined);
469
- mockOptions.prompts.select.mockResolvedValue("default");
470
-
471
- const result = await publishDocs(
472
- {
473
- docsDir: "./docs",
474
- appUrl: "https://docsmith.aigne.io",
475
- },
476
- mockOptions,
477
- );
478
-
479
- expect(result.message).toBe("❌ Failed to publish docs: Failed to get official access token");
480
- });
481
-
482
449
  test("should handle checkCacheSession failure", async () => {
483
450
  loadConfigFromFileSpy.mockResolvedValue({});
484
451
  getOfficialAccessTokenSpy.mockResolvedValue("valid-token");
@@ -157,7 +157,7 @@ export async function getAccessToken(appUrl, ltToken = "") {
157
157
  * @param {string} baseUrl - The official service URL
158
158
  * @returns {Promise<string>} - The access token
159
159
  */
160
- export async function getOfficialAccessToken(baseUrl) {
160
+ export async function getOfficialAccessToken(baseUrl, openPage = true) {
161
161
  // Early parameter validation
162
162
  if (!baseUrl) {
163
163
  throw new Error("baseUrl parameter is required for getOfficialAccessToken.");
@@ -188,7 +188,7 @@ export async function getOfficialAccessToken(baseUrl) {
188
188
  }
189
189
 
190
190
  // If token is found, return it
191
- if (accessToken) {
191
+ if (accessToken || !openPage) {
192
192
  return accessToken;
193
193
  }
194
194