Skip to content

Commit

Permalink
Move from "views" naming to "widgets" (#1075)
Browse files Browse the repository at this point in the history
* Move from "views" naming to "widgets"

* Remove RID instance components

* Remove remaining uses of widget RID instance

---------

Co-authored-by: Ross Court <[email protected]>
  • Loading branch information
rosscourt and Ross Court authored Jan 8, 2025
1 parent 656f975 commit 314ae66
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 32 deletions.
9 changes: 9 additions & 0 deletions .changeset/itchy-moons-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@osdk/widget.vite-plugin.unstable": minor
"@osdk/widget-client.unstable": minor
"@osdk/widget-api.unstable": minor
"@osdk/example-generator": minor
"@osdk/create-widget": minor
---

Move from "views" naming to "widgets"
2 changes: 1 addition & 1 deletion examples/example-widget-react-sdk-2.x/foundry.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"foundryUrl": "https://fake.palantirfoundry.com",
"widget": {
"rid": "ri.viewregistry.main.view.fake",
"rid": "ri.widgetregistry..widget.fake",
"directory": "./dist",
"autoVersion": {
"type": "package-json"
Expand Down
2 changes: 1 addition & 1 deletion examples/example-widget-react-sdk-2.x/src/main.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "@osdk/widget-client.unstable";

export default defineConfig({
type: "workshop",
rid: "ri.viewregistry.main.view.fake",
rid: "ri.widgetregistry..widget.fake",
parameters: {
headerText: {
displayName: "Widget title",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-widget/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function runTest({
"--foundryUrl",
"https://example.palantirfoundry.com",
"--widget",
"ri.viewregistry.main.view.fake",
"ri.widgetregistry..widget.fake",
"--osdkPackage",
"@custom-widget/sdk",
"--osdkRegistryUrl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const expected = `
{
"foundryUrl": "https://example.palantirfoundry.com",
"widget": {
"rid": "ri.viewregistry.main.view.fake",
"rid": "ri.widgetregistry..widget.fake",
"directory": "./dist",
"autoVersion": {
"type": "git-describe",
Expand All @@ -35,7 +35,7 @@ test("it generates foundry.config.json", () => {
expect(
generateFoundryConfigJson({
foundryUrl: "https://example.palantirfoundry.com",
widget: "ri.viewregistry.main.view.fake",
widget: "ri.widgetregistry..widget.fake",
directory: "./dist",
}),
).toEqual(expected);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-widget/src/prompts/promptWidgetRid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ afterEach(() => {
vi.restoreAllMocks();
});

const valid = "ri.viewregistry.main.view.0000-0000-0000-0000";
const valid = "ri.widgetregistry..widget.0000-0000-0000-0000";

test("it accepts valid application rid from prompt", async () => {
vi.mocked(consola).prompt.mockResolvedValueOnce(valid);
Expand Down
4 changes: 2 additions & 2 deletions packages/create-widget/src/prompts/promptWidgetRid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export async function promptWidgetRid({
}): Promise<string> {
while (
widget == null
|| !/^ri\.viewregistry\.[^.]*\.view\.[^.]+$/.test(widget)
|| !/^ri\.widgetregistry\.\.widget\.[^.]+$/.test(widget)
) {
if (widget != null) {
consola.fail("Please enter a valid widget resource identifier (rid)");
}
widget = await consola.prompt(
`Enter the widget resource identifier (rid) for your widget:\n${
italic(
"(Example: ri.viewregistry.main.view.1c66b352-4e00-40d2-995d-061c9d533ace)",
"(Example: ri.widgetregistry..widget.1c66b352-4e00-40d2-995d-061c9d533ace)",
)
}`,
{ type: "text" },
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e.sandbox.todowidget/foundry.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"foundryUrl": "https://fake.palantirfoundry.com/",
"widget": {
"rid": "ri.viewregistry..view.fake",
"rid": "ri.widgetregistry..widget.fake",
"directory": "./dist",
"autoVersion": {
"type": "package-json"
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e.sandbox.todowidget/src/main.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "@osdk/widget-client.unstable";

export default defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
headerText: {
displayName: "Widget title",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e.sandbox.todowidget/src/second.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "@osdk/widget-client.unstable";

const Config = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.1234-0000-0000-0000",
rid: "ri.widgetregistry..widget.1234-0000-0000-0000",
parameters: {
headerText: {
displayName: "Widget title",
Expand Down
2 changes: 1 addition & 1 deletion packages/example-generator/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function generateExamples(tmpDir: tmp.DirResult): Promise<void> {
template,
sdkVersion,
foundryUrl: "https://fake.palantirfoundry.com",
widget: "ri.viewregistry.main.view.fake",
widget: "ri.widgetregistry..widget.fake",
osdkPackage,
osdkRegistryUrl:
"https://fake.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.main.repository.fake/contents/release/npm",
Expand Down
2 changes: 1 addition & 1 deletion packages/monorepo.cspell/cspell.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const cspell = {
"blueprintjs",
"picocolors",
// used in a RID template literal string
"viewregistry",
"widgetregistry",
],
},
{
Expand Down
18 changes: 9 additions & 9 deletions packages/widget.api.unstable/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("WidgetConfig", () => {
it("should be able to infer the type of the parameter ID", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand All @@ -52,7 +52,7 @@ describe("WidgetConfig", () => {
it("should construct a type safe map of async parameter values", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand All @@ -74,7 +74,7 @@ describe("WidgetConfig", () => {
it("should construct a type safe map of async parameter values with arrays", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("WidgetConfig", () => {
it("should construct a type safe map of parameter values", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -132,7 +132,7 @@ describe("WidgetConfig", () => {
it("should construct a type safe map of events that reference parameters", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -164,7 +164,7 @@ describe("WidgetConfig", () => {
it("will not extract an event that references a parameter ID that doesn't exist", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -197,7 +197,7 @@ describe("WidgetConfig", () => {
it("should extract event IDs correctly", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -233,7 +233,7 @@ describe("WidgetConfig", () => {
it("should extract an event to the parameter values", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -269,7 +269,7 @@ describe("WidgetConfig", () => {
const test = defineConfig({
type: "workshop",
// @ts-expect-error
rid: "ri.asdf..view.0000-0000-0000-0000",
rid: "ri.asdf..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget.api.unstable/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type ParameterConfig = Record<string, ParameterDefinition>;

export interface WidgetConfig<P extends ParameterConfig> {
parameters: ParameterConfig;
rid: `ri.viewregistry.${string}.view.${string}`;
rid: `ri.widgetregistry..widget.${string}`;
// TODO: Add specific config for each type of widget. For now, all the config is generic and can be used by any widget.
type: "workshop";
events: { [eventId: string]: EventDefinition<NoInfer<P>> };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("WidgetMessages", () => {
it("should emit an event with the correct payload", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -72,7 +72,7 @@ describe("WidgetMessages", () => {
it("should be able to assign specific events to the union", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget.api.unstable/src/metaTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

export const META_TAG_HOST_ORIGIN = "x-palantir-views-host-origin";
export const META_TAG_HOST_ORIGIN = "x-palantir-widgets-host-origin";
6 changes: 3 additions & 3 deletions packages/widget.client.unstable/src/host.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("FoundryHostEventTarget", () => {
it("should narrow the event payload based on host message type for addEventListener", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -69,7 +69,7 @@ describe("FoundryHostEventTarget", () => {
it("should narrow the event payload based on host message type for removeEventListener", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down Expand Up @@ -109,7 +109,7 @@ describe("FoundryHostEventTarget", () => {
it("should narrow the event payload when dispatching an event", () => {
const test = defineConfig({
type: "workshop",
rid: "ri.viewregistry..view.0000-0000-0000-0000",
rid: "ri.widgetregistry..widget.0000-0000-0000-0000",
parameters: {
test: {
displayName: "Testing",
Expand Down
6 changes: 3 additions & 3 deletions packages/widget.vite-plugin.unstable/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export function FoundryWidgetVitePlugin(_options: Options = {}): Plugin {
res.end(
JSON.stringify({
redirectUrl:
`${foundryUrl.origin}/workspace/custom-views/preview/${foundryConfig.foundryConfig.widget.rid}`,
`${foundryUrl.origin}/workspace/custom-widgets/preview/${foundryConfig.foundryConfig.widget.rid}`,
}),
);
} catch (error: any) {
Expand Down Expand Up @@ -588,7 +588,7 @@ function setWidgetSettings(
entrypointCss: [],
};
return fetch(
`${foundryUrl.origin}/view-registry/api/dev-mode/settings/${widgetRid}`,
`${foundryUrl.origin}/widget-registry/api/dev-mode/settings/${widgetRid}`,
{
body: JSON.stringify(widgetDevModeSettings),
method: "PUT",
Expand All @@ -602,7 +602,7 @@ function setWidgetSettings(
}

function enableDevMode(foundryUrl: URL) {
return fetch(`${foundryUrl.origin}/view-registry/api/dev-mode/enable`, {
return fetch(`${foundryUrl.origin}/widget-registry/api/dev-mode/enable`, {
method: "POST",
headers: {
authorization: `Bearer ${process.env.FOUNDRY_TOKEN}`,
Expand Down

0 comments on commit 314ae66

Please sign in to comment.