fix(client): correct return inventory carton paging and label printing
This commit is contained in:
@@ -30,3 +30,13 @@ export function isApiEnvelope(value: unknown): value is ApiEnvelope<unknown> {
|
||||
const record = value as Record<string, unknown>
|
||||
return typeof record.code === 'string' && typeof record.message === 'string' && 'data' in record
|
||||
}
|
||||
|
||||
// Security failures have no business data, unlike successful API responses.
|
||||
export function isApiFailure(value: unknown): value is Omit<ApiEnvelope<never>, 'data'> {
|
||||
if (!value || typeof value !== 'object') return false
|
||||
const record = value as Record<string, unknown>
|
||||
return typeof record.code === 'string' && record.code !== '200'
|
||||
&& typeof record.message === 'string'
|
||||
&& (record.requestId == null || typeof record.requestId === 'string')
|
||||
&& (record.traceId == null || typeof record.traceId === 'string')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user