Skip to content

Commit

Permalink
web: Upgrade Rest Hooks to v5
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Feb 4, 2021
1 parent ea00397 commit f7eedc1
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 32 deletions.
54 changes: 40 additions & 14 deletions airbyte-webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions airbyte-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@hot-loader/react-dom": "16.13.0",
"@papercups-io/chat-widget": "^1.1.5",
"@papercups-io/storytime": "^1.0.6",
"@rest-hooks/legacy": "^1.0.12",
"@rest-hooks/legacy": "^2.0.1",
"dayjs": "^1.8.35",
"formik": "2.1.5",
"lodash.at": "^4.6.0",
Expand All @@ -36,7 +36,7 @@
"react-router-dom": "^5.1.2",
"react-table": "^7.5.0",
"react-widgets": "^4.5.0",
"rest-hooks": "^4.5.9",
"rest-hooks": "^5.0.3",
"sanitize-html": "^2.1.2",
"styled-components": "^5.1.1",
"yup": "^0.28.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useDestinationDefinitionSpecificationLoad = (
? {
destinationDefinitionId
}
: undefined
: null
);

return { destinationDefinitionSpecification, error, isLoading };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useSourceDefinitionSpecificationLoad = (
? {
sourceDefinitionId
}
: undefined
: null
);

return { sourceDefinitionSpecification, error, isLoading };
Expand Down
41 changes: 30 additions & 11 deletions airbyte-webapp/src/core/resources/BaseResource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Method, Resource } from "rest-hooks";
import {
Method,
MutateShape,
Resource,
AbstractInstanceType,
ReadShape,
schemas,
SchemaDetail,
SchemaList
} from "rest-hooks";

// import { authService } from "../auth/authService";
import config from "../../config";
Expand Down Expand Up @@ -62,9 +71,11 @@ export default abstract class BaseResource extends Resource {
return config.apiUrl;
}

static listShape<T extends typeof Resource>(this: T) {
static listShape<T extends typeof Resource>(
this: T
): ReadShape<SchemaList<AbstractInstanceType<T>>> {
return {
...super.listShape(),
...(super.listShape() as any),
getFetchKey: (params: any) =>
"POST " + this.url(params) + "/list" + JSON.stringify(params),
fetch: async (
Expand All @@ -80,9 +91,11 @@ export default abstract class BaseResource extends Resource {
};
}

static detailShape<T extends typeof Resource>(this: T) {
static detailShape<T extends typeof Resource>(
this: T
): ReadShape<SchemaDetail<AbstractInstanceType<T>>> {
return {
...super.detailShape(),
...(super.detailShape() as any),
getFetchKey: (params: any) =>
"POST " + this.url(params) + "/get" + JSON.stringify(params),
fetch: async (
Expand All @@ -98,9 +111,11 @@ export default abstract class BaseResource extends Resource {
};
}

static createShape<T extends typeof Resource>(this: T) {
static createShape<T extends typeof Resource>(
this: T
): MutateShape<SchemaDetail<AbstractInstanceType<T>>> {
return {
...super.createShape(),
...(super.createShape() as any),
getFetchKey: (params: any) =>
"POST " + this.url(params) + "/create" + JSON.stringify(params),
fetch: async (
Expand All @@ -117,9 +132,11 @@ export default abstract class BaseResource extends Resource {
};
}

static deleteShape<T extends typeof Resource>(this: T) {
static deleteShape<T extends typeof Resource>(
this: T
): MutateShape<schemas.Delete<T>, Readonly<object>, unknown> {
return {
...super.deleteShape(),
...(super.deleteShape() as any),
getFetchKey: (params: any) =>
"POST " + this.url(params) + "/delete" + JSON.stringify(params),
fetch: async (
Expand All @@ -135,9 +152,11 @@ export default abstract class BaseResource extends Resource {
};
}

static partialUpdateShape<T extends typeof Resource>(this: T) {
static partialUpdateShape<T extends typeof Resource>(
this: T
): MutateShape<SchemaDetail<AbstractInstanceType<T>>> {
return {
...super.partialUpdateShape(),
...(super.partialUpdateShape() as any),
getFetchKey: (params: any) =>
"POST " + this.url(params) + "/partial-update" + JSON.stringify(params),
fetch: async (
Expand Down
1 change: 1 addition & 0 deletions airbyte-webapp/src/core/resources/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class ConnectionResource extends BaseResource
readonly sourceId: string = "";
readonly destinationId: string = "";
readonly status: string = "";
readonly message: string = "";
readonly schedule: ScheduleProperties | null = null;
readonly source: SourceInformation | undefined = undefined;
readonly destination: DestinationInformation | undefined = undefined;
Expand Down
4 changes: 2 additions & 2 deletions airbyte-webapp/src/core/resources/Deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class DeploymentResource extends BaseResource
file
};
},
schema: {}
schema: { file: "" }
};
}

Expand Down Expand Up @@ -67,7 +67,7 @@ export default class DeploymentResource extends BaseResource
);
return response;
},
schema: {}
schema: null
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import DestinationForm from "./components/DestinationForm";
import ConnectionBlock from "../../../../components/ConnectionBlock";
import { Routes } from "../../../routes";
import CreateConnectionContent from "../../../../components/CreateConnectionContent";
import { useResource } from "rest-hooks/lib/react-integration/hooks";
import { useResource } from "rest-hooks";
import SourceResource from "../../../../core/resources/Source";
import DestinationResource from "../../../../core/resources/Destination";

Expand Down

0 comments on commit f7eedc1

Please sign in to comment.