feat(striker-ui-api): add getAnvilData to accessModule

main
Tsu-ba-me 2 years ago
parent 0284434815
commit 5a9f936913
  1. 17
      striker-ui-api/src/lib/accessModule.ts
  2. 3
      striker-ui-api/src/types/AnvilDataStruct.d.ts
  3. 3
      striker-ui-api/src/types/GetAnvilDataOptions.d.ts

@ -19,7 +19,7 @@ const execAnvilAccessModule = (
throw error;
}
if (stderr) {
if (stderr.length > 0) {
throw new Error(stderr.toString());
}
@ -122,6 +122,20 @@ const dbSubRefreshTimestamp = () =>
const dbWrite = (query: string, options?: SpawnSyncOptions) =>
execAnvilAccessModule(['--query', query, '--mode', 'write'], options);
const getAnvilData = (
dataStruct: AnvilDataStruct,
{ predata, ...spawnSyncOptions }: GetAnvilDataOptions = {},
) =>
execAnvilAccessModule(
[
'--predata',
JSON.stringify(predata),
'--data',
JSON.stringify(dataStruct),
],
spawnSyncOptions,
).stdout;
const getLocalHostUUID = () =>
execModuleSubroutine('host_uuid', {
subModuleName: 'Get',
@ -132,6 +146,7 @@ export {
dbQuery,
dbSubRefreshTimestamp,
dbWrite,
getAnvilData,
getLocalHostUUID,
execModuleSubroutine as sub,
};

@ -0,0 +1,3 @@
interface AnvilDataStruct {
[key: string]: AnvilDataStruct | boolean;
}

@ -0,0 +1,3 @@
type GetAnvilDataOptions = import('child_process').SpawnSyncOptions & {
predata?: Array<[string, ...unknown[]]>;
};
Loading…
Cancel
Save