|
|
@ -128,7 +128,7 @@ class Access extends EventEmitter { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
shvar({ scriptId, script }); |
|
|
|
shvar({ scriptId, script }, 'Access interact: '); |
|
|
|
|
|
|
|
|
|
|
|
this.queue.push(scriptId); |
|
|
|
this.queue.push(scriptId); |
|
|
|
stdin?.write(script); |
|
|
|
stdin?.write(script); |
|
|
@ -139,6 +139,36 @@ class Access extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
const access = new Access(); |
|
|
|
const access = new Access(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const data = async <T>(...keys: string[]) => |
|
|
|
|
|
|
|
access.interact<T>('x', `data->${keys.join('->')}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const subroutine = <T extends Record<string, unknown>>( |
|
|
|
|
|
|
|
subroutine: string, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
params = [], |
|
|
|
|
|
|
|
pre = ['Database'], |
|
|
|
|
|
|
|
}: { |
|
|
|
|
|
|
|
params?: unknown[]; |
|
|
|
|
|
|
|
pre?: string[]; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) => { |
|
|
|
|
|
|
|
const chain = `${pre.join('->')}->${subroutine}`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const subParams: string[] = params.map<string>((p) => { |
|
|
|
|
|
|
|
let result: string; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
result = JSON.stringify(p); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
result = String(p); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return access.interact<T>('x', chain, ...subParams); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const query = <T extends (number | null | string)[][]>(script: string) => |
|
|
|
const query = <T extends (number | null | string)[][]>(script: string) => |
|
|
|
access.interact<T>('r', formatSql(script)); |
|
|
|
access.interact<T>('r', formatSql(script)); |
|
|
|
|
|
|
|
|
|
|
@ -366,6 +396,8 @@ export { |
|
|
|
getLocalHostName, |
|
|
|
getLocalHostName, |
|
|
|
getLocalHostUUID, |
|
|
|
getLocalHostUUID, |
|
|
|
getPeerData, |
|
|
|
getPeerData, |
|
|
|
|
|
|
|
data, |
|
|
|
query, |
|
|
|
query, |
|
|
|
|
|
|
|
subroutine, |
|
|
|
write, |
|
|
|
write, |
|
|
|
}; |
|
|
|
}; |
|
|
|