Browse Source

fix all the lint warnings

search-bbox
Trent Larson 1 year ago
parent
commit
4b9cbd0e9f
  1. 31
      src/libs/endorserServer.ts
  2. 1
      src/router/index.ts
  3. 2
      src/views/AccountViewView.vue
  4. 1
      src/views/ContactAmountsView.vue
  5. 15
      src/views/ContactGiftingView.vue
  6. 2
      src/views/DiscoverView.vue
  7. 28
      src/views/HomeView.vue
  8. 3
      src/views/NewEditProjectView.vue
  9. 33
      src/views/ProjectViewView.vue
  10. 14
      src/views/ProjectsView.vue

31
src/libs/endorserServer.ts

@ -65,6 +65,29 @@ export interface GiveVerifiableCredential {
recipient?: { identifier: string };
}
export interface PlanVerifiableCredential {
"@context": "https://schema.org";
"@type": "PlanAction";
name: string;
description: string;
identifier?: string;
location?: {
geo: { "@type": "GeoCoordinates"; latitude: number; longitude: number };
};
}
export interface PlanServerRecord {
agentDid?: string; // optional, if the issuer wants someone else to manage as well
description: string;
endTime?: string;
issuerDid: string;
handleId: string;
locLat?: number;
locLon?: number;
startTime?: string;
url?: string;
}
export interface RegisterVerifiableCredential {
"@context": string;
"@type": string;
@ -112,7 +135,11 @@ export function didInfo(
}
}
export interface SuccessResult {
export interface ResultWithType {
type: string;
}
export interface SuccessResult extends ResultWithType {
type: "success";
response: AxiosResponse<ClaimResult>;
}
@ -242,7 +269,7 @@ export async function createAndSubmitGive(
type: "error",
error: {
error: errorMessage,
userMessage: "Failed to create and submit the claim",
userMessage: "Failed to create and submit the claim.",
},
};
}

1
src/router/index.ts

@ -201,6 +201,7 @@ const router = createRouter({
});
const errorHandler = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any,
to: RouteLocationNormalized,
from: RouteLocationNormalized,

2
src/views/AccountViewView.vue

@ -414,6 +414,7 @@ export default class AccountViewView extends Vue {
});
this.checkLimitsFor(identity);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
if (
err.message ===
@ -517,6 +518,7 @@ export default class AccountViewView extends Vue {
if (resp.status === 200) {
this.limits = resp.data;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (
error.message ===

1
src/views/ContactAmountsView.vue

@ -172,6 +172,7 @@ export default class ContactsView extends Vue {
if (this.activeDid && this.contact) {
this.loadGives(this.activeDid, this.contact);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
this.$notify(
{

15
src/views/ContactGiftingView.vue

@ -154,6 +154,7 @@ export default class HomeView extends Vue {
this.apiServer = settings?.apiServer || "";
this.activeDid = settings?.activeDid || "";
this.allContacts = await db.contacts.toArray();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
this.$notify(
{
@ -261,16 +262,20 @@ export default class HomeView extends Vue {
-1,
);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.log("Error with give caught:", error);
const message =
error.userMessage ||
error.response?.data?.error?.message ||
"There was an error recording the Give.";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
this.getGiveErrorMessage(error) ||
"There was an error recording the give.",
text: message,
},
-1,
);
@ -286,9 +291,5 @@ export default class HomeView extends Vue {
getGiveCreationErrorMessage(result: CreateAndSubmitGiveResult) {
return (result as ErrorResult).error?.userMessage;
}
getGiveErrorMessage(error: any) {
return error.userMessage || error.response?.data?.error?.message;
}
}
</script>

2
src/views/DiscoverView.vue

@ -337,6 +337,7 @@ export default class DiscoverView extends Vue {
} else {
throw JSON.stringify(results);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.log("Error with feed load:", e);
this.$notify(
@ -415,6 +416,7 @@ export default class DiscoverView extends Vue {
} else {
throw JSON.stringify(results);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.log("Error with feed load:", e);
this.$notify(

28
src/views/HomeView.vue

@ -284,6 +284,7 @@ export default class HomeView extends Vue {
this.allContacts = await db.contacts.toArray();
this.feedLastViewedId = settings?.lastViewedClaimId;
this.updateAllFeed();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
this.$notify(
{
@ -384,12 +385,11 @@ export default class HomeView extends Vue {
}
giveDescription(giveRecord: GiveServerRecord) {
let claim = giveRecord.fullClaim;
if ((claim as any).claim) {
// can happen for some claims wrapped in a Verifiable Credential
claim = (claim as any).claim;
}
// claim.claim happen for some claims wrapped in a Verifiable Credential
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const claim = (giveRecord.fullClaim as any).claim || giveRecord.fullClaim;
// agent.did is for legacy data, before March 2023
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const giverDid = claim.agent?.identifier || (claim.agent as any)?.did;
const giverInfo = didInfo(
giverDid,
@ -402,6 +402,7 @@ export default class HomeView extends Vue {
: claim.description || "something unknown";
// recipient.did is for legacy data, before March 2023
const gaveRecipientId =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
claim.recipient?.identifier || (claim.recipient as any)?.did;
const gaveRecipientInfo = gaveRecipientId
? " to " +
@ -515,16 +516,19 @@ export default class HomeView extends Vue {
-1,
);
}
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.log("Error with give caught:", error);
const message =
error.userMessage ||
error.response?.data?.error?.message ||
"There was an error recording the give.";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
this.getGiveErrorMessage(error) ||
"There was an error recording the give.",
text: message,
},
-1,
);
@ -533,16 +537,14 @@ export default class HomeView extends Vue {
// Helper functions for readability
// eslint-disable-next-line @typescript-eslint/no-explicit-any
isGiveCreationError(result: any) {
return result.status !== 201 || result.data?.error;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getGiveCreationErrorMessage(result: any) {
return result.data?.error?.message;
}
getGiveErrorMessage(error: any) {
return error.userMessage || error.response?.data?.error?.message;
}
}
</script>

3
src/views/NewEditProjectView.vue

@ -112,6 +112,7 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { accessToken, SimpleSigner } from "@/libs/crypto";
import { useAppStore } from "@/store/app";
import { IIdentifier } from "@veramo/core";
import { PlanVerifiableCredential } from "@/libs/endorserServer";
interface Notification {
group: string;
@ -217,7 +218,7 @@ export default class NewEditProjectView extends Vue {
private async SaveProject(identity: IIdentifier) {
// Make a claim
const vcClaim: any = {
const vcClaim: PlanVerifiableCredential = {
"@context": "https://schema.org",
"@type": "PlanAction",
name: this.projectName,

33
src/views/ProjectViewView.vue

@ -220,6 +220,7 @@ import {
GiverInputInfo,
GiverOutputInfo,
GiveServerRecord,
ResultWithType,
} from "@/libs/endorserServer";
import QuickNav from "@/components/QuickNav.vue";
import EntityIcon from "@/components/EntityIcon.vue";
@ -547,22 +548,26 @@ export default class ProjectViewView extends Vue {
},
-1,
);
} else if (result.type == "error") {
console.log("Error with give result:", result);
if ("data" in result) {
const data: any = result.data;
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
data?.error?.message ||
"There was an error recording the give.",
},
-1,
} else {
console.log("Error with give creation:", result);
if (result.type != "error") {
console.log(
"... and it has an unexpected result type of",
(result as ResultWithType).type,
);
}
const message =
result?.error?.userMessage ||
"There was an error recording the Give.";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: message,
},
-1,
);
}
}
}

14
src/views/ProjectsView.vue

@ -129,16 +129,26 @@ export default class ProjectsView extends Vue {
}
} else {
console.log("Bad server response & data:", resp.status, resp.data);
throw Error("Failed to get projects from the server.");
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "Failed to get projects from the server. Try again later.",
},
-1,
);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.error("Got error loading projects:", error.message);
const additional = error.message ? " " + error.message : "";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "Got an error loading projects: " + error.message,
text: "Got an error loading projects." + additional,
},
-1,
);

Loading…
Cancel
Save