From 1590e69d67f309bb8d0b1516f8c622b53c60c98a Mon Sep 17 00:00:00 2001 From: wb-liuxuehuan Date: Tue, 23 Jun 2026 17:42:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(tokenplan):=20=E6=9B=B4=E6=96=B0=20Account?= =?UTF-8?q?Ids=20=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改 `assign-seats` 命令中的 AccountIds 参数处理,将字符串类型的 AccountIds 转换为数组。同时,更新相关的测试用例以验证新逻辑的正确性。 --- .../src/commands/tokenplan/assign-seats.ts | 2 +- packages/cli/tests/e2e/tokenplan.e2e.test.ts | 2 ++ packages/core/src/client/ak-sign.ts | 6 +++--- packages/core/tests/ak-sign.test.ts | 20 +++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 packages/core/tests/ak-sign.test.ts diff --git a/packages/cli/src/commands/tokenplan/assign-seats.ts b/packages/cli/src/commands/tokenplan/assign-seats.ts index d453ae4..5dd1e76 100644 --- a/packages/cli/src/commands/tokenplan/assign-seats.ts +++ b/packages/cli/src/commands/tokenplan/assign-seats.ts @@ -165,7 +165,7 @@ function buildQueryParams( if (Array.isArray(accountIds) && accountIds.length > 0) { params.AccountIds = accountIds; } else if (typeof accountIds === "string" && accountIds.length > 0) { - params.AccountIds = accountIds; + params.AccountIds = [accountIds]; } return params; diff --git a/packages/cli/tests/e2e/tokenplan.e2e.test.ts b/packages/cli/tests/e2e/tokenplan.e2e.test.ts index 1635bbf..e264cbf 100644 --- a/packages/cli/tests/e2e/tokenplan.e2e.test.ts +++ b/packages/cli/tests/e2e/tokenplan.e2e.test.ts @@ -328,6 +328,8 @@ describe("e2e: tokenplan dry-run", () => { expect(data.query?.WorkspaceId).toBe("ws_456"); expect(data.query?.SeatType).toBe("standard"); expect(data.query?.AccountIds).toEqual(["acc_1", "acc_2"]); + expect(data.endpoint).toMatch(/AccountIds\.1=acc_1/); + expect(data.endpoint).toMatch(/AccountIds\.2=acc_2/); }); test("add-member --dry-run 输出 endpoint 和 query 参数", async () => { diff --git a/packages/core/src/client/ak-sign.ts b/packages/core/src/client/ak-sign.ts index d807ad3..1f55c46 100644 --- a/packages/core/src/client/ak-sign.ts +++ b/packages/core/src/client/ak-sign.ts @@ -28,9 +28,9 @@ export function buildCanonicalQuery(params: Record { + expect( + buildCanonicalQuery({ + WorkspaceId: "ws_1", + SeatType: "pro", + AccountIds: ["acc_1", "acc_2"], + }), + ).toBe("AccountIds.1=acc_1&AccountIds.2=acc_2&SeatType=pro&WorkspaceId=ws_1"); +}); + +test("buildCanonicalQuery uses single indexed key for one-element arrays", () => { + expect( + buildCanonicalQuery({ + AccountIds: ["acc_2bd88814c31743d9aa5833dc16b3b8e0"], + }), + ).toBe("AccountIds.1=acc_2bd88814c31743d9aa5833dc16b3b8e0"); +});