u
This commit is contained in:
@@ -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
|
||||
`;
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user