Skip to content

Commit bb1165e

Browse files
committed
format operation IDs in table as integer
1 parent 3c813e2 commit bb1165e

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

packages/app/src/cli/services/bulk-operations/bulk-operation-status.test.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import {getBulkOperationStatus, listBulkOperations, normalizeBulkOperationId} from './bulk-operation-status.js'
1+
import {
2+
getBulkOperationStatus,
3+
listBulkOperations,
4+
normalizeBulkOperationId,
5+
extractBulkOperationId,
6+
} from './bulk-operation-status.js'
27
import {GetBulkOperationByIdQuery} from '../../api/graphql/bulk-operations/generated/get-bulk-operation-by-id.js'
38
import {OrganizationApp, Organization, OrganizationSource} from '../../models/organization.js'
49
import {ListBulkOperationsQuery} from '../../api/graphql/bulk-operations/generated/list-bulk-operations.js'
@@ -53,6 +58,18 @@ describe('normalizeBulkOperationId', () => {
5358
})
5459
})
5560

61+
describe('extractBulkOperationId', () => {
62+
test('extracts numeric ID from GID', () => {
63+
expect(extractBulkOperationId('gid://shopify/BulkOperation/123')).toBe('123')
64+
expect(extractBulkOperationId('gid://shopify/BulkOperation/456789')).toBe('456789')
65+
})
66+
67+
test('returns input as-is if not a valid GID format', () => {
68+
expect(extractBulkOperationId('invalid-id')).toBe('invalid-id')
69+
expect(extractBulkOperationId('123')).toBe('123')
70+
})
71+
})
72+
5673
describe('getBulkOperationStatus', () => {
5774
function mockBulkOperation(
5875
overrides?: Partial<NonNullable<GetBulkOperationByIdQuery['bulkOperation']>>,
@@ -239,15 +256,15 @@ describe('listBulkOperations', () => {
239256
│ │
240257
╰──────────────────────────────────────────────────────────────────────────────╯
241258
242-
ID STATUS COU DATE CREATED DATE RESULTS
243-
T FINISHED
259+
I STATUS COUNT DATE CREATED DATE FINISHED RESULTS
244260
245-
──────────────── ────── ─── ──────────── ─────────── ───────────────────────────
246-
──────────── ── ── ─────── ─────── ───────────────────
247-
gid://shopify/Bu COMPLE 123 2025-11-10 2025-11-10 download ( https://example.
248-
kOperation/1 ED 5K 12:37:52 16:37:12 com/results.jsonl )
249-
gid://shopify/Bu RUNNIN 100 2025-11-11
250-
kOperation/2 15:37:52"
261+
─ ─────── ───── ────────────── ────────────── ──────────────────────────────────
262+
─ ──── ──── ────────────
263+
1 COMPLET 123.5 2025-11-10 2025-11-10 download (
264+
D 12:37:52 16:37:12 https://example.com/results.jsonl
265+
)
266+
2 RUNNING 100 2025-11-11
267+
15:37:52"
251268
`)
252269
})
253270

packages/app/src/cli/services/bulk-operations/bulk-operation-status.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export function normalizeBulkOperationId(id: string): string {
3636
return id
3737
}
3838

39+
export function extractBulkOperationId(gid: string): string {
40+
// Extract the numeric ID from a GID like "gid://shopify/BulkOperation/123"
41+
const match = gid.match(/\/BulkOperation\/(\d+)$/)
42+
return match?.[1] ?? gid
43+
}
44+
3945
interface GetBulkOperationStatusOptions {
4046
organization: Organization
4147
storeFqdn: string
@@ -119,7 +125,7 @@ export async function listBulkOperations(options: ListBulkOperationsOptions): Pr
119125
})
120126

121127
const operations = response.bulkOperations.nodes.map((operation) => ({
122-
id: operation.id,
128+
id: extractBulkOperationId(operation.id),
123129
status: formatStatus(operation.status),
124130
count: formatCount(operation.objectCount as number),
125131
dateCreated: formatDate(new Date(String(operation.createdAt))),

0 commit comments

Comments
 (0)