拆分工单资料映射
This commit is contained in:
@@ -43,6 +43,10 @@ import {
|
||||
normalizeStatuses,
|
||||
normalizeUploadedFiles,
|
||||
} from './worker-input-normalizers.js'
|
||||
import {
|
||||
mapAcceptanceForResponse,
|
||||
resolveCollectSubmittedFieldValues,
|
||||
} from './work-order-material-mappers.js'
|
||||
export {
|
||||
assertWithdrawChannelAllowedForAmount,
|
||||
isWorkerPasswordStrong,
|
||||
@@ -1119,29 +1123,10 @@ export function matchesOptionalText(ruleValue: unknown, sourceValue: unknown) {
|
||||
)
|
||||
}
|
||||
|
||||
export function mapAcceptanceForResponse(value: unknown) {
|
||||
const acceptance = safeParseJson(value)
|
||||
const files = normalizeUploadedFiles(acceptance.files).map((file) =>
|
||||
refreshUploadedFileUrls(file),
|
||||
)
|
||||
const imageUrls = normalizeStringArray(acceptance.imageUrls).map((url) =>
|
||||
refreshStoredFileUrl(url),
|
||||
)
|
||||
return {
|
||||
...acceptance,
|
||||
files,
|
||||
imageUrls,
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveCollectSubmittedFieldValues(workOrder: WorkOrderRow) {
|
||||
const material = safeParseJson(workOrder.material_json)
|
||||
const collect =
|
||||
material.collect && typeof material.collect === 'object' && !Array.isArray(material.collect)
|
||||
? safeParseJson(material.collect)
|
||||
: {}
|
||||
return normalizeSubmittedFields(collect.fields)
|
||||
}
|
||||
export {
|
||||
mapAcceptanceForResponse,
|
||||
resolveCollectSubmittedFieldValues,
|
||||
} from './work-order-material-mappers.js'
|
||||
|
||||
export function isIgnorableWorkerAuthError(error: unknown) {
|
||||
return IGNORABLE_WORKER_AUTH_ERROR_CODES.has(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { WorkOrderRow } from '../../repositories/worker-platform/index.js'
|
||||
import { safeParseJson } from '../admin/admin-query-utils.js'
|
||||
import {
|
||||
refreshStoredFileUrl,
|
||||
refreshUploadedFileUrls,
|
||||
} from '../file-storage/file-storage-service.js'
|
||||
import {
|
||||
normalizeStringArray,
|
||||
normalizeSubmittedFields,
|
||||
normalizeUploadedFiles,
|
||||
} from './worker-input-normalizers.js'
|
||||
|
||||
export function mapAcceptanceForResponse(value: unknown) {
|
||||
const acceptance = safeParseJson(value)
|
||||
const files = normalizeUploadedFiles(acceptance.files).map((file) =>
|
||||
refreshUploadedFileUrls(file),
|
||||
)
|
||||
const imageUrls = normalizeStringArray(acceptance.imageUrls).map((url) =>
|
||||
refreshStoredFileUrl(url),
|
||||
)
|
||||
return { ...acceptance, files, imageUrls }
|
||||
}
|
||||
|
||||
export function resolveCollectSubmittedFieldValues(workOrder: WorkOrderRow) {
|
||||
const material = safeParseJson(workOrder.material_json)
|
||||
const collect =
|
||||
material.collect && typeof material.collect === 'object' && !Array.isArray(material.collect)
|
||||
? safeParseJson(material.collect)
|
||||
: {}
|
||||
return normalizeSubmittedFields(collect.fields)
|
||||
}
|
||||
Reference in New Issue
Block a user