Skip to content

Commit

Permalink
chore: updated types
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanjassal committed Aug 26, 2024
1 parent ef9032e commit c2723ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
16 changes: 8 additions & 8 deletions src/client/handlers/VaultsSecretsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
SecretFilesMessage,
SecretFiles,
SecretIdentifierMessage,
} from '../types';
import type VaultManager from '../../vaults/VaultManager';
import path from 'path';
Expand All @@ -17,13 +17,13 @@ class VaultsSecretsList extends ServerHandler<
vaultManager: VaultManager;
db: DB;
},
ClientRPCRequestParams<SecretFilesMessage>,
ClientRPCResponseResult<SecretFiles>
ClientRPCRequestParams<SecretIdentifierMessage>,
ClientRPCResponseResult<SecretFilesMessage>
> {
public async *handle(
input: ClientRPCRequestParams<SecretFilesMessage>,
input: ClientRPCRequestParams<SecretIdentifierMessage>,
_cancel: any,
): AsyncGenerator<ClientRPCResponseResult<SecretFiles>, void, void> {
): AsyncGenerator<ClientRPCResponseResult<SecretFilesMessage>, void, void> {
const { vaultManager, db } = this.container;
const vaultId = await db.withTransactionF(async (tran) => {
const vaultIdFromName = await vaultManager.getVaultId(
Expand All @@ -38,7 +38,7 @@ class VaultsSecretsList extends ServerHandler<

yield* vaultManager.withVaultsG([vaultId], (vault) => {
return vault.readG(async function* (fs): AsyncGenerator<
SecretFiles,
SecretFilesMessage,
void,
void
> {
Expand All @@ -48,11 +48,11 @@ class VaultsSecretsList extends ServerHandler<
files = await fs.promises.readdir(input.path);
} catch (e) {
throw new clientErrors.ErrorClientFSReadFailed(
`No matches exist for path: ${input.path}`,
`No matches exist for path: ${input.secretPath}`,
{ cause: e },
);
}
files = files.map((file) => path.join(input.path, file));
files = files.map((file) => path.join(input.secretPath, file));

for await (const file of files) {
const stat = await fs.promises.stat(file);
Expand Down
17 changes: 6 additions & 11 deletions src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,11 @@ type VaultsLatestVersionMessage = {
};

// Secrets
type SecretFilesMessage = VaultIdentifierMessage & {
path: string;
};

type SecretNameMessage = {
secretName: string;
type SecretPathMessage = {
secretPath: string;
};

type SecretIdentifierMessage = VaultIdentifierMessage & SecretNameMessage;
type SecretIdentifierMessage = VaultIdentifierMessage & SecretPathMessage;

// Contains binary content as a binary string 'toString('binary')'
type ContentMessage = {
Expand All @@ -330,7 +326,7 @@ type SecretRenameMessage = SecretIdentifierMessage & {
newSecretName: string;
};

type SecretFiles = {
type SecretFilesMessage = {
path: string;
type: 'FILE' | 'DIRECTORY';
};
Expand Down Expand Up @@ -418,15 +414,14 @@ export type {
VaultsScanMessage,
VaultsVersionMessage,
VaultsLatestVersionMessage,
SecretNameMessage,
SecretPathMessage,
SecretIdentifierMessage,
SecretFilesMessage,
ContentMessage,
SecretContentMessage,
SecretMkdirMessage,
SecretDirMessage,
SecretRenameMessage,
SecretFiles,
SecretFilesMessage,
SecretStatMessage,
SignatureMessage,
OverrideRPClientType,
Expand Down

0 comments on commit c2723ac

Please sign in to comment.