This commit is contained in:
seb
2026-10-29 03:28:39 +01:00
parent 75a83bdc28
commit 0fb5893a70
6 changed files with 165 additions and 17 deletions

View File

@@ -63,7 +63,7 @@ WHERE pairingpin = @pairingpin
export const PAIR = `
UPDATE posterminal
SET token = @token, paired_at = @pairedAt, clientserial = @clientserial, pairingpin = NULL, lastseen_at = @pairedAt, updated_at = SYSUTCDATETIME()
SET token = @token, paired_at = @pairedAt, clientserial = @clientserial, clientversion = @clientversion, pairingpin = NULL, lastseen_at = @pairedAt, updated_at = SYSUTCDATETIME()
WHERE id = @id
`;
@@ -75,7 +75,7 @@ VALUES (@companyId, @name, @token, @pairingpin, @pairedAt, @clientserial, @maxkn
export const UPDATE = `
UPDATE posterminal
SET name = @name, token = @token, pairingpin = @pairingpin, paired_at = @pairedAt, clientserial = @clientserial, maxknownobituaryid = @maxknownobituaryid, root_category_id = @rootCategoryId, sync_root_articles = @syncRootArticles, lastseen_at = @lastseenAt, sort = @sort, enabled = @enabled, updated_at = SYSUTCDATETIME()
SET name = @name, token = @token, pairingpin = @pairingpin, paired_at = @pairedAt, clientserial = @clientserial, maxknownobituaryid = @maxknownobituaryid, root_category_id = @rootCategoryId, sync_root_articles = @syncRootArticles, lastseen_at = @lastseenAt, sort = @sort, enabled = @enabled, clientversion = @clientversion, updated_at = SYSUTCDATETIME()
WHERE id = @id AND company_id = @companyId
`;

View File

@@ -13,15 +13,18 @@ export default function pair(provider) {
* @param {string} input.token - The auth token for the paired device.
* @param {string} [input.clientserial] - The client name or serial identifier.
* @param {string} [input.pairedAt] - Timestamp when paired.
* @param {string|null} [input.clientversion] - Client software version reported by the POS device during pairing.
* @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<{id: number, token: string, clientserial: string|null, pairedAt: string|null}>}
* @returns {Promise<{id: number, token: string, clientserial: string|null, pairedAt: string|null, clientversion: string|null}>}
*/
return async (id, { token, clientserial, pairedAt }, tx) => {
return async (id, { token, clientserial, pairedAt, clientversion }, tx) => {
const versionVal = clientversion ? String(clientversion).trim() : null;
await makeRunner(provider, tx).query(sql, {
id,
token,
clientserial: clientserial ?? null,
pairedAt: pairedAt ?? null,
clientversion: versionVal,
});
return {
@@ -29,6 +32,7 @@ export default function pair(provider) {
token,
clientserial: clientserial ?? null,
pairedAt: pairedAt ?? null,
clientversion: versionVal,
};
};
}

View File

@@ -76,6 +76,7 @@ export default function upsert(provider) {
const sort = input.sort !== undefined ? input.sort : existing.rows[0].sort;
const enabled = input.enabled !== undefined ? (input.enabled ? 1 : 0) : (existing.rows[0].enabled ? 1 : 0);
const clientversion = input.clientversion !== undefined ? (input.clientversion ? String(input.clientversion).trim() : null) : (existing.rows[0].clientversion ?? null);
const pairingpin =
input.pairingpin !== undefined
@@ -116,6 +117,7 @@ export default function upsert(provider) {
lastseenAt,
sort,
enabled,
clientversion,
});
return {
@@ -131,7 +133,7 @@ export default function upsert(provider) {
lastseenAt,
sort,
enabled,
clientversion: existing.rows[0].clientversion ?? null,
clientversion,
};
}