Add valuePatterns field; relax columnMap to optional for value-pattern-only mappings
layoutMappings/layoutMappingVersions gain valuePatterns (json, optional)
- same incremental pattern as startPage/headerBottom (migrations 7/8).
Also relaxes columnMap from required to optional on both collections:
confirmed empirically against the real running container that
PocketBase's required:true rejects an empty JSON object the same way
it rejects a missing one ("Cannot be blank"), and a value-pattern-only
mapping (no region-drawing at all) genuinely has no column positions
to store.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
a3b57e4d6d
commit
4236276e04
|
|
@ -0,0 +1,36 @@
|
||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A value-pattern-only mapping (see migration 9) genuinely has no
|
||||||
|
* column positions to store - there's no region-drawing step in that
|
||||||
|
* flow at all, so `columnMap` stays `{}`. Confirmed empirically against
|
||||||
|
* the real running container, not assumed: PocketBase's `required: true`
|
||||||
|
* on a JSON field rejects an empty object the same way it rejects a
|
||||||
|
* missing one ("Cannot be blank"), so this HAD to be relaxed, not just
|
||||||
|
* tolerated by existing code (which was already defensive everywhere -
|
||||||
|
* see LayoutsView.vue/AdminLayoutReviewView.vue's own `mapping.columnMap
|
||||||
|
* || {}` reads). Relaxed on BOTH collections, for parity with how every
|
||||||
|
* other field this schema has grown (startPage/headerBottom, migrations
|
||||||
|
* 7/8) was always added to both at once.
|
||||||
|
*/
|
||||||
|
migrate((app) => {
|
||||||
|
let layoutMappings = app.findCollectionByNameOrId('layoutMappings')
|
||||||
|
let columnMap = layoutMappings.fields.getByName('columnMap')
|
||||||
|
columnMap.required = false
|
||||||
|
app.save(layoutMappings)
|
||||||
|
|
||||||
|
let layoutMappingVersions = app.findCollectionByNameOrId('layoutMappingVersions')
|
||||||
|
let versionColumnMap = layoutMappingVersions.fields.getByName('columnMap')
|
||||||
|
versionColumnMap.required = false
|
||||||
|
app.save(layoutMappingVersions)
|
||||||
|
}, (app) => {
|
||||||
|
let layoutMappings = app.findCollectionByNameOrId('layoutMappings')
|
||||||
|
let columnMap = layoutMappings.fields.getByName('columnMap')
|
||||||
|
columnMap.required = true
|
||||||
|
app.save(layoutMappings)
|
||||||
|
|
||||||
|
let layoutMappingVersions = app.findCollectionByNameOrId('layoutMappingVersions')
|
||||||
|
let versionColumnMap = layoutMappingVersions.fields.getByName('columnMap')
|
||||||
|
versionColumnMap.required = true
|
||||||
|
app.save(layoutMappingVersions)
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value-pattern mapping (a narrower layout-mapper tier, 2026-10-31) -
|
||||||
|
* lets a user teach the extractor to CLEAN a raw value it can't parse
|
||||||
|
* (strip a currency-code prefix/suffix the general Unicode-symbol
|
||||||
|
* fallback in table_extract.py doesn't recognize) without drawing a
|
||||||
|
* single column region. `valuePatterns` is `{field: {stripPrefix?,
|
||||||
|
* stripSuffix?}}` for any of date/debit/credit/amount/balance - a
|
||||||
|
* mapping built this way carries THIS field but no real `columnMap`
|
||||||
|
* at all (it composes with auto-detection instead of replacing it -
|
||||||
|
* see table_extract.extract_pdf's own docstring), same optional,
|
||||||
|
* no-default pattern already used for startPage/headerBottom
|
||||||
|
* (migrations 7/8).
|
||||||
|
*/
|
||||||
|
migrate((app) => {
|
||||||
|
let layoutMappings = app.findCollectionByNameOrId('layoutMappings')
|
||||||
|
layoutMappings.fields.add(new Field({ type: 'json', name: 'valuePatterns' }))
|
||||||
|
app.save(layoutMappings)
|
||||||
|
|
||||||
|
let layoutMappingVersions = app.findCollectionByNameOrId('layoutMappingVersions')
|
||||||
|
layoutMappingVersions.fields.add(new Field({ type: 'json', name: 'valuePatterns' }))
|
||||||
|
app.save(layoutMappingVersions)
|
||||||
|
}, (app) => {
|
||||||
|
let layoutMappings = app.findCollectionByNameOrId('layoutMappings')
|
||||||
|
layoutMappings.fields.removeByName('valuePatterns')
|
||||||
|
app.save(layoutMappings)
|
||||||
|
|
||||||
|
let layoutMappingVersions = app.findCollectionByNameOrId('layoutMappingVersions')
|
||||||
|
layoutMappingVersions.fields.removeByName('valuePatterns')
|
||||||
|
app.save(layoutMappingVersions)
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue