-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove getMethods in templates (#27)
- Loading branch information
Showing
16 changed files
with
106 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Override root lib/ ignore | ||
!templates/template-next-static-export/src/lib/ | ||
!**/__snapshots__/expected-template-next-static-export/src/lib/ |
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,5 @@ | ||
type: improvement | ||
improvement: | ||
description: Remove getMethods in templates now that generated methods are enumerable | ||
links: | ||
- https://github.com/palantir/osdk-ts/pull/27 |
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
15 changes: 15 additions & 0 deletions
15
...te-app/src/__tests__/__snapshots__/expected-template-next-static-export/src/lib/client.ts
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,15 @@ | ||
import { FoundryClient, PublicClientAuth } from "@fake/sdk"; | ||
|
||
/** | ||
* Initialize the client to interact with the Ontology SDK | ||
*/ | ||
const client = new FoundryClient({ | ||
url: process.env.NEXT_PUBLIC_FOUNDRY_API_URL!, | ||
auth: new PublicClientAuth({ | ||
clientId: process.env.NEXT_PUBLIC_FOUNDRY_CLIENT_ID!, | ||
url: process.env.NEXT_PUBLIC_FOUNDRY_API_URL!, | ||
redirectUrl: process.env.NEXT_PUBLIC_FOUNDRY_REDIRECT_URL!, | ||
}), | ||
}); | ||
|
||
export default client; |
25 changes: 25 additions & 0 deletions
25
.../__tests__/__snapshots__/expected-template-next-static-export/src/lib/useAuthenticated.ts
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,25 @@ | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect, useState } from "react"; | ||
import client from "./client"; | ||
|
||
function useAuthenticated() { | ||
const router = useRouter(); | ||
const [token, setToken] = useState(client.auth.token); | ||
useEffect(() => { | ||
if (client.auth.token == null || client.auth.token.isExpired) { | ||
client.auth | ||
.refresh() | ||
.then(() => { | ||
setToken(client.auth.token); | ||
}) | ||
.catch(() => { | ||
// If we cannot refresh the token (i.e. the user is not logged in) we redirect to the login page | ||
router.push("/login"); | ||
}); | ||
} | ||
}, [router]); | ||
|
||
return token != null && !token.isExpired; | ||
} | ||
|
||
export default useAuthenticated; |
7 changes: 3 additions & 4 deletions
7
packages/create-app/src/__tests__/__snapshots__/expected-template-react/src/Home.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
24 changes: 0 additions & 24 deletions
24
packages/create-app/src/__tests__/__snapshots__/expected-template-react/src/getMethods.ts
This file was deleted.
Oops, something went wrong.
7 changes: 3 additions & 4 deletions
7
packages/create-app/src/__tests__/__snapshots__/expected-template-vue/src/Home.vue
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
24 changes: 0 additions & 24 deletions
24
packages/create-app/src/__tests__/__snapshots__/expected-template-vue/src/getMethods.ts
This file was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
packages/create-app/templates/template-next-static-export/src/lib/client.ts.hbs
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,15 @@ | ||
import { FoundryClient, PublicClientAuth } from "{{osdkPackage}}"; | ||
|
||
/** | ||
* Initialize the client to interact with the Ontology SDK | ||
*/ | ||
const client = new FoundryClient({ | ||
url: process.env.NEXT_PUBLIC_FOUNDRY_API_URL!, | ||
auth: new PublicClientAuth({ | ||
clientId: process.env.NEXT_PUBLIC_FOUNDRY_CLIENT_ID!, | ||
url: process.env.NEXT_PUBLIC_FOUNDRY_API_URL!, | ||
redirectUrl: process.env.NEXT_PUBLIC_FOUNDRY_REDIRECT_URL!, | ||
}), | ||
}); | ||
|
||
export default client; |
25 changes: 25 additions & 0 deletions
25
packages/create-app/templates/template-next-static-export/src/lib/useAuthenticated.ts
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,25 @@ | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect, useState } from "react"; | ||
import client from "./client"; | ||
|
||
function useAuthenticated() { | ||
const router = useRouter(); | ||
const [token, setToken] = useState(client.auth.token); | ||
useEffect(() => { | ||
if (client.auth.token == null || client.auth.token.isExpired) { | ||
client.auth | ||
.refresh() | ||
.then(() => { | ||
setToken(client.auth.token); | ||
}) | ||
.catch(() => { | ||
// If we cannot refresh the token (i.e. the user is not logged in) we redirect to the login page | ||
router.push("/login"); | ||
}); | ||
} | ||
}, [router]); | ||
|
||
return token != null && !token.isExpired; | ||
} | ||
|
||
export default useAuthenticated; |
7 changes: 3 additions & 4 deletions
7
packages/create-app/templates/template-react/src/Home.tsx.hbs
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
24 changes: 0 additions & 24 deletions
24
packages/create-app/templates/template-react/src/getMethods.ts
This file was deleted.
Oops, something went wrong.
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
24 changes: 0 additions & 24 deletions
24
packages/create-app/templates/template-vue/src/getMethods.ts
This file was deleted.
Oops, something went wrong.