fix(lastleg): route all relabel pickups directly to outbound and verify final schemas

This commit is contained in:
2026-10-15 21:05:34 +08:00
parent 4277601999
commit 607aaf74dc
27 changed files with 717 additions and 185 deletions
+8 -5
View File
@@ -49,12 +49,15 @@ function splitValues(value) {
}
export function seedRows(sql, name) {
const pattern = new RegExp(`^INSERT INTO ${name} \\(([^\\n]+?)\\) VALUES \\(([^\\n]+)\\);$`, 'gm')
return [...sql.matchAll(pattern)].map(match => {
const pattern = new RegExp(`^INSERT INTO ${name} \\(([^\\n]+?)\\) VALUES\\s*([\\s\\S]*?);$`, 'gm')
return [...sql.replaceAll('\r\n', '\n').matchAll(pattern)].flatMap(match => {
const keys = match[1].split(',').map(key => key.trim())
const values = splitValues(match[2])
if (keys.length !== values.length) throw new Error(`Invalid seed columns: ${name}`)
return Object.fromEntries(keys.map((key, i) => [key, values[i]]))
return splitValues(match[2]).map(row => {
if (!row.startsWith('(') || !row.endsWith(')')) throw new Error(`Invalid seed row: ${name}`)
const values = splitValues(row.slice(1, -1))
if (keys.length !== values.length) throw new Error(`Invalid seed columns: ${name}`)
return Object.fromEntries(keys.map((key, i) => [key, values[i]]))
})
})
}