27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
import { SET_CLIENTVERSION as MSSQL_SET } from '../../providers/mssql/queries/posterminal.js';
|
|
import { SET_CLIENTVERSION as SQLITE_SET } from '../../providers/sqlite3/queries/posterminal.js';
|
|
import makeRunner from '../runner.js';
|
|
|
|
export default function setClientversion(provider) {
|
|
const sql = provider?.dialect === 'sqlite3' ? SQLITE_SET : MSSQL_SET;
|
|
|
|
/**
|
|
* Stores the software version reported by a POS terminal.
|
|
*
|
|
* @param {number} id - The posterminal id.
|
|
* @param {string|null} clientversion - Version string reported by the client (trimmed; empty → null).
|
|
* @param {object} [tx] - Optional transaction to run within.
|
|
* @returns {Promise<{id: number, clientversion: string|null}>}
|
|
*
|
|
* @example
|
|
* await store.posterminal.setClientversion(7, '1.10.12.0');
|
|
* // => { id: 7, clientversion: '1.10.12.0' }
|
|
*/
|
|
return async (id, clientversion, tx) => {
|
|
const value = clientversion == null ? null : String(clientversion).trim() || null;
|
|
await makeRunner(provider, tx).query(sql, { id: Number(id), clientversion: value });
|
|
return { id: Number(id), clientversion: value };
|
|
};
|
|
}
|
|
|