feat: bump client-services (accumulated feature work + deploy fixes)
Snapshot of in-progress work across local_backend, manager_dashboard, and waiter_pwa (pricing, chat, fiscal, prep zones, recovery codes, CRM, inventory, permissions), plus the nginx/docker-compose deploy fixes for the Unraid + NPM reverse-proxy setup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+105
-10
@@ -1,23 +1,118 @@
|
||||
import Dexie from 'dexie'
|
||||
|
||||
/**
|
||||
* Local IndexedDB snapshot — written by SSE events and full GETs.
|
||||
* Read-only in Emergency Mode when the server is unreachable.
|
||||
*/
|
||||
// NOTE: do NOT use 'tables' as a store name — Dexie 4.x has a built-in
|
||||
// `.tables` getter on the prototype that returns all registered stores as an
|
||||
// array, so an own-property store named 'tables' gets shadowed by it.
|
||||
// We use pos_ prefix on store names to avoid all such collisions.
|
||||
|
||||
const db = new Dexie('pos_snapshot')
|
||||
|
||||
db.version(1).stores({
|
||||
tables: 'id, group_id, is_active',
|
||||
orders: 'id, table_id, status',
|
||||
tables: 'id, group_id, is_active',
|
||||
orders: 'id, table_id, status',
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
})
|
||||
|
||||
db.version(2).stores({
|
||||
tables: 'id, group_id, is_active',
|
||||
orders: 'id, table_id, status',
|
||||
tables: 'id, group_id, is_active',
|
||||
orders: 'id, table_id, status',
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
})
|
||||
|
||||
db.version(3).stores({
|
||||
tables: 'id, group_id, is_active',
|
||||
orders: 'id, table_id, status',
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
offline_orders: '++localId, uuid, synced, table_id',
|
||||
})
|
||||
|
||||
db.version(4).stores({
|
||||
tables: 'id, group_id, is_active',
|
||||
orders: 'id, table_id, status',
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
offline_orders: '++localId, uuid, synced, table_id',
|
||||
table_groups: 'id',
|
||||
flag_defs: 'id',
|
||||
flag_assignments: '++localId, table_id, flag_id',
|
||||
})
|
||||
|
||||
// Version 5: rename 'tables' → 'pos_tables' and 'orders' → 'pos_orders'
|
||||
db.version(5).stores({
|
||||
tables: null,
|
||||
orders: null,
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
offline_orders: '++localId, uuid, synced, table_id',
|
||||
table_groups: 'id',
|
||||
flag_defs: 'id',
|
||||
flag_assignments: '++localId, table_id, flag_id',
|
||||
pos_tables: 'id, group_id, is_active',
|
||||
pos_orders: 'id, table_id, status',
|
||||
}).upgrade(tx => {
|
||||
return tx.table('tables').toArray().then(rows => {
|
||||
if (rows.length > 0) return tx.table('pos_tables').bulkPut(rows)
|
||||
}).then(() =>
|
||||
tx.table('orders').toArray().then(rows => {
|
||||
if (rows.length > 0) return tx.table('pos_orders').bulkPut(rows)
|
||||
})
|
||||
).catch(() => {})
|
||||
})
|
||||
|
||||
// Version 6: add offline_ops queue for splits and payments taken offline
|
||||
db.version(6).stores({
|
||||
tables: null,
|
||||
orders: null,
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
offline_orders: '++localId, uuid, synced, table_id',
|
||||
table_groups: 'id',
|
||||
flag_defs: 'id',
|
||||
flag_assignments: '++localId, table_id, flag_id',
|
||||
pos_tables: 'id, group_id, is_active',
|
||||
pos_orders: 'id, table_id, status',
|
||||
offline_ops: '++localId, orderId, synced, seq',
|
||||
})
|
||||
|
||||
// Version 7: add kv store for persisting WebSocket cursor (last seen seq_id)
|
||||
db.version(7).stores({
|
||||
tables: null,
|
||||
orders: null,
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
offline_orders: '++localId, uuid, synced, table_id',
|
||||
table_groups: 'id',
|
||||
flag_defs: 'id',
|
||||
flag_assignments: '++localId, table_id, flag_id',
|
||||
pos_tables: 'id, group_id, is_active',
|
||||
pos_orders: 'id, table_id, status',
|
||||
offline_ops: '++localId, orderId, synced, seq',
|
||||
kv: 'key',
|
||||
})
|
||||
|
||||
// Version 8: add uuid index to offline_ops (needed for legacy-drain dedup check)
|
||||
db.version(8).stores({
|
||||
tables: null,
|
||||
orders: null,
|
||||
offline_payments: '++localId, uuid, synced',
|
||||
products: 'id, category_id, is_available',
|
||||
categories: 'id, parent_id',
|
||||
offline_orders: '++localId, uuid, synced, table_id',
|
||||
table_groups: 'id',
|
||||
flag_defs: 'id',
|
||||
flag_assignments: '++localId, table_id, flag_id',
|
||||
pos_tables: 'id, group_id, is_active',
|
||||
pos_orders: 'id, table_id, status',
|
||||
offline_ops: '++localId, uuid, orderId, synced, seq',
|
||||
kv: 'key',
|
||||
})
|
||||
|
||||
export default db
|
||||
|
||||
Reference in New Issue
Block a user