-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(intoduced) API doc and GraphiQL embedded page under developer
- Loading branch information
Showing
24 changed files
with
1,405 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ExpandedSidebar } from '@karrio/ui/components/expanded-sidebar'; | ||
import { ModeIndicator } from '@karrio/ui/components/mode-indicator'; | ||
import React from 'react'; | ||
|
||
|
||
export const EmbedLayout: React.FC<{ showModeIndicator?: boolean, children?: React.ReactNode }> = ({ children, ...props }) => { | ||
return ( | ||
<> | ||
{props.showModeIndicator && <ModeIndicator />} | ||
<ExpandedSidebar /> | ||
|
||
<div className="plex-wrapper is-relative p-0"> | ||
|
||
{children} | ||
|
||
</div> | ||
|
||
</> | ||
) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AuthenticatedPage } from "@/layouts/authenticated-page"; | ||
import { useAPIMetadata } from "@karrio/hooks/api-metadata"; | ||
import { useSyncedSession } from "@karrio/hooks/session"; | ||
import { EmbedLayout } from "@/layouts/embed-layout"; | ||
import { RedocStandalone } from 'redoc'; | ||
import { url$ } from "@karrio/lib"; | ||
import Head from "next/head"; | ||
import React from "react"; | ||
|
||
export { getServerSideProps } from "@/context/main"; | ||
|
||
export default function Page(pageProps: any) { | ||
const Component: React.FC = () => { | ||
const { metadata } = useAPIMetadata(); | ||
|
||
return ( | ||
<> | ||
|
||
<RedocStandalone | ||
specUrl={url$`${metadata?.HOST}/shipping-openapi`} | ||
options={{ | ||
nativeScrollbars: true, | ||
}} | ||
/> | ||
|
||
</> | ||
); | ||
}; | ||
|
||
return AuthenticatedPage(( | ||
<EmbedLayout showModeIndicator={true}> | ||
<Head><title>{`API Docs - ${(pageProps as any).metadata?.APP_NAME}`}</title></Head> | ||
|
||
<Component /> | ||
|
||
</EmbedLayout> | ||
), pageProps) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { AuthenticatedPage } from "@/layouts/authenticated-page"; | ||
import { useAPIMetadata } from "@karrio/hooks/api-metadata"; | ||
import { createGraphiQLFetcher } from '@graphiql/toolkit'; | ||
import { useSyncedSession } from "@karrio/hooks/session"; | ||
import { EmbedLayout } from "@/layouts/embed-layout"; | ||
import { GraphiQL } from 'graphiql'; | ||
import Head from "next/head"; | ||
import React from "react"; | ||
|
||
import 'graphiql/graphiql.css'; | ||
|
||
export { getServerSideProps } from "@/context/main"; | ||
|
||
export default function Page(pageProps: any) { | ||
const Component: React.FC = () => { | ||
const { metadata } = useAPIMetadata(); | ||
const { query: { data: session } } = useSyncedSession(); | ||
|
||
const fetcher = React.useMemo(() => { | ||
return createGraphiQLFetcher({ | ||
url: metadata?.GRAPHQL, | ||
headers: { | ||
...(!!session?.orgId ? { 'x-org-id': session.orgId } : {}), | ||
...(!!session?.testMode ? { 'x-test-mode': session.testMode } : {}), | ||
...(!!session?.accessToken ? { 'authorization': `Bearer ${session.accessToken}` } : {}) | ||
}, | ||
}) | ||
}, [session.accessToken]); | ||
|
||
return ( | ||
<div className="playground-wrapper" style={{ position: 'absolute', top: 0, left: 0, bottom: 0, right: 0 }}> | ||
|
||
<GraphiQL fetcher={fetcher} /> | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
return AuthenticatedPage(( | ||
<EmbedLayout showModeIndicator={true}> | ||
<Head><title>{`GraphiQL - ${(pageProps as any).metadata?.APP_NAME}`}</title></Head> | ||
|
||
<Component /> | ||
|
||
</EmbedLayout> | ||
), pageProps) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/docs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/graphiql"; |
1 change: 1 addition & 0 deletions
1
apps/dashboard/src/pages/_sites/[site]/test/developers/docs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/docs"; |
1 change: 1 addition & 0 deletions
1
apps/dashboard/src/pages/_sites/[site]/test/developers/graphiql.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/graphiql"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/docs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/graphiql"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/docs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, getServerSideProps } from "@/modules/Developers/graphiql"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import enum | ||
import typing | ||
import base64 | ||
import logging | ||
|
Oops, something went wrong.