Skip to content

Commit 515c582

Browse files
committed
fix(download-abi): update handling of pagination tokens in download-abi command
- Refactored the handling of pagination tokens in the `download-abi` command to utilize an array of continue token fields for improved flexibility. - Updated the test suite to ensure proper verification of pagination behavior with the new implementation.
1 parent f65951d commit 515c582

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/cli/commands/download-abi/download-abi.command.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ const createPaginatedContext = (
8080
return Promise.resolve({
8181
body: {
8282
items,
83-
metadata: nextToken ? { continue: nextToken } : {},
83+
metadata: nextToken
84+
? { continue: nextToken, _continue: nextToken }
85+
: {},
8486
},
8587
});
8688
},

src/cli/commands/download-abi/download-abi.command.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "../../integrations/kubernetes/kubernetes.client.ts";
1515

1616
const DEFAULT_OUTPUT_DIRECTORY = "/data/abi";
17-
const CONTINUE_TOKEN_FIELD = "continue";
17+
const CONTINUE_TOKEN_FIELDS = ["_continue", "continue"] as const;
1818
const SAFE_FILENAME_PATTERN = /[\\/]/g;
1919

2020
type CommanderOptions = {
@@ -64,15 +64,12 @@ const getContinueToken = (payload: unknown): string | undefined => {
6464
}
6565

6666
const source = "body" in payload && payload.body ? payload.body : payload;
67-
if (
68-
source &&
69-
typeof (source as { metadata?: { continue?: string } }).metadata?.[
70-
CONTINUE_TOKEN_FIELD
71-
] === "string"
72-
) {
73-
return (source as { metadata: { continue: string } }).metadata[
74-
CONTINUE_TOKEN_FIELD
75-
];
67+
for (const field of CONTINUE_TOKEN_FIELDS) {
68+
const candidate = (source as { metadata?: Record<string, unknown> })
69+
.metadata?.[field];
70+
if (typeof candidate === "string" && candidate.length > 0) {
71+
return candidate;
72+
}
7673
}
7774
return;
7875
};
@@ -123,8 +120,6 @@ const writeConfigMap = async (
123120
return written;
124121
};
125122

126-
const PAGE_SIZE = 100;
127-
128123
const fetchAbiConfigMaps = async (
129124
context: KubernetesClient
130125
): Promise<readonly V1ConfigMap[]> => {
@@ -134,11 +129,9 @@ const fetchAbiConfigMaps = async (
134129
do {
135130
const request: {
136131
namespace: string;
137-
limit: number;
138132
_continue?: string;
139133
} = {
140134
namespace: context.namespace,
141-
limit: PAGE_SIZE,
142135
};
143136
if (continueToken) {
144137
request._continue = continueToken;

0 commit comments

Comments
 (0)