diff --git a/components/dataproducts/access/datasetAccess.tsx b/components/dataproducts/access/datasetAccess.tsx index e152b435..6040b85e 100644 --- a/components/dataproducts/access/datasetAccess.tsx +++ b/components/dataproducts/access/datasetAccess.tsx @@ -3,10 +3,8 @@ import { useState } from 'react' import { isAfter, parseISO, format } from 'date-fns' import { useRevokeAccessMutation, - useAccessRequestsForDatasetQuery, useApproveAccessRequestMutation, useDenyAccessRequestMutation, - useDatasetAccessQuery, } from '../../../lib/schema/graphql' import { Alert, @@ -17,11 +15,11 @@ import { Table, Textarea, } from '@navikt/ds-react' -import { GET_DATASET_ACCESS } from '../../../lib/queries/access/datasetAccess' import { ExternalLink } from '@navikt/ds-icons' -import { GET_ACCESS_REQUESTS_FOR_DATASET } from '../../../lib/queries/accessRequest/accessRequestsForDataset' import { nb } from 'date-fns/locale' import ErrorMessage from '../../lib/error' +import { useGetDataset } from '../../../lib/rest/dataproducts' +import { useFetchAccessRequestsForDataset } from '../../../lib/rest/access' interface AccessEntry { subject: string @@ -239,54 +237,36 @@ const DatasetAccess = ({ id }: AccessListProps) => { const [revokeAccess] = useRevokeAccessMutation() const [approveAccessRequest] = useApproveAccessRequestMutation() const [denyAccessRequest] = useDenyAccessRequestMutation() - const datasetAccessRequestsQuery = useAccessRequestsForDatasetQuery({ - variables: { datasetID: id }, - ssr: true, - }) + const fetchAccessRequestsForDataset = useFetchAccessRequestsForDataset(id) - const datasetAccessQuery = useDatasetAccessQuery({ - variables: { id }, - ssr: true, - }) + const getDataset = useGetDataset(id) - if (datasetAccessRequestsQuery.error) - return + if (fetchAccessRequestsForDataset.error) + return if ( - datasetAccessRequestsQuery.loading || - !datasetAccessRequestsQuery.data?.accessRequestsForDataset + fetchAccessRequestsForDataset.loading || + !fetchAccessRequestsForDataset.data?.accessRequests ) return
const datasetAccessRequests = - datasetAccessRequestsQuery.data?.accessRequestsForDataset + fetchAccessRequestsForDataset.data.accessRequests as any[] - if (datasetAccessQuery.error) - return + if (getDataset.error) + return if ( - datasetAccessQuery.loading || - !datasetAccessQuery.data?.dataset.access + getDataset.loading || + !getDataset?.dataset?.access ) return
- const access = datasetAccessQuery.data.dataset.access + const access = getDataset.dataset.access const approveRequest = async (requestID: string) => { try { await approveAccessRequest({ variables: { id: requestID }, refetchQueries: [ - { - query: GET_DATASET_ACCESS, - variables: { - id, - }, - }, - { - query: GET_ACCESS_REQUESTS_FOR_DATASET, - variables: { - datasetID: id, - }, - }, ], }) } catch (e: any) { @@ -299,12 +279,6 @@ const DatasetAccess = ({ id }: AccessListProps) => { await denyAccessRequest({ variables: { id: requestID }, refetchQueries: [ - { - query: GET_ACCESS_REQUESTS_FOR_DATASET, - variables: { - datasetID: id, - }, - }, ], }) } catch (e: any) { @@ -319,12 +293,6 @@ const DatasetAccess = ({ id }: AccessListProps) => { await revokeAccess({ variables: { id: a.id }, refetchQueries: [ - { - query: GET_DATASET_ACCESS, - variables: { - id, - }, - }, ], }) } catch (e: any) { diff --git a/components/dataproducts/accessRequest/accessRequestsListForOwner.tsx b/components/dataproducts/accessRequest/accessRequestsListForOwner.tsx index 487885ae..cdb3f506 100644 --- a/components/dataproducts/accessRequest/accessRequestsListForOwner.tsx +++ b/components/dataproducts/accessRequest/accessRequestsListForOwner.tsx @@ -1,23 +1,21 @@ import * as React from 'react' import { useState } from 'react' import { - AccessRequestsForDatasetQuery, useApproveAccessRequestMutation, } from '../../../lib/schema/graphql' import { Alert, Button, Table } from '@navikt/ds-react' import { useRouter } from 'next/router' interface AccessListProps { - accessQuery: AccessRequestsForDatasetQuery | undefined + accessRequests: any[] } -const AccessRequestsListForOwner = ({ accessQuery }: AccessListProps) => { - const access = accessQuery?.accessRequestsForDataset +const AccessRequestsListForOwner = ({ accessRequests }: AccessListProps) => { const [approveAccessRequest] = useApproveAccessRequestMutation() const [isDenying, setIsDenying] = useState>([]) const [formError, setFormError] = useState('') - if (access?.length === 0) { + if (accessRequests?.length === 0) { return <>Ingen har forespurt tilgang til produktet } @@ -52,7 +50,7 @@ const AccessRequestsListForOwner = ({ accessQuery }: AccessListProps) => { - {access?.map((a, i) => ( + {accessRequests?.map((a, i) => ( {a.subject} {a.expires} diff --git a/components/dataproducts/dataset/access/datasetAccessForOwner.tsx b/components/dataproducts/dataset/access/datasetAccessForOwner.tsx deleted file mode 100644 index e4f4085f..00000000 --- a/components/dataproducts/dataset/access/datasetAccessForOwner.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { ApolloError } from '@apollo/client' -import { Heading } from '@navikt/ds-react' -import * as React from 'react' -import { DatasetQuery } from '../../../../lib/schema/datasetQuery' -import { AccessRequestsForDatasetQuery } from '../../../../lib/schema/graphql' -import ErrorMessage from '../../../lib/error' -import LoaderSpinner from '../../../lib/spinner' -import AccessRequestsListForOwner from '../../accessRequest/accessRequestsListForOwner' - -interface AccessProps { - dataset: DatasetQuery - access: AccessRequestsForDatasetQuery | undefined - error: ApolloError | undefined - loading: boolean -} - -const DatasetAccess = ({ access, dataset, error, loading }: AccessProps) => { - if (error) return - if (loading || !access) return - - return ( -
- - Tilganger - - {access.accessRequestsForDataset.length > 0 && ( -
- - Søknader - - -
- )} -
- ) -} - -export default DatasetAccess diff --git a/components/dataproducts/dataset/access/datasetAccessForUser.tsx b/components/dataproducts/dataset/access/datasetAccessForUser.tsx deleted file mode 100644 index d96c9d80..00000000 --- a/components/dataproducts/dataset/access/datasetAccessForUser.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { ApolloError } from '@apollo/client' -import { Heading } from '@navikt/ds-react' -import * as React from 'react' -import humanizeDate from '../../../../lib/humanizeDate' -import { DatasetQuery } from '../../../../lib/schema/datasetQuery' -import { AccessRequestsForDatasetQuery } from '../../../../lib/schema/graphql' -import ErrorMessage from '../../../lib/error' -import LoaderSpinner from '../../../lib/spinner' - -interface AccessProps { - dataset: DatasetQuery - access: AccessRequestsForDatasetQuery | undefined - error: ApolloError | undefined - loading: boolean -} - -const DatasetAccess = ({ dataset, access, error, loading }: AccessProps) => { - if (error) return - if (loading || !access) return - - return ( -
- {access.accessRequestsForDataset.length > 0 && ( -
- - Tilganger - -
    - {access.accessRequestsForDataset.map((a) => ( -
  • {a.subject}
  • - ))} -
-
- )} - {dataset.access.length > 0 && ( -
- - Aktive tilganger - -
    - {dataset.access.map((a) => ( -
  • - {a.subject} - {a.expires ? ` (Gyldig til ${humanizeDate(a.expires)})` : ''} -
  • - ))} -
-
- )} -
- ) -} - -export default DatasetAccess diff --git a/components/dataproducts/dataset/useColumnTags.tsx b/components/dataproducts/dataset/useColumnTags.tsx index 3e8eb546..561ad07d 100644 --- a/components/dataproducts/dataset/useColumnTags.tsx +++ b/components/dataproducts/dataset/useColumnTags.tsx @@ -1,8 +1,8 @@ import { useState } from 'react' import { BigQueryType, - useGcpGetColumnsQuery, } from '../../../lib/schema/graphql' +import { useFetchBQcolumns } from '../../../lib/rest/bigquery' export type PIITagType = | 'PII_DirekteIdentifiserende' @@ -53,13 +53,7 @@ export const useColumnTags = ( new Map>() ) - const columnsQuery = useGcpGetColumnsQuery({ - variables: { - projectID: projectID, - datasetID: datasetID, - tableID: tableID, - }, - }) + const fetchColumns = useFetchBQcolumns(projectID, datasetID, tableID) var tableKey = buildTableKey(projectID, datasetID, tableID) @@ -69,9 +63,9 @@ export const useColumnTags = ( datasetID && tableID && !tagsMap.has(tableKey) && - !columnsQuery.error && - !columnsQuery.loading && - columnsQuery.data + !fetchColumns.error && + !fetchColumns.loading && + fetchColumns.bqColumns ) { var newTagsMap = new Map | undefined>( tagsMap @@ -81,7 +75,7 @@ export const useColumnTags = ( var newPseudoColumnsMap = new Map>(pseudoColumnsMap) var pseudoColumns = new Map() - columnsQuery.data.gcpGetColumns.forEach((it) =>{ + fetchColumns.bqColumns.forEach((it) =>{ tags.set( it.name, (!!tagsFromQuery[it.name] && @@ -126,11 +120,11 @@ export const useColumnTags = ( return { columns: - !columnsQuery.error && !columnsQuery.loading - ? (columnsQuery.data?.gcpGetColumns as ColumnType[]) + !fetchColumns.error && !fetchColumns.loading + ? (fetchColumns.bqColumns as ColumnType[]) : undefined, - loading: columnsQuery.loading, - error: columnsQuery.error, + loading: fetchColumns.loading, + error: fetchColumns.error, tags: tagsMap.get(tableKey), pseudoColumns: pseudoColumnsMap.get(tableKey) || new Map(), annotateColumn: annotateColumn, diff --git a/components/dataproducts/datasource/dataset.tsx b/components/dataproducts/datasource/dataset.tsx index aae7eacc..679bea74 100644 --- a/components/dataproducts/datasource/dataset.tsx +++ b/components/dataproducts/datasource/dataset.tsx @@ -1,7 +1,5 @@ import { BigQueryType, - GcpGetTablesQuery, - useGcpGetTablesLazyQuery, } from '../../../lib/schema/graphql' import { TreeItem } from '@mui/x-tree-view/TreeItem'; @@ -9,11 +7,12 @@ import { TreeItem } from '@mui/x-tree-view/TreeItem'; import { Loader } from '@navikt/ds-react' import { ExpandFilled, NextFilled } from '@navikt/ds-icons' import Tabell from '../../lib/icons/tabell' +import { useFetchBQTables } from '../../../lib/rest/bigquery'; -const DataproductTableIconMap: Record JSX.Element> = { - materialized_view: Tabell, - table: Tabell, - view: Tabell, +const DataproductTableIconMap: Record JSX.Element> = { + "materialized_view": Tabell, + "table": Tabell, + "view": Tabell, } export interface DataproductSourceDatasetProps { @@ -27,11 +26,7 @@ export const Dataset = ({ datasetID, active, }: DataproductSourceDatasetProps) => { - const [getTables, { data, loading, called }] = useGcpGetTablesLazyQuery({ - variables: { projectID, datasetID }, - }) - - if (active && !called) getTables() + const fetchBQTables= useFetchBQTables(projectID, datasetID) const loadingPlaceholder = ( ) - const datasetContents = (contents: GcpGetTablesQuery['gcpGetTables']) => - contents?.map(({ name, type }) => ( + const datasetContents = (contents: any) => + contents?.map((it: any) => ( )) @@ -65,10 +60,10 @@ export const Dataset = ({ itemId={`${projectID}/${datasetID}`} label={datasetID} > - {loading + {fetchBQTables.loading ? loadingPlaceholder - : data?.gcpGetTables?.length - ? datasetContents(data?.gcpGetTables) + : fetchBQTables.bqTables?.length + ? datasetContents(fetchBQTables?.bqTables) : emptyPlaceholder} ) diff --git a/components/dataproducts/datasource/project.tsx b/components/dataproducts/datasource/project.tsx index 01a13b71..6d55f1b8 100644 --- a/components/dataproducts/datasource/project.tsx +++ b/components/dataproducts/datasource/project.tsx @@ -1,8 +1,8 @@ import { TreeItem } from '@mui/x-tree-view/TreeItem'; import { Loader } from '@navikt/ds-react' -import { useGcpGetDatasetsLazyQuery } from '../../../lib/schema/graphql' import { ExpandFilled, NextFilled } from '@navikt/ds-icons' import { Dataset } from './dataset' +import { useFetchBQDatasets } from '../../../lib/rest/bigquery'; export interface DataproductSourceDatasetProps { activePaths: string[] @@ -13,12 +13,7 @@ export const Project = ({ projectID, activePaths, }: DataproductSourceDatasetProps) => { - const [getDatasets, { data, loading, error, called }] = - useGcpGetDatasetsLazyQuery({ - variables: { projectID }, - }) - - if (!called && activePaths.includes(projectID)) getDatasets() + const fetchBQDatasets= useFetchBQDatasets(projectID) const emptyPlaceholder = ( - {loading + {fetchBQDatasets.loading ? loadingPlaceholder - : !data?.gcpGetDatasets?.length + : !fetchBQDatasets.bqDatasets?.length ? emptyPlaceholder - : data?.gcpGetDatasets.map((datasetID) => ( + : fetchBQDatasets.bqDatasets?.map((datasetID) => ( { - const { data, loading, error } = useGcpGetAllTablesInProjectQuery({ - variables: { projectID }, - }) - - return ( - <> - {data?.gcpGetAllTablesInProject.map((table) => ( - - ))} - - ) -} - -export default ProjectTables diff --git a/lib/queries/access/datasetAccess.ts b/lib/queries/access/datasetAccess.ts deleted file mode 100644 index bd172b97..00000000 --- a/lib/queries/access/datasetAccess.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GET_DATASET_ACCESS = gql` - query DatasetAccess($id: ID!) { - dataset(id: $id) { - id - name - pii - owner { - group - teamkatalogenURL - } - access { - id - subject - granter - expires - created - revoked - accessRequestID - } - } - } -` diff --git a/lib/queries/accessRequest/accessRequest.ts b/lib/queries/accessRequest/accessRequest.ts deleted file mode 100644 index 8cc42139..00000000 --- a/lib/queries/accessRequest/accessRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GET_ACCESS_REQUEST = gql` - query accessRequest($id: ID!) { - accessRequest(id: $id) { - id - datasetID - subject - subjectType - granter - status - created - expires - owner - polly { - id - name - externalID - url - } - reason - } - } -` diff --git a/lib/queries/accessRequest/accessRequestsForDataset.ts b/lib/queries/accessRequest/accessRequestsForDataset.ts deleted file mode 100644 index 48827574..00000000 --- a/lib/queries/accessRequest/accessRequestsForDataset.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GET_ACCESS_REQUESTS_FOR_DATASET = gql` - query accessRequestsForDataset($datasetID: ID!) { - accessRequestsForDataset(datasetID: $datasetID) { - id - subject - subjectType - owner - created - expires - owner - polly { - name - externalID - url - } - } - } -` diff --git a/lib/queries/dataproduct/dataproductSummary.ts b/lib/queries/dataproduct/dataproductSummary.ts deleted file mode 100644 index 97f5d79d..00000000 --- a/lib/queries/dataproduct/dataproductSummary.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GET_DATAPRODUCT_SUMMARY = gql` - query DataproductSummary($id: ID!) { - dataproduct(id: $id) { - id - lastModified - name - description - created - slug - keywords - datasets { - datasource { - type: __typename - } - } - } - } -` diff --git a/lib/queries/dataproduct/dataproducts.ts b/lib/queries/dataproduct/dataproducts.ts deleted file mode 100644 index 2b1cf81e..00000000 --- a/lib/queries/dataproduct/dataproducts.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GET_METABASE_PRODUCTS = gql` - query MetabaseProudcts { - dataproducts(service: metabase) { - id - name - keywords - slug - owner { - group - teamkatalogenURL - teamContact - } - } - } -` diff --git a/lib/queries/dataproduct/gcpGetAllTablesInProject.ts b/lib/queries/dataproduct/gcpGetAllTablesInProject.ts deleted file mode 100644 index f89f1076..00000000 --- a/lib/queries/dataproduct/gcpGetAllTablesInProject.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GCP_GET_TABLES_IN_PROJECT = gql` - query gcpGetAllTablesInProject($projectID: String!) { - gcpGetAllTablesInProject(projectID: $projectID) { - table - dataset - } - } -` diff --git a/lib/queries/dataproduct/gcpGetColumns.ts b/lib/queries/dataproduct/gcpGetColumns.ts deleted file mode 100644 index dd01ea90..00000000 --- a/lib/queries/dataproduct/gcpGetColumns.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GCP_GET_TABLES = gql` - query gcpGetColumns($projectID: String!, $datasetID: String!, $tableID: String!) { - gcpGetColumns(projectID: $projectID, datasetID: $datasetID, tableID: $tableID) { - name - type - mode - description - } - } -` diff --git a/lib/queries/dataproduct/gcpGetDatasets.ts b/lib/queries/dataproduct/gcpGetDatasets.ts deleted file mode 100644 index e404c23e..00000000 --- a/lib/queries/dataproduct/gcpGetDatasets.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GCP_GET_DATASETS = gql` - query gcpGetDatasets($projectID: String!) { - gcpGetDatasets(projectID: $projectID) - } -` diff --git a/lib/queries/dataproduct/gcpGetTables.ts b/lib/queries/dataproduct/gcpGetTables.ts deleted file mode 100644 index e15e9d6e..00000000 --- a/lib/queries/dataproduct/gcpGetTables.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { gql } from 'graphql-tag' - -export const GCP_GET_TABLES = gql` - query gcpGetTables($projectID: String!, $datasetID: String!) { - gcpGetTables(projectID: $projectID, datasetID: $datasetID) { - name - type - description - } - } -` diff --git a/lib/rest/access.ts b/lib/rest/access.ts new file mode 100644 index 00000000..52a05cce --- /dev/null +++ b/lib/rest/access.ts @@ -0,0 +1,32 @@ +import { useEffect, useState } from "react"; +import { fetchAccessRequestUrl, fetchTemplate } from "./restApi"; + +export const fetchAccessRequests = async (datasetId: string) => { + const url = fetchAccessRequestUrl(datasetId); + return fetchTemplate(url); +} + +export const useFetchAccessRequestsForDataset = (datasetId: string)=>{ + const [data, setData] = useState(undefined) + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + + + useEffect(()=>{ + if(!datasetId) return + fetchAccessRequests(datasetId).then((res)=> res.json()) + .then((data)=> + { + setError(null) + setData(data) + }) + .catch((err)=>{ + setError(err) + setData(undefined) + }).finally(()=>{ + setLoading(false) + }) + }, [datasetId]) + + return {data, loading, error} +} \ No newline at end of file diff --git a/lib/rest/bigquery.ts b/lib/rest/bigquery.ts new file mode 100644 index 00000000..3dedd6f6 --- /dev/null +++ b/lib/rest/bigquery.ts @@ -0,0 +1,89 @@ +import { useEffect, useState } from "react" +import { fetchBQColumnsUrl, fetchBQDatasetsUrl, fetchBQTablesUrl, fetchTemplate } from "./restApi" + +export const fetchBQDatasets = async (projectID: string) => { + if(!projectID) return Promise.resolve({} as Response) + const url = fetchBQDatasetsUrl(projectID) + return fetchTemplate(url) +} + +export const fetchBQTables = async (projectID: string, datasetID: string) => { + if(!projectID || !datasetID) return Promise.resolve({} as Response) + const url = fetchBQTablesUrl(projectID, datasetID) + return fetchTemplate(url) +} + +export const fetchBQColumns = async (projectID: string, datasetID: string, tableID: string) => { + if(!projectID || !datasetID || !tableID) return Promise.resolve({} as Response) + const url = fetchBQColumnsUrl(projectID, datasetID, tableID) + return fetchTemplate(url) +} + +export const useFetchBQDatasets = (projectID: string) => { + const [datasets, setDatasets] = useState([]) + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + + useEffect(() => { + setLoading(true) + fetchBQDatasets(projectID).then((res) => res.json()) + .then((data) => { + setError(null) + setDatasets(data.bqDatasets) + }) + .catch((err) => { + setError(err) + setDatasets([]) + }).finally(() => { + setLoading(false) + }) + }, [projectID]) + + return { bqDatasets: datasets, loading, error } +} + +export const useFetchBQTables = (projectID: string, datasetID: string) => { + const [tables, setTables] = useState([]) + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + + useEffect(() => { + setLoading(true) + fetchBQTables(projectID, datasetID).then((res) => res.json()) + .then((data) => { + setError(null) + setTables(data.bqTables) + }) + .catch((err) => { + setError(err) + setTables([]) + }).finally(() => { + setLoading(false) + }) + }, [projectID, datasetID]) + + return { bqTables: tables, loading, error } +} + +export const useFetchBQcolumns = (projectID: string, datasetID: string, tableID: string) => { + const [columns, setColumns] = useState([]) + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + + useEffect(() => { + setLoading(true) + fetchBQColumns(projectID, datasetID, tableID).then((res) => res.json()) + .then((data) => { + setError(null) + setColumns(data.bqColumns) + }) + .catch((err) => { + setError(err) + setColumns([]) + }).finally(() => { + setLoading(false) + }) + }, [projectID, datasetID, tableID]) + + return { bqColumns: columns, loading, error } +} \ No newline at end of file diff --git a/lib/rest/restApi.ts b/lib/rest/restApi.ts index 6ddb928b..0eb4a72e 100644 --- a/lib/rest/restApi.ts +++ b/lib/rest/restApi.ts @@ -15,6 +15,10 @@ export const getProductAreasUrl = () => `${apiUrl()}/productareas` export const getProductAreaUrl = (id: string) => `${apiUrl()}/productareas/${id}` export const fetchUserDataUrl = () => `${apiUrl()}/userData` export const fetchKeywordsUrl = () => `${apiUrl()}/keywords` +export const fetchAccessRequestUrl = (datasetId: string) => `${apiUrl()}/accessRequests?datasetId=${datasetId}` +export const fetchBQDatasetsUrl = (projectId: string) => `${apiUrl()}/bigquery/datasets?projectId=${projectId}` +export const fetchBQTablesUrl = (projectId: string, datasetId: string) => `${apiUrl()}/bigquery/tables?projectId=${projectId}&datasetId=${datasetId}` +export const fetchBQColumnsUrl = (projectId: string, datasetId: string, tableId: string) => `${apiUrl()}/bigquery/columns?projectId=${projectId}&datasetId=${datasetId}&tableId=${tableId}` export const searchTeamKatalogenUrl = (gcpGroups?: string[]) => { const parameters = gcpGroups?.length ? gcpGroups.map(group => `gcpGroups=${encodeURIComponent(group)}`).join('&') : '' const query = parameters ? `?${parameters}` : '' diff --git a/lib/schema/graphql.ts b/lib/schema/graphql.ts index 64a50a64..0b7385db 100644 --- a/lib/schema/graphql.ts +++ b/lib/schema/graphql.ts @@ -1180,13 +1180,6 @@ export type UserInfo = { stories: Array; }; -export type DatasetAccessQueryVariables = Exact<{ - id: Scalars['ID']['input']; -}>; - - -export type DatasetAccessQuery = { __typename?: 'Query', dataset: { __typename?: 'Dataset', id: string, name: string, pii: PiiLevel, owner: { __typename?: 'Owner', group: string, teamkatalogenURL?: string | null }, access: Array<{ __typename?: 'Access', id: string, subject: string, granter: string, expires?: any | null, created: any, revoked?: any | null, accessRequestID?: string | null }> } }; - export type GrantAccessMutationVariables = Exact<{ input: NewGrant; }>; @@ -1201,20 +1194,6 @@ export type RevokeAccessMutationVariables = Exact<{ export type RevokeAccessMutation = { __typename?: 'Mutation', revokeAccessToDataset: boolean }; -export type AccessRequestQueryVariables = Exact<{ - id: Scalars['ID']['input']; -}>; - - -export type AccessRequestQuery = { __typename?: 'Query', accessRequest: { __typename?: 'AccessRequest', id: string, datasetID: string, subject: string, subjectType: SubjectType, granter?: string | null, status: AccessRequestStatus, created: any, expires?: any | null, owner: string, reason?: string | null, polly?: { __typename?: 'Polly', id: string, name: string, externalID: string, url: string } | null } }; - -export type AccessRequestsForDatasetQueryVariables = Exact<{ - datasetID: Scalars['ID']['input']; -}>; - - -export type AccessRequestsForDatasetQuery = { __typename?: 'Query', accessRequestsForDataset: Array<{ __typename?: 'AccessRequest', id: string, subject: string, subjectType: SubjectType, owner: string, created: any, expires?: any | null, polly?: { __typename?: 'Polly', name: string, externalID: string, url: string } | null }> }; - export type ApproveAccessRequestMutationVariables = Exact<{ id: Scalars['ID']['input']; }>; @@ -1258,18 +1237,6 @@ export type CreateDataproductMutationVariables = Exact<{ export type CreateDataproductMutation = { __typename?: 'Mutation', createDataproduct: { __typename?: 'Dataproduct', id: string, slug: string } }; -export type DataproductSummaryQueryVariables = Exact<{ - id: Scalars['ID']['input']; -}>; - - -export type DataproductSummaryQuery = { __typename?: 'Query', dataproduct: { __typename?: 'Dataproduct', id: string, lastModified: any, name: string, description: string, created: any, slug: string, keywords: Array, datasets: Array<{ __typename?: 'Dataset', datasource: { __typename?: 'BigQuery', type: 'BigQuery' } }> } }; - -export type MetabaseProudctsQueryVariables = Exact<{ [key: string]: never; }>; - - -export type MetabaseProudctsQuery = { __typename?: 'Query', dataproducts: Array<{ __typename?: 'Dataproduct', id: string, name: string, keywords: Array, slug: string, owner: { __typename?: 'Owner', group: string, teamkatalogenURL?: string | null, teamContact?: string | null } }> }; - export type DeleteDataproductMutationVariables = Exact<{ id: Scalars['ID']['input']; }>; @@ -1277,37 +1244,6 @@ export type DeleteDataproductMutationVariables = Exact<{ export type DeleteDataproductMutation = { __typename?: 'Mutation', deleteDataproduct: boolean }; -export type GcpGetAllTablesInProjectQueryVariables = Exact<{ - projectID: Scalars['String']['input']; -}>; - - -export type GcpGetAllTablesInProjectQuery = { __typename?: 'Query', gcpGetAllTablesInProject: Array<{ __typename?: 'BigQuerySource', table: string, dataset: string }> }; - -export type GcpGetColumnsQueryVariables = Exact<{ - projectID: Scalars['String']['input']; - datasetID: Scalars['String']['input']; - tableID: Scalars['String']['input']; -}>; - - -export type GcpGetColumnsQuery = { __typename?: 'Query', gcpGetColumns: Array<{ __typename?: 'TableColumn', name: string, type: string, mode: string, description: string }> }; - -export type GcpGetDatasetsQueryVariables = Exact<{ - projectID: Scalars['String']['input']; -}>; - - -export type GcpGetDatasetsQuery = { __typename?: 'Query', gcpGetDatasets: Array }; - -export type GcpGetTablesQueryVariables = Exact<{ - projectID: Scalars['String']['input']; - datasetID: Scalars['String']['input']; -}>; - - -export type GcpGetTablesQuery = { __typename?: 'Query', gcpGetTables: Array<{ __typename?: 'BigQueryTable', name: string, type: BigQueryType, description: string }> }; - export type UpdateDataproductMutationVariables = Exact<{ id: Scalars['ID']['input']; input: UpdateDataproduct; @@ -1475,61 +1411,6 @@ export type UserInfoAccessableDataproductQueryVariables = Exact<{ [key: string]: export type UserInfoAccessableDataproductQuery = { __typename?: 'Query', userInfo: { __typename?: 'UserInfo', accessable: { __typename?: 'AccessibleDatasets', owned: Array<{ __typename: 'Dataset', id: string, name: string, description: string, created: any, lastModified: any, owner: { __typename?: 'Owner', group: string, teamkatalogenURL?: string | null } }>, granted: Array<{ __typename: 'Dataset', id: string, name: string, description: string, created: any, lastModified: any, owner: { __typename?: 'Owner', group: string, teamkatalogenURL?: string | null } }> } } }; -export const DatasetAccessDocument = gql` - query DatasetAccess($id: ID!) { - dataset(id: $id) { - id - name - pii - owner { - group - teamkatalogenURL - } - access { - id - subject - granter - expires - created - revoked - accessRequestID - } - } -} - `; - -/** - * __useDatasetAccessQuery__ - * - * To run a query within a React component, call `useDatasetAccessQuery` and pass it any options that fit your needs. - * When your component renders, `useDatasetAccessQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useDatasetAccessQuery({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function useDatasetAccessQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: DatasetAccessQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(DatasetAccessDocument, options); - } -export function useDatasetAccessLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(DatasetAccessDocument, options); - } -export function useDatasetAccessSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(DatasetAccessDocument, options); - } -export type DatasetAccessQueryHookResult = ReturnType; -export type DatasetAccessLazyQueryHookResult = ReturnType; -export type DatasetAccessSuspenseQueryHookResult = ReturnType; -export type DatasetAccessQueryResult = Apollo.QueryResult; export const GrantAccessDocument = gql` mutation GrantAccess($input: NewGrant!) { grantAccessToDataset(input: $input) { @@ -1594,112 +1475,6 @@ export function useRevokeAccessMutation(baseOptions?: Apollo.MutationHookOptions export type RevokeAccessMutationHookResult = ReturnType; export type RevokeAccessMutationResult = Apollo.MutationResult; export type RevokeAccessMutationOptions = Apollo.BaseMutationOptions; -export const AccessRequestDocument = gql` - query accessRequest($id: ID!) { - accessRequest(id: $id) { - id - datasetID - subject - subjectType - granter - status - created - expires - owner - polly { - id - name - externalID - url - } - reason - } -} - `; - -/** - * __useAccessRequestQuery__ - * - * To run a query within a React component, call `useAccessRequestQuery` and pass it any options that fit your needs. - * When your component renders, `useAccessRequestQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useAccessRequestQuery({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function useAccessRequestQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: AccessRequestQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(AccessRequestDocument, options); - } -export function useAccessRequestLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(AccessRequestDocument, options); - } -export function useAccessRequestSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(AccessRequestDocument, options); - } -export type AccessRequestQueryHookResult = ReturnType; -export type AccessRequestLazyQueryHookResult = ReturnType; -export type AccessRequestSuspenseQueryHookResult = ReturnType; -export type AccessRequestQueryResult = Apollo.QueryResult; -export const AccessRequestsForDatasetDocument = gql` - query accessRequestsForDataset($datasetID: ID!) { - accessRequestsForDataset(datasetID: $datasetID) { - id - subject - subjectType - owner - created - expires - owner - polly { - name - externalID - url - } - } -} - `; - -/** - * __useAccessRequestsForDatasetQuery__ - * - * To run a query within a React component, call `useAccessRequestsForDatasetQuery` and pass it any options that fit your needs. - * When your component renders, `useAccessRequestsForDatasetQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useAccessRequestsForDatasetQuery({ - * variables: { - * datasetID: // value for 'datasetID' - * }, - * }); - */ -export function useAccessRequestsForDatasetQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: AccessRequestsForDatasetQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(AccessRequestsForDatasetDocument, options); - } -export function useAccessRequestsForDatasetLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(AccessRequestsForDatasetDocument, options); - } -export function useAccessRequestsForDatasetSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(AccessRequestsForDatasetDocument, options); - } -export type AccessRequestsForDatasetQueryHookResult = ReturnType; -export type AccessRequestsForDatasetLazyQueryHookResult = ReturnType; -export type AccessRequestsForDatasetSuspenseQueryHookResult = ReturnType; -export type AccessRequestsForDatasetQueryResult = Apollo.QueryResult; export const ApproveAccessRequestDocument = gql` mutation approveAccessRequest($id: ID!) { approveAccessRequest(id: $id) @@ -1894,104 +1669,6 @@ export function useCreateDataproductMutation(baseOptions?: Apollo.MutationHookOp export type CreateDataproductMutationHookResult = ReturnType; export type CreateDataproductMutationResult = Apollo.MutationResult; export type CreateDataproductMutationOptions = Apollo.BaseMutationOptions; -export const DataproductSummaryDocument = gql` - query DataproductSummary($id: ID!) { - dataproduct(id: $id) { - id - lastModified - name - description - created - slug - keywords - datasets { - datasource { - type: __typename - } - } - } -} - `; - -/** - * __useDataproductSummaryQuery__ - * - * To run a query within a React component, call `useDataproductSummaryQuery` and pass it any options that fit your needs. - * When your component renders, `useDataproductSummaryQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useDataproductSummaryQuery({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function useDataproductSummaryQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: DataproductSummaryQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(DataproductSummaryDocument, options); - } -export function useDataproductSummaryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(DataproductSummaryDocument, options); - } -export function useDataproductSummarySuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(DataproductSummaryDocument, options); - } -export type DataproductSummaryQueryHookResult = ReturnType; -export type DataproductSummaryLazyQueryHookResult = ReturnType; -export type DataproductSummarySuspenseQueryHookResult = ReturnType; -export type DataproductSummaryQueryResult = Apollo.QueryResult; -export const MetabaseProudctsDocument = gql` - query MetabaseProudcts { - dataproducts(service: metabase) { - id - name - keywords - slug - owner { - group - teamkatalogenURL - teamContact - } - } -} - `; - -/** - * __useMetabaseProudctsQuery__ - * - * To run a query within a React component, call `useMetabaseProudctsQuery` and pass it any options that fit your needs. - * When your component renders, `useMetabaseProudctsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useMetabaseProudctsQuery({ - * variables: { - * }, - * }); - */ -export function useMetabaseProudctsQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(MetabaseProudctsDocument, options); - } -export function useMetabaseProudctsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(MetabaseProudctsDocument, options); - } -export function useMetabaseProudctsSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(MetabaseProudctsDocument, options); - } -export type MetabaseProudctsQueryHookResult = ReturnType; -export type MetabaseProudctsLazyQueryHookResult = ReturnType; -export type MetabaseProudctsSuspenseQueryHookResult = ReturnType; -export type MetabaseProudctsQueryResult = Apollo.QueryResult; export const DeleteDataproductDocument = gql` mutation deleteDataproduct($id: ID!) { deleteDataproduct(id: $id) @@ -2023,173 +1700,6 @@ export function useDeleteDataproductMutation(baseOptions?: Apollo.MutationHookOp export type DeleteDataproductMutationHookResult = ReturnType; export type DeleteDataproductMutationResult = Apollo.MutationResult; export type DeleteDataproductMutationOptions = Apollo.BaseMutationOptions; -export const GcpGetAllTablesInProjectDocument = gql` - query gcpGetAllTablesInProject($projectID: String!) { - gcpGetAllTablesInProject(projectID: $projectID) { - table - dataset - } -} - `; - -/** - * __useGcpGetAllTablesInProjectQuery__ - * - * To run a query within a React component, call `useGcpGetAllTablesInProjectQuery` and pass it any options that fit your needs. - * When your component renders, `useGcpGetAllTablesInProjectQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useGcpGetAllTablesInProjectQuery({ - * variables: { - * projectID: // value for 'projectID' - * }, - * }); - */ -export function useGcpGetAllTablesInProjectQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: GcpGetAllTablesInProjectQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(GcpGetAllTablesInProjectDocument, options); - } -export function useGcpGetAllTablesInProjectLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(GcpGetAllTablesInProjectDocument, options); - } -export function useGcpGetAllTablesInProjectSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(GcpGetAllTablesInProjectDocument, options); - } -export type GcpGetAllTablesInProjectQueryHookResult = ReturnType; -export type GcpGetAllTablesInProjectLazyQueryHookResult = ReturnType; -export type GcpGetAllTablesInProjectSuspenseQueryHookResult = ReturnType; -export type GcpGetAllTablesInProjectQueryResult = Apollo.QueryResult; -export const GcpGetColumnsDocument = gql` - query gcpGetColumns($projectID: String!, $datasetID: String!, $tableID: String!) { - gcpGetColumns(projectID: $projectID, datasetID: $datasetID, tableID: $tableID) { - name - type - mode - description - } -} - `; - -/** - * __useGcpGetColumnsQuery__ - * - * To run a query within a React component, call `useGcpGetColumnsQuery` and pass it any options that fit your needs. - * When your component renders, `useGcpGetColumnsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useGcpGetColumnsQuery({ - * variables: { - * projectID: // value for 'projectID' - * datasetID: // value for 'datasetID' - * tableID: // value for 'tableID' - * }, - * }); - */ -export function useGcpGetColumnsQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: GcpGetColumnsQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(GcpGetColumnsDocument, options); - } -export function useGcpGetColumnsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(GcpGetColumnsDocument, options); - } -export function useGcpGetColumnsSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(GcpGetColumnsDocument, options); - } -export type GcpGetColumnsQueryHookResult = ReturnType; -export type GcpGetColumnsLazyQueryHookResult = ReturnType; -export type GcpGetColumnsSuspenseQueryHookResult = ReturnType; -export type GcpGetColumnsQueryResult = Apollo.QueryResult; -export const GcpGetDatasetsDocument = gql` - query gcpGetDatasets($projectID: String!) { - gcpGetDatasets(projectID: $projectID) -} - `; - -/** - * __useGcpGetDatasetsQuery__ - * - * To run a query within a React component, call `useGcpGetDatasetsQuery` and pass it any options that fit your needs. - * When your component renders, `useGcpGetDatasetsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useGcpGetDatasetsQuery({ - * variables: { - * projectID: // value for 'projectID' - * }, - * }); - */ -export function useGcpGetDatasetsQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: GcpGetDatasetsQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(GcpGetDatasetsDocument, options); - } -export function useGcpGetDatasetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(GcpGetDatasetsDocument, options); - } -export function useGcpGetDatasetsSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(GcpGetDatasetsDocument, options); - } -export type GcpGetDatasetsQueryHookResult = ReturnType; -export type GcpGetDatasetsLazyQueryHookResult = ReturnType; -export type GcpGetDatasetsSuspenseQueryHookResult = ReturnType; -export type GcpGetDatasetsQueryResult = Apollo.QueryResult; -export const GcpGetTablesDocument = gql` - query gcpGetTables($projectID: String!, $datasetID: String!) { - gcpGetTables(projectID: $projectID, datasetID: $datasetID) { - name - type - description - } -} - `; - -/** - * __useGcpGetTablesQuery__ - * - * To run a query within a React component, call `useGcpGetTablesQuery` and pass it any options that fit your needs. - * When your component renders, `useGcpGetTablesQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useGcpGetTablesQuery({ - * variables: { - * projectID: // value for 'projectID' - * datasetID: // value for 'datasetID' - * }, - * }); - */ -export function useGcpGetTablesQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: GcpGetTablesQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(GcpGetTablesDocument, options); - } -export function useGcpGetTablesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(GcpGetTablesDocument, options); - } -export function useGcpGetTablesSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSuspenseQuery(GcpGetTablesDocument, options); - } -export type GcpGetTablesQueryHookResult = ReturnType; -export type GcpGetTablesLazyQueryHookResult = ReturnType; -export type GcpGetTablesSuspenseQueryHookResult = ReturnType; -export type GcpGetTablesQueryResult = Apollo.QueryResult; export const UpdateDataproductDocument = gql` mutation updateDataproduct($id: ID!, $input: UpdateDataproduct!) { updateDataproduct(id: $id, input: $input) { diff --git a/pages/index.tsx b/pages/index.tsx index 83158279..50e16c88 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,8 +1,5 @@ import { GetServerSideProps } from 'next' import { addApolloState, initializeApollo } from '../lib/apollo' -import { - MetabaseProudctsDocument, -} from '../lib/schema/graphql' import { useRouter } from 'next/router' import { FrontPageLogo } from '../components/index/frontPageLogo' import { useEffect, useState } from 'react' @@ -133,10 +130,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const cookie = context?.req?.headers?.cookie || '' const apolloClient = initializeApollo(null, cookie) - await apolloClient.query({ - query: MetabaseProudctsDocument, - }) - return addApolloState(apolloClient, { props: {}, })