feat(pda): connect online picking workflow
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
function hash32(value, seed) {
|
||||
let hash = seed >>> 0
|
||||
for (let index = 0; index < value.length; index += 1) {
|
||||
hash ^= value.charCodeAt(index)
|
||||
hash = Math.imul(hash, 0x01000193) >>> 0
|
||||
}
|
||||
return hash.toString(16).padStart(8, '0')
|
||||
}
|
||||
|
||||
export function shortStableHash(value) {
|
||||
const input = String(value ?? '')
|
||||
return `${hash32(input, 0x811c9dc5)}${hash32(input, 0x9e3779b9)}`
|
||||
}
|
||||
|
||||
export function stableOperationId(scope, identity, payload) {
|
||||
const safeScope = String(scope || 'operation').replace(/[^A-Za-z0-9_-]/g, '-').slice(0, 24)
|
||||
const safeIdentity = String(identity || 'unknown').replace(/[^A-Za-z0-9_-]/g, '-').slice(0, 48)
|
||||
return `${safeScope}-${safeIdentity}-${shortStableHash(JSON.stringify(payload ?? null))}`.slice(0, 120)
|
||||
}
|
||||
Reference in New Issue
Block a user