diff --git a/.changeset/fast-experts-cross.md b/.changeset/fast-experts-cross.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/fast-experts-cross.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/examples/example-react-sdk-2.x/src/AuthCallback.tsx b/examples/example-react-sdk-2.x/src/AuthCallback.tsx index d047f2741..78efbf0e8 100644 --- a/examples/example-react-sdk-2.x/src/AuthCallback.tsx +++ b/examples/example-react-sdk-2.x/src/AuthCallback.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; -import { auth } from "./client"; +import { auth } from "./main"; /** * Component to render at `/auth/callback` diff --git a/examples/example-react-sdk-2.x/src/Home.tsx b/examples/example-react-sdk-2.x/src/Home.tsx index 1aa5bf473..de637c012 100644 --- a/examples/example-react-sdk-2.x/src/Home.tsx +++ b/examples/example-react-sdk-2.x/src/Home.tsx @@ -1,39 +1,11 @@ import { $Objects, $Actions, $Queries } from "@osdk/e2e.generated.catchall"; import css from "./Home.module.css"; import Layout from "./Layout"; - // import { useOsdkClient } from "@osdk/react"; -// import React from "react"; -// import { Osdk } from "@osdk/client"; function Home() { - // const client = useOsdkClient(); - - // const [objects, setObjects] = React.useState<$Objects.Todo.OsdkInstance[]>(); - // const [isLoading, setIsLoading] = React.useState(true); - - // React.useEffect(() => { - // client($Objects.Todo).fetchPage().then((page) => { - // setObjects(page.data); - // setIsLoading(false); - // }); - // }, []); - - // if (isLoading) { - // return Loading...; - // } else { - // return ( - // - // - // - // ) - // } - + // See API Docs on Developer console on how to use the client object to access the ontology resource const objectApiNames = Object.keys($Objects); const actionApiNames = Object.keys($Actions); diff --git a/examples/example-react-sdk-2.x/src/client.ts b/examples/example-react-sdk-2.x/src/client.ts deleted file mode 100644 index e583ca149..000000000 --- a/examples/example-react-sdk-2.x/src/client.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { Client } from "@osdk/client"; -import { createClient } from "@osdk/client"; -import { $ontologyRid } from "@osdk/e2e.generated.catchall"; -import { createPublicOauthClient } from "@osdk/oauth"; - -const url = import.meta.env.VITE_FOUNDRY_API_URL; -const clientId = import.meta.env.VITE_FOUNDRY_CLIENT_ID; -const redirectUrl = import.meta.env.VITE_FOUNDRY_REDIRECT_URL; -const scopes = [ - "api:ontologies-read", - "api:ontologies-write", -]; - -checkEnv(url, "VITE_FOUNDRY_API_URL"); -checkEnv(clientId, "VITE_FOUNDRY_CLIENT_ID"); -checkEnv(redirectUrl, "VITE_FOUNDRY_REDIRECT_URL"); - -function checkEnv( - value: string | undefined, - name: string, -): asserts value is string { - if (value == null) { - throw new Error(`Missing environment variable: ${name}`); - } -} - -export const auth = createPublicOauthClient( - clientId, - url, - redirectUrl, - true, - undefined, - window.location.toString(), - scopes, -); - -/** - * Initialize the client to interact with the Ontology SDK - */ -const client: Client = createClient( - url, - $ontologyRid, - auth, -); - -export default client; diff --git a/examples/example-react-sdk-2.x/src/main.tsx b/examples/example-react-sdk-2.x/src/main.tsx index d2f6e0a50..c0ce81173 100644 --- a/examples/example-react-sdk-2.x/src/main.tsx +++ b/examples/example-react-sdk-2.x/src/main.tsx @@ -5,7 +5,8 @@ import createClientAndAuth from "./createClientAndAuth"; import "./index.css"; import { router } from "./router"; -const { client } = createClientAndAuth(); +const { client, auth } = createClientAndAuth(); +export { auth }; ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/packages/create-app.template.react.beta/templates/src/AuthCallback.tsx b/packages/create-app.template.react.beta/templates/src/AuthCallback.tsx index d047f2741..78efbf0e8 100644 --- a/packages/create-app.template.react.beta/templates/src/AuthCallback.tsx +++ b/packages/create-app.template.react.beta/templates/src/AuthCallback.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; -import { auth } from "./client"; +import { auth } from "./main"; /** * Component to render at `/auth/callback` diff --git a/packages/create-app.template.react.beta/templates/src/Home.tsx.hbs b/packages/create-app.template.react.beta/templates/src/Home.tsx.hbs index 96678239a..600f209a0 100644 --- a/packages/create-app.template.react.beta/templates/src/Home.tsx.hbs +++ b/packages/create-app.template.react.beta/templates/src/Home.tsx.hbs @@ -1,39 +1,11 @@ import { $Objects, $Actions, $Queries } from "{{osdkPackage}}"; import css from "./Home.module.css"; import Layout from "./Layout"; - // import { useOsdkClient } from "@osdk/react"; -// import React from "react"; -// import { Osdk } from "@osdk/client"; function Home() { - // const client = useOsdkClient(); - - // const [objects, setObjects] = React.useState<$Objects.Todo.OsdkInstance[]>(); - // const [isLoading, setIsLoading] = React.useState(true); - - // React.useEffect(() => { - // client($Objects.Todo).fetchPage().then((page) => { - // setObjects(page.data); - // setIsLoading(false); - // }); - // }, []); - - // if (isLoading) { - // return Loading...; - // } else { - // return ( - // - // - // - // ) - // } - + // See API Docs on Developer console on how to use the client object to access the ontology resource const objectApiNames = Object.keys($Objects); const actionApiNames = Object.keys($Actions); diff --git a/packages/create-app.template.react.beta/templates/src/client.ts.hbs b/packages/create-app.template.react.beta/templates/src/client.ts.hbs deleted file mode 100644 index 4877b88bd..000000000 --- a/packages/create-app.template.react.beta/templates/src/client.ts.hbs +++ /dev/null @@ -1,51 +0,0 @@ -import type { Client } from "@osdk/client"; -import { createClient } from "@osdk/client"; -import { $ontologyRid } from "{{osdkPackage}}"; -import { createPublicOauthClient } from "@osdk/oauth"; - -const url = import.meta.env.VITE_FOUNDRY_API_URL; -const clientId = import.meta.env.VITE_FOUNDRY_CLIENT_ID; -const redirectUrl = import.meta.env.VITE_FOUNDRY_REDIRECT_URL; -{{#if scopes}} -const scopes = [ - {{#each scopes}} - "{{this}}", - {{/each}} -]; -{{/if}} - -checkEnv(url, "VITE_FOUNDRY_API_URL"); -checkEnv(clientId, "VITE_FOUNDRY_CLIENT_ID"); -checkEnv(redirectUrl, "VITE_FOUNDRY_REDIRECT_URL"); - -function checkEnv( - value: string | undefined, - name: string, -): asserts value is string { - if (value == null) { - throw new Error(`Missing environment variable: ${name}`); - } -} - -export const auth = createPublicOauthClient( - clientId, - url, - redirectUrl, - {{#if scopes}} - true, - undefined, - window.location.toString(), - scopes, - {{/if}} -); - -/** - * Initialize the client to interact with the Ontology SDK - */ -const client: Client = createClient( - url, - $ontologyRid, - auth, -); - -export default client; diff --git a/packages/create-app.template.react.beta/templates/src/main.tsx b/packages/create-app.template.react.beta/templates/src/main.tsx index d2f6e0a50..c0ce81173 100644 --- a/packages/create-app.template.react.beta/templates/src/main.tsx +++ b/packages/create-app.template.react.beta/templates/src/main.tsx @@ -5,7 +5,8 @@ import createClientAndAuth from "./createClientAndAuth"; import "./index.css"; import { router } from "./router"; -const { client } = createClientAndAuth(); +const { client, auth } = createClientAndAuth(); +export { auth }; ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/packages/example-generator/README.md b/packages/example-generator/README.md index 24bf45899..ab82ae8ea 100644 --- a/packages/example-generator/README.md +++ b/packages/example-generator/README.md @@ -2,4 +2,4 @@ Generates examples packages for `@osdk/create-app` and `@osdk/create-widget`. -Run `pnpm generate` to generate packages and `pnpm check` to verify if they are up to date. +Run `pnpm generate` to generate packages and `turbo check` to verify if they are up to date. diff --git a/packages/example-generator/src/run.ts b/packages/example-generator/src/run.ts index a4bc03c98..a3bdd762a 100644 --- a/packages/example-generator/src/run.ts +++ b/packages/example-generator/src/run.ts @@ -217,10 +217,10 @@ async function checkExamples( for (const q of compareResult.diffSet ?? []) { if (q.state !== "equal") { const aPath = q.path1 && q.name1 - ? path.join(q.path1, q.relativePath, q.name1) + ? path.join(q.path1, q.name1) : null; const bPath = q.path2 && q.name2 - ? path.join(q.path2, q.relativePath, q.name2) + ? path.join(q.path2, q.name2) : null; const aContents = getContents(aPath); diff --git a/turbo.json b/turbo.json index c18109f0b..d8e4324ac 100644 --- a/turbo.json +++ b/turbo.json @@ -181,6 +181,7 @@ "inputs": [ "bin/**", "src/**", + "templates/**", "tsup.config.js", "tsconfig.json", "tsconfig.cjs.json"