-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial views API #978
Open
styu
wants to merge
6
commits into
main
Choose a base branch
from
syu/initial-views-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dd90aee
Add initial views API
styu 9fd3d95
dedupe lockfile, delete old changelog
styu 699c716
add back react to tsconfig
styu 75415a8
add packages to changeset
styu 08c105a
Add changeset, put back version to 0.0.0
styu c40f60a
cr
styu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@osdk/views-client-react.unstable": minor | ||
"@osdk/views-client.unstable": minor | ||
"@osdk/views-api.unstable": minor | ||
--- | ||
|
||
Add initial views API |
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 @@ | ||
dist/ |
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,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Custom View: Ontology SDK + React</title> | ||
</head> | ||
<body> | ||
<div id="root-container"> | ||
<div id="root"></div> | ||
</div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
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,67 @@ | ||
{ | ||
"name": "@osdk/e2e.sandbox.views.todo-widget", | ||
"private": true, | ||
"version": "0.1.0-beta.1", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/palantir/osdk-ts.git" | ||
}, | ||
"exports": { | ||
".": { | ||
"browser": "./build/browser/index.js", | ||
"import": "./build/esm/index.js", | ||
"default": "./build/browser/index.js" | ||
}, | ||
"./*": { | ||
"browser": "./build/browser/public/*.js", | ||
"import": "./build/esm/public/*.js", | ||
"default": "./build/browser/public/*.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsc && vite build", | ||
"check-attw": "monorepo.tool.attw esm", | ||
"check-spelling": "cspell --quiet .", | ||
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo", | ||
"dev": "vite", | ||
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)", | ||
"lint": "eslint . && dprint check --config $(find-up dprint.json)", | ||
"preview": "vite preview", | ||
"transpile": "monorepo.tool.transpile" | ||
}, | ||
"dependencies": { | ||
"@osdk/views-client-react.unstable": "workspace:~", | ||
"@osdk/views-client.unstable": "workspace:~", | ||
"@radix-ui/react-icons": "^1.3.1", | ||
"@radix-ui/themes": "^3.1.4", | ||
"react": "^18", | ||
"react-dom": "^18" | ||
}, | ||
"devDependencies": { | ||
"@osdk/monorepo.api-extractor": "workspace:~", | ||
"@osdk/monorepo.tsconfig": "workspace:~", | ||
"@osdk/monorepo.tsup": "workspace:~", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"@vitejs/plugin-react": "^4.2.0", | ||
"typescript": "~5.5.4", | ||
"vite": "^5.4.8", | ||
"vitest": "^2.1.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"files": [ | ||
"build/cjs", | ||
"build/esm", | ||
"build/browser", | ||
"CHANGELOG.md", | ||
"package.json", | ||
"templates", | ||
"*.d.ts" | ||
], | ||
"module": "./build/esm/index.js", | ||
"types": "./build/esm/index.d.ts", | ||
"type": "module" | ||
} |
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,72 @@ | ||
import { useFoundryViewContext } from "@osdk/views-client-react.unstable"; | ||
import { ExclamationTriangleIcon } from "@radix-ui/react-icons"; | ||
import { | ||
Box, | ||
Callout, | ||
Container, | ||
Flex, | ||
Heading, | ||
Skeleton, | ||
Table, | ||
} from "@radix-ui/themes"; | ||
import React, { useEffect } from "react"; | ||
import type MainParameters from "./main.parameters.js"; | ||
|
||
export const App: React.FC = () => { | ||
const { parameterValues, sendReady } = useFoundryViewContext< | ||
typeof MainParameters | ||
>(); | ||
const { headerText, showWarning } = parameterValues; | ||
useEffect(() => { | ||
sendReady(); | ||
}, []); | ||
return ( | ||
<Box> | ||
<Container size="1"> | ||
<Flex p="5" direction="column" gap="2"> | ||
<Heading size="4"> | ||
{headerText.value.type === "loading" | ||
|| headerText.value.type === "not-started" | ||
? <Skeleton>Hello, world!</Skeleton> | ||
: ( | ||
headerText.value.value | ||
)} | ||
</Heading> | ||
{showWarning.value.type === "loaded" && showWarning.value.value && ( | ||
<Callout.Root size="1" color="orange" variant="soft"> | ||
<Callout.Icon> | ||
<ExclamationTriangleIcon /> | ||
</Callout.Icon> | ||
<Callout.Text>This is a data warning</Callout.Text> | ||
</Callout.Root> | ||
)} | ||
<Table.Root> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.ColumnHeaderCell>Email</Table.ColumnHeaderCell> | ||
<Table.ColumnHeaderCell>Group</Table.ColumnHeaderCell> | ||
</Table.Row> | ||
</Table.Header> | ||
|
||
<Table.Body> | ||
<Table.Row> | ||
<Table.Cell>[email protected]</Table.Cell> | ||
<Table.Cell>Developer</Table.Cell> | ||
</Table.Row> | ||
|
||
<Table.Row> | ||
<Table.Cell>[email protected]</Table.Cell> | ||
<Table.Cell>Admin</Table.Cell> | ||
</Table.Row> | ||
|
||
<Table.Row> | ||
<Table.Cell>[email protected]</Table.Cell> | ||
<Table.Cell>Developer</Table.Cell> | ||
</Table.Row> | ||
</Table.Body> | ||
</Table.Root> | ||
</Flex> | ||
</Container> | ||
</Box> | ||
); | ||
}; |
Empty file.
20 changes: 20 additions & 0 deletions
20
packages/e2e.sandbox.views.todo-widget/src/main.parameters.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,20 @@ | ||
import type { ParameterConfig } from "@osdk/views-client.unstable"; | ||
|
||
const MainParameters = { | ||
parameters: { | ||
headerText: { | ||
displayName: "Widget title", | ||
type: "string", | ||
}, | ||
showWarning: { | ||
displayName: "Show warning callout", | ||
type: "boolean", | ||
}, | ||
todoItems: { | ||
displayName: "Todo items", | ||
type: "array", | ||
subType: "string", | ||
}, | ||
}, | ||
} as const satisfies ParameterConfig; | ||
export default MainParameters; |
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,26 @@ | ||
import "@radix-ui/themes/styles.css"; | ||
import "./main.css"; | ||
|
||
import { | ||
FoundryView, | ||
initializeParameters, | ||
} from "@osdk/views-client-react.unstable"; | ||
import { Theme } from "@radix-ui/themes"; | ||
import React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import { App } from "./app.js"; | ||
import MainParameters from "./main.parameters.js"; | ||
|
||
const root = document.querySelector("body")!; | ||
|
||
createRoot(root).render( | ||
( | ||
<Theme> | ||
<FoundryView<typeof MainParameters> | ||
initialValues={initializeParameters(MainParameters, "loading")} | ||
> | ||
<App /> | ||
</FoundryView> | ||
</Theme> | ||
), | ||
); |
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 @@ | ||
/// <reference types="vite/client" /> |
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,12 @@ | ||
{ | ||
"extends": "@osdk/monorepo.tsconfig/base.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build/esm", | ||
"jsx": "react" | ||
}, | ||
"include": [ | ||
"./src/**/*" | ||
], | ||
"references": [] | ||
} |
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,23 @@ | ||
/* | ||
* Copyright 2023 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig(async (options) => | ||
(await import("@osdk/monorepo.tsup")).default(options, { | ||
esmOnly: true, | ||
}) | ||
); |
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,10 @@ | ||
import react from "@vitejs/plugin-react"; | ||
import { defineConfig } from "vite"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
server: { | ||
port: 8080, | ||
}, | ||
}); |
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,24 @@ | ||
/* | ||
* Copyright 2023 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { configDefaults, defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
pool: "forks", | ||
exclude: [...configDefaults.exclude, "**/build/**/*"], | ||
}, | ||
}); |
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,54 @@ | ||
{ | ||
"name": "@osdk/views-api.unstable", | ||
"version": "0.0.0", | ||
"description": "API contract between Foundry UIs that can embed custom views and the custom views themselves", | ||
"access": "public", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/palantir/osdk-ts.git" | ||
}, | ||
"exports": { | ||
".": { | ||
"browser": "./build/browser/index.js", | ||
"import": "./build/esm/index.js", | ||
"default": "./build/browser/index.js" | ||
}, | ||
"./*": { | ||
"browser": "./build/browser/public/*.js", | ||
"import": "./build/esm/public/*.js", | ||
"default": "./build/browser/public/*.js" | ||
} | ||
}, | ||
"scripts": { | ||
"check-attw": "monorepo.tool.attw esm", | ||
"check-spelling": "cspell --quiet .", | ||
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo", | ||
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)", | ||
"lint": "eslint . && dprint check --config $(find-up dprint.json)", | ||
"transpile": "monorepo.tool.transpile" | ||
}, | ||
"devDependencies": { | ||
"@osdk/monorepo.api-extractor": "workspace:~", | ||
"@osdk/monorepo.tsconfig": "workspace:~", | ||
"@osdk/monorepo.tsup": "workspace:~", | ||
"ts-expect": "^1.3.0", | ||
"typescript": "~5.5.4" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"keywords": [], | ||
"files": [ | ||
"build/cjs", | ||
"build/esm", | ||
"build/browser", | ||
"CHANGELOG.md", | ||
"package.json", | ||
"templates", | ||
"*.d.ts" | ||
], | ||
"module": "./build/esm/index.js", | ||
"types": "./build/esm/index.d.ts", | ||
"type": "module" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note i haven't actually ran this yet, i mostly made it to make sure all the types are right. I will go after a proper template (+ vite plugin) in a follow up PR