anastasis-core: type naming consistency

This commit is contained in:
Florian Dold 2021-11-04 16:25:02 +01:00
parent 4ac0b23793
commit 83622bd65a
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 40 additions and 40 deletions

View File

@ -27,15 +27,15 @@ import {
TruthUploadRequest, TruthUploadRequest,
} from "./provider-types.js"; } from "./provider-types.js";
import { import {
ActionArgAddAuthentication, ActionArgsAddAuthentication,
ActionArgDeleteAuthentication, ActionArgsDeleteAuthentication,
ActionArgDeletePolicy, ActionArgsDeletePolicy,
ActionArgEnterSecret, ActionArgsEnterSecret,
ActionArgEnterSecretName, ActionArgsEnterSecretName,
ActionArgEnterUserAttributes, ActionArgsEnterUserAttributes,
ActionArgsAddPolicy, ActionArgsAddPolicy,
ActionArgSelectContinent, ActionArgsSelectContinent,
ActionArgSelectCountry, ActionArgsSelectCountry,
ActionArgsSelectChallenge, ActionArgsSelectChallenge,
ActionArgsSolveChallengeRequest, ActionArgsSolveChallengeRequest,
ActionArgsUpdateExpiration, ActionArgsUpdateExpiration,
@ -43,9 +43,9 @@ import {
AuthenticationProviderStatusOk, AuthenticationProviderStatusOk,
AuthMethod, AuthMethod,
BackupStates, BackupStates,
codecForActionArgEnterUserAttributes, codecForActionArgsEnterUserAttributes,
codecForActionArgsAddPolicy, codecForActionArgsAddPolicy,
codecForActionArgSelectChallenge, codecForActionArgsSelectChallenge,
codecForActionArgSelectContinent, codecForActionArgSelectContinent,
codecForActionArgSelectCountry, codecForActionArgSelectCountry,
codecForActionArgsUpdateExpiration, codecForActionArgsUpdateExpiration,
@ -168,7 +168,7 @@ export async function getRecoveryStartState(): Promise<ReducerStateRecovery> {
async function selectCountry( async function selectCountry(
selectedContinent: string, selectedContinent: string,
args: ActionArgSelectCountry, args: ActionArgsSelectCountry,
): Promise<Partial<ReducerStateBackup> & Partial<ReducerStateRecovery>> { ): Promise<Partial<ReducerStateBackup> & Partial<ReducerStateRecovery>> {
const countryCode = args.country_code; const countryCode = args.country_code;
const currencies = args.currencies; const currencies = args.currencies;
@ -209,7 +209,7 @@ async function selectCountry(
async function backupSelectCountry( async function backupSelectCountry(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgSelectCountry, args: ActionArgsSelectCountry,
): Promise<ReducerStateError | ReducerStateBackup> { ): Promise<ReducerStateError | ReducerStateBackup> {
return { return {
...state, ...state,
@ -220,7 +220,7 @@ async function backupSelectCountry(
async function recoverySelectCountry( async function recoverySelectCountry(
state: ReducerStateRecovery, state: ReducerStateRecovery,
args: ActionArgSelectCountry, args: ActionArgsSelectCountry,
): Promise<ReducerStateError | ReducerStateRecovery> { ): Promise<ReducerStateError | ReducerStateRecovery> {
return { return {
...state, ...state,
@ -275,7 +275,7 @@ async function getProviderInfo(
async function backupEnterUserAttributes( async function backupEnterUserAttributes(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgEnterUserAttributes, args: ActionArgsEnterUserAttributes,
): Promise<ReducerStateBackup> { ): Promise<ReducerStateBackup> {
const attributes = args.identity_attributes; const attributes = args.identity_attributes;
const providerUrls = Object.keys(state.authentication_providers ?? {}); const providerUrls = Object.keys(state.authentication_providers ?? {});
@ -787,7 +787,7 @@ async function solveChallenge(
async function recoveryEnterUserAttributes( async function recoveryEnterUserAttributes(
state: ReducerStateRecovery, state: ReducerStateRecovery,
args: ActionArgEnterUserAttributes, args: ActionArgsEnterUserAttributes,
): Promise<ReducerStateRecovery | ReducerStateError> { ): Promise<ReducerStateRecovery | ReducerStateError> {
// FIXME: validate attributes // FIXME: validate attributes
const st: ReducerStateRecovery = { const st: ReducerStateRecovery = {
@ -812,7 +812,7 @@ async function selectChallenge(
async function backupSelectContinent( async function backupSelectContinent(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgSelectContinent, args: ActionArgsSelectContinent,
): Promise<ReducerStateBackup | ReducerStateError> { ): Promise<ReducerStateBackup | ReducerStateError> {
const countries = getCountries(args.continent); const countries = getCountries(args.continent);
if (countries.length <= 0) { if (countries.length <= 0) {
@ -831,7 +831,7 @@ async function backupSelectContinent(
async function recoverySelectContinent( async function recoverySelectContinent(
state: ReducerStateRecovery, state: ReducerStateRecovery,
args: ActionArgSelectContinent, args: ActionArgsSelectContinent,
): Promise<ReducerStateRecovery | ReducerStateError> { ): Promise<ReducerStateRecovery | ReducerStateError> {
const countries = getCountries(args.continent); const countries = getCountries(args.continent);
return { return {
@ -890,7 +890,7 @@ function transitionRecoveryJump(
async function addAuthentication( async function addAuthentication(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgAddAuthentication, args: ActionArgsAddAuthentication,
): Promise<ReducerStateBackup> { ): Promise<ReducerStateBackup> {
return { return {
...state, ...state,
@ -903,7 +903,7 @@ async function addAuthentication(
async function deleteAuthentication( async function deleteAuthentication(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgDeleteAuthentication, args: ActionArgsDeleteAuthentication,
): Promise<ReducerStateBackup> { ): Promise<ReducerStateBackup> {
const m = state.authentication_methods ?? []; const m = state.authentication_methods ?? [];
m.splice(args.authentication_method, 1); m.splice(args.authentication_method, 1);
@ -915,7 +915,7 @@ async function deleteAuthentication(
async function deletePolicy( async function deletePolicy(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgDeletePolicy, args: ActionArgsDeletePolicy,
): Promise<ReducerStateBackup> { ): Promise<ReducerStateBackup> {
const policies = [...(state.policies ?? [])]; const policies = [...(state.policies ?? [])];
policies.splice(args.policy_index, 1); policies.splice(args.policy_index, 1);
@ -1020,7 +1020,7 @@ async function updateUploadFees(
async function enterSecret( async function enterSecret(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgEnterSecret, args: ActionArgsEnterSecret,
): Promise<ReducerStateBackup | ReducerStateError> { ): Promise<ReducerStateBackup | ReducerStateError> {
return updateUploadFees({ return updateUploadFees({
...state, ...state,
@ -1048,7 +1048,7 @@ async function nextFromChallengeSelecting(
async function enterSecretName( async function enterSecretName(
state: ReducerStateBackup, state: ReducerStateBackup,
args: ActionArgEnterSecretName, args: ActionArgsEnterSecretName,
): Promise<ReducerStateBackup | ReducerStateError> { ): Promise<ReducerStateBackup | ReducerStateError> {
return { return {
...state, ...state,
@ -1094,7 +1094,7 @@ const backupTransitions: Record<
...transitionBackupJump("back", BackupStates.CountrySelecting), ...transitionBackupJump("back", BackupStates.CountrySelecting),
...transition( ...transition(
"enter_user_attributes", "enter_user_attributes",
codecForActionArgEnterUserAttributes(), codecForActionArgsEnterUserAttributes(),
backupEnterUserAttributes, backupEnterUserAttributes,
), ),
}, },
@ -1157,7 +1157,7 @@ const recoveryTransitions: Record<
...transitionRecoveryJump("back", RecoveryStates.CountrySelecting), ...transitionRecoveryJump("back", RecoveryStates.CountrySelecting),
...transition( ...transition(
"enter_user_attributes", "enter_user_attributes",
codecForActionArgEnterUserAttributes(), codecForActionArgsEnterUserAttributes(),
recoveryEnterUserAttributes, recoveryEnterUserAttributes,
), ),
}, },
@ -1169,7 +1169,7 @@ const recoveryTransitions: Record<
...transitionRecoveryJump("back", RecoveryStates.SecretSelecting), ...transitionRecoveryJump("back", RecoveryStates.SecretSelecting),
...transition( ...transition(
"select_challenge", "select_challenge",
codecForActionArgSelectChallenge(), codecForActionArgsSelectChallenge(),
selectChallenge, selectChallenge,
), ),
...transition("next", codecForAny(), nextFromChallengeSelecting), ...transition("next", codecForAny(), nextFromChallengeSelecting),

View File

@ -256,16 +256,16 @@ export interface ReducerStateBackupUserAttributesCollecting
authentication_providers: { [url: string]: AuthenticationProviderStatus }; authentication_providers: { [url: string]: AuthenticationProviderStatus };
} }
export interface ActionArgEnterUserAttributes { export interface ActionArgsEnterUserAttributes {
identity_attributes: Record<string, string>; identity_attributes: Record<string, string>;
} }
export const codecForActionArgEnterUserAttributes = () => export const codecForActionArgsEnterUserAttributes = () =>
buildCodecForObject<ActionArgEnterUserAttributes>() buildCodecForObject<ActionArgsEnterUserAttributes>()
.property("identity_attributes", codecForAny()) .property("identity_attributes", codecForAny())
.build("ActionArgEnterUserAttributes"); .build("ActionArgsEnterUserAttributes");
export interface ActionArgAddAuthentication { export interface ActionArgsAddAuthentication {
authentication_method: { authentication_method: {
type: string; type: string;
instructions: string; instructions: string;
@ -274,19 +274,19 @@ export interface ActionArgAddAuthentication {
}; };
} }
export interface ActionArgDeleteAuthentication { export interface ActionArgsDeleteAuthentication {
authentication_method: number; authentication_method: number;
} }
export interface ActionArgDeletePolicy { export interface ActionArgsDeletePolicy {
policy_index: number; policy_index: number;
} }
export interface ActionArgEnterSecretName { export interface ActionArgsEnterSecretName {
name: string; name: string;
} }
export interface ActionArgEnterSecret { export interface ActionArgsEnterSecret {
secret: { secret: {
value: string; value: string;
mime?: string; mime?: string;
@ -294,16 +294,16 @@ export interface ActionArgEnterSecret {
expiration: Timestamp; expiration: Timestamp;
} }
export interface ActionArgSelectContinent { export interface ActionArgsSelectContinent {
continent: string; continent: string;
} }
export const codecForActionArgSelectContinent = () => export const codecForActionArgSelectContinent = () =>
buildCodecForObject<ActionArgSelectContinent>() buildCodecForObject<ActionArgsSelectContinent>()
.property("continent", codecForString()) .property("continent", codecForString())
.build("ActionArgSelectContinent"); .build("ActionArgSelectContinent");
export interface ActionArgSelectCountry { export interface ActionArgsSelectCountry {
country_code: string; country_code: string;
currencies: string[]; currencies: string[];
} }
@ -347,13 +347,13 @@ export const codecForActionArgsUpdateExpiration = () =>
.property("expiration", codecForTimestamp) .property("expiration", codecForTimestamp)
.build("ActionArgsUpdateExpiration"); .build("ActionArgsUpdateExpiration");
export const codecForActionArgSelectChallenge = () => export const codecForActionArgsSelectChallenge = () =>
buildCodecForObject<ActionArgsSelectChallenge>() buildCodecForObject<ActionArgsSelectChallenge>()
.property("uuid", codecForString()) .property("uuid", codecForString())
.build("ActionArgSelectChallenge"); .build("ActionArgsSelectChallenge");
export const codecForActionArgSelectCountry = () => export const codecForActionArgSelectCountry = () =>
buildCodecForObject<ActionArgSelectCountry>() buildCodecForObject<ActionArgsSelectCountry>()
.property("country_code", codecForString()) .property("country_code", codecForString())
.property("currencies", codecForList(codecForString())) .property("currencies", codecForList(codecForString()))
.build("ActionArgSelectCountry"); .build("ActionArgSelectCountry");