@osdk/widget.api 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +128 -0
- package/build/browser/config.js +41 -0
- package/build/browser/config.js.map +1 -0
- package/build/browser/config.test.js +243 -0
- package/build/browser/config.test.js.map +1 -0
- package/build/browser/index.js +22 -0
- package/build/browser/index.js.map +1 -0
- package/build/browser/manifest.js +18 -0
- package/build/browser/manifest.js.map +1 -0
- package/build/browser/manifest.test.js +57 -0
- package/build/browser/manifest.test.js.map +1 -0
- package/build/browser/messages/hostMessages.js +40 -0
- package/build/browser/messages/hostMessages.js.map +1 -0
- package/build/browser/messages/widgetMessages.js +37 -0
- package/build/browser/messages/widgetMessages.js.map +1 -0
- package/build/browser/messages/widgetMessages.test.js +94 -0
- package/build/browser/messages/widgetMessages.test.js.map +1 -0
- package/build/browser/metaTags.js +18 -0
- package/build/browser/metaTags.js.map +1 -0
- package/build/browser/parameters.js +23 -0
- package/build/browser/parameters.js.map +1 -0
- package/build/browser/parameters.test.js +38 -0
- package/build/browser/parameters.test.js.map +1 -0
- package/build/browser/utils/asyncValue.js +2 -0
- package/build/browser/utils/asyncValue.js.map +1 -0
- package/build/cjs/index.cjs +64 -0
- package/build/cjs/index.cjs.map +1 -0
- package/build/cjs/index.d.cts +289 -0
- package/build/esm/config.js +41 -0
- package/build/esm/config.js.map +1 -0
- package/build/esm/config.test.js +243 -0
- package/build/esm/config.test.js.map +1 -0
- package/build/esm/index.js +22 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/manifest.js +18 -0
- package/build/esm/manifest.js.map +1 -0
- package/build/esm/manifest.test.js +57 -0
- package/build/esm/manifest.test.js.map +1 -0
- package/build/esm/messages/hostMessages.js +40 -0
- package/build/esm/messages/hostMessages.js.map +1 -0
- package/build/esm/messages/widgetMessages.js +37 -0
- package/build/esm/messages/widgetMessages.js.map +1 -0
- package/build/esm/messages/widgetMessages.test.js +94 -0
- package/build/esm/messages/widgetMessages.test.js.map +1 -0
- package/build/esm/metaTags.js +18 -0
- package/build/esm/metaTags.js.map +1 -0
- package/build/esm/parameters.js +23 -0
- package/build/esm/parameters.js.map +1 -0
- package/build/esm/parameters.test.js +38 -0
- package/build/esm/parameters.test.js.map +1 -0
- package/build/esm/utils/asyncValue.js +2 -0
- package/build/esm/utils/asyncValue.js.map +1 -0
- package/build/types/config.d.ts +74 -0
- package/build/types/config.d.ts.map +1 -0
- package/build/types/config.test.d.ts +1 -0
- package/build/types/config.test.d.ts.map +1 -0
- package/build/types/index.d.ts +10 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/manifest.d.ts +64 -0
- package/build/types/manifest.d.ts.map +1 -0
- package/build/types/manifest.test.d.ts +1 -0
- package/build/types/manifest.test.d.ts.map +1 -0
- package/build/types/messages/hostMessages.d.ts +33 -0
- package/build/types/messages/hostMessages.d.ts.map +1 -0
- package/build/types/messages/widgetMessages.d.ts +36 -0
- package/build/types/messages/widgetMessages.d.ts.map +1 -0
- package/build/types/messages/widgetMessages.test.d.ts +1 -0
- package/build/types/messages/widgetMessages.test.d.ts.map +1 -0
- package/build/types/metaTags.d.ts +1 -0
- package/build/types/metaTags.d.ts.map +1 -0
- package/build/types/parameters.d.ts +43 -0
- package/build/types/parameters.d.ts.map +1 -0
- package/build/types/parameters.test.d.ts +1 -0
- package/build/types/parameters.test.d.ts.map +1 -0
- package/build/types/utils/asyncValue.d.ts +38 -0
- package/build/types/utils/asyncValue.d.ts.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":["defineConfig","c"],"sources":["config.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ParameterValue } from \"./parameters.js\";\nimport type { AsyncValue } from \"./utils/asyncValue.js\";\n\ninterface PrimitiveParameterDefinition<T extends ParameterValue.PrimitiveType> {\n type: T;\n displayName: string;\n}\ninterface ArrayParameterDefinition<S extends ParameterValue.PrimitiveType> {\n type: ParameterValue.Array[\"type\"];\n displayName: string;\n subType: S;\n}\nexport type ParameterDefinition =\n | PrimitiveParameterDefinition<ParameterValue.PrimitiveType>\n | ArrayParameterDefinition<ParameterValue.PrimitiveType>;\n\nexport interface EventDefinition<P extends ParameterConfig> {\n displayName: string;\n parameterUpdateIds: Array<ParameterId<P>>;\n}\n\nexport type ParameterConfig = Record<string, ParameterDefinition>;\n\nexport interface WidgetConfig<P extends ParameterConfig> {\n id: string;\n name: string;\n description?: string;\n // TODO: Add specific config for each type of widget. For now, all the config is generic and can be used by any widget.\n type: \"workshop\";\n parameters: ParameterConfig;\n events: { [eventId: string]: EventDefinition<NoInfer<P>> };\n}\n\n/**\n * Extracts the parameter ID strings as types from the given ParameterConfig.\n */\nexport type ParameterId<C extends ParameterConfig> = Extract<keyof C, string>;\n\n/**\n * Extracts a map of parameter IDs to their async-wrapped value types from the given ParameterConfig.\n */\nexport type AsyncParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [\n K in ParameterId<\n C[\"parameters\"]\n >\n ]: C[\"parameters\"][K] extends ArrayParameterDefinition<infer S>\n // If it's an array, pull out the subtype correctly\n ? Extract<\n ParameterValue.Array,\n { type: C[\"parameters\"][K][\"type\"]; subType: S }\n >[\"value\"] extends AsyncValue<infer P> ? {\n type: \"array\";\n subType: S;\n value: AsyncValue<P>;\n }\n : never\n : Extract<\n ParameterValue,\n { type: C[\"parameters\"][K][\"type\"] }\n >[\"value\"] extends AsyncValue<infer P> ? {\n type: C[\"parameters\"][K][\"type\"];\n value: AsyncValue<P>;\n }\n : never;\n};\n\n/**\n * Extracts a map of parameter IDs to the raw parameter values from the given ParameterConfig.\n */\nexport type ParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [\n K in ParameterId<\n C[\"parameters\"]\n >\n ]: C[\"parameters\"][K] extends ArrayParameterDefinition<infer S> ? Extract<\n ParameterValue.Array,\n { type: C[\"parameters\"][K][\"type\"]; subType: S }\n >[\"value\"] extends AsyncValue<infer P> ? P\n : never\n : Extract<\n ParameterValue,\n { type: C[\"parameters\"][K][\"type\"] }\n >[\"value\"] extends AsyncValue<infer P> ? P\n : never;\n};\n\nexport type EventId<C extends WidgetConfig<C[\"parameters\"]>> =\n keyof C[\"events\"];\n\n/**\n * Extracts a list of strongly-typed parameter IDs from the given WidgetConfig for a given event ID.\n * If a parameter ID is referenced by an event but does not exist, its type will be never\n */\nexport type EventParameterIdList<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = C[\"events\"][K][\"parameterUpdateIds\"] extends\n Array<ParameterId<C[\"parameters\"]>> ? C[\"events\"][K][\"parameterUpdateIds\"]\n : never;\n\n/**\n * Extracts a map of event IDs to their raw parameter value types from the given WidgetConfig.\n */\nexport type EventParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n [P in EventParameterIdList<C, K>[number]]: ParameterValueMap<C>[P];\n};\n\nexport function defineConfig<const C extends WidgetConfig<any>>(c: C): C {\n return c as any;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;;AAGA;AACA;AACA;;AA2BA;AACA;AACA;;AAqBA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAQA,OAAO,SAASA,YAAYA,CAAoCC,CAAI,EAAK;EACvE,OAAOA,CAAC;AACV","ignoreList":[]}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, expectTypeOf, it } from "vitest";
|
|
18
|
+
import { defineConfig } from "./config.js";
|
|
19
|
+
describe("WidgetConfig", () => {
|
|
20
|
+
describe("ParameterConfigId", () => {
|
|
21
|
+
it("should be able to infer the type of the parameter ID", () => {
|
|
22
|
+
defineConfig({
|
|
23
|
+
id: "widgetId",
|
|
24
|
+
name: "Widget Name",
|
|
25
|
+
description: "Widget Description",
|
|
26
|
+
type: "workshop",
|
|
27
|
+
parameters: {
|
|
28
|
+
test: {
|
|
29
|
+
displayName: "Testing",
|
|
30
|
+
type: "boolean"
|
|
31
|
+
},
|
|
32
|
+
test2: {
|
|
33
|
+
displayName: "Testing 2",
|
|
34
|
+
type: "string"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
events: {}
|
|
38
|
+
});
|
|
39
|
+
expectTypeOf().toEqualTypeOf();
|
|
40
|
+
});
|
|
41
|
+
it("should construct a type safe map of async parameter values", () => {
|
|
42
|
+
defineConfig({
|
|
43
|
+
id: "widgetId",
|
|
44
|
+
name: "Widget Name",
|
|
45
|
+
description: "Widget Description",
|
|
46
|
+
type: "workshop",
|
|
47
|
+
parameters: {
|
|
48
|
+
test: {
|
|
49
|
+
displayName: "Testing",
|
|
50
|
+
type: "boolean"
|
|
51
|
+
},
|
|
52
|
+
test2: {
|
|
53
|
+
displayName: "Testing 2",
|
|
54
|
+
type: "string"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
events: {}
|
|
58
|
+
});
|
|
59
|
+
expectTypeOf().toMatchTypeOf();
|
|
60
|
+
});
|
|
61
|
+
it("should construct a type safe map of async parameter values with arrays", () => {
|
|
62
|
+
defineConfig({
|
|
63
|
+
id: "widgetId",
|
|
64
|
+
name: "Widget Name",
|
|
65
|
+
description: "Widget Description",
|
|
66
|
+
type: "workshop",
|
|
67
|
+
parameters: {
|
|
68
|
+
test: {
|
|
69
|
+
displayName: "Testing",
|
|
70
|
+
type: "array",
|
|
71
|
+
subType: "boolean"
|
|
72
|
+
},
|
|
73
|
+
test2: {
|
|
74
|
+
displayName: "Testing 2",
|
|
75
|
+
type: "array",
|
|
76
|
+
subType: "string"
|
|
77
|
+
},
|
|
78
|
+
test3: {
|
|
79
|
+
displayName: "Testing 3",
|
|
80
|
+
type: "number"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
events: {}
|
|
84
|
+
});
|
|
85
|
+
expectTypeOf().toMatchTypeOf();
|
|
86
|
+
});
|
|
87
|
+
it("should construct a type safe map of parameter values", () => {
|
|
88
|
+
defineConfig({
|
|
89
|
+
id: "widgetId",
|
|
90
|
+
name: "Widget Name",
|
|
91
|
+
description: "Widget Description",
|
|
92
|
+
type: "workshop",
|
|
93
|
+
parameters: {
|
|
94
|
+
test: {
|
|
95
|
+
displayName: "Testing",
|
|
96
|
+
type: "array",
|
|
97
|
+
subType: "boolean"
|
|
98
|
+
},
|
|
99
|
+
test2: {
|
|
100
|
+
displayName: "Testing 2",
|
|
101
|
+
type: "array",
|
|
102
|
+
subType: "string"
|
|
103
|
+
},
|
|
104
|
+
test3: {
|
|
105
|
+
displayName: "Testing 3",
|
|
106
|
+
type: "number"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
events: {}
|
|
110
|
+
});
|
|
111
|
+
expectTypeOf().toMatchTypeOf();
|
|
112
|
+
});
|
|
113
|
+
it("should construct a type safe map of events that reference parameters", () => {
|
|
114
|
+
defineConfig({
|
|
115
|
+
id: "widgetId",
|
|
116
|
+
name: "Widget Name",
|
|
117
|
+
description: "Widget Description",
|
|
118
|
+
type: "workshop",
|
|
119
|
+
parameters: {
|
|
120
|
+
test: {
|
|
121
|
+
displayName: "Testing",
|
|
122
|
+
type: "array",
|
|
123
|
+
subType: "boolean"
|
|
124
|
+
},
|
|
125
|
+
test2: {
|
|
126
|
+
displayName: "Testing 2",
|
|
127
|
+
type: "array",
|
|
128
|
+
subType: "string"
|
|
129
|
+
},
|
|
130
|
+
test3: {
|
|
131
|
+
displayName: "Testing 3",
|
|
132
|
+
type: "number"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
events: {
|
|
136
|
+
myEvent: {
|
|
137
|
+
displayName: "My Event",
|
|
138
|
+
parameterUpdateIds: ["test"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
expectTypeOf().toMatchTypeOf();
|
|
143
|
+
});
|
|
144
|
+
it("will not extract an event that references a parameter ID that doesn't exist", () => {
|
|
145
|
+
defineConfig({
|
|
146
|
+
id: "widgetId",
|
|
147
|
+
name: "Widget Name",
|
|
148
|
+
description: "Widget Description",
|
|
149
|
+
type: "workshop",
|
|
150
|
+
parameters: {
|
|
151
|
+
test: {
|
|
152
|
+
displayName: "Testing",
|
|
153
|
+
type: "array",
|
|
154
|
+
subType: "boolean"
|
|
155
|
+
},
|
|
156
|
+
test2: {
|
|
157
|
+
displayName: "Testing 2",
|
|
158
|
+
type: "array",
|
|
159
|
+
subType: "string"
|
|
160
|
+
},
|
|
161
|
+
test3: {
|
|
162
|
+
displayName: "Testing 3",
|
|
163
|
+
type: "number"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
events: {
|
|
167
|
+
myEvent: {
|
|
168
|
+
displayName: "My Event",
|
|
169
|
+
parameterUpdateIds: ["test4"]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
expectTypeOf().toMatchTypeOf();
|
|
174
|
+
});
|
|
175
|
+
it("should extract event IDs correctly", () => {
|
|
176
|
+
defineConfig({
|
|
177
|
+
id: "widgetId",
|
|
178
|
+
name: "Widget Name",
|
|
179
|
+
description: "Widget Description",
|
|
180
|
+
type: "workshop",
|
|
181
|
+
parameters: {
|
|
182
|
+
test: {
|
|
183
|
+
displayName: "Testing",
|
|
184
|
+
type: "array",
|
|
185
|
+
subType: "boolean"
|
|
186
|
+
},
|
|
187
|
+
test2: {
|
|
188
|
+
displayName: "Testing 2",
|
|
189
|
+
type: "array",
|
|
190
|
+
subType: "string"
|
|
191
|
+
},
|
|
192
|
+
test3: {
|
|
193
|
+
displayName: "Testing 3",
|
|
194
|
+
type: "number"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
events: {
|
|
198
|
+
myEvent: {
|
|
199
|
+
displayName: "My Event",
|
|
200
|
+
parameterUpdateIds: ["test", "test2"]
|
|
201
|
+
},
|
|
202
|
+
myEvent2: {
|
|
203
|
+
displayName: "My second event",
|
|
204
|
+
parameterUpdateIds: []
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
expectTypeOf().toEqualTypeOf();
|
|
209
|
+
});
|
|
210
|
+
it("should extract an event to the parameter values", () => {
|
|
211
|
+
defineConfig({
|
|
212
|
+
id: "widgetId",
|
|
213
|
+
name: "Widget Name",
|
|
214
|
+
description: "Widget Description",
|
|
215
|
+
type: "workshop",
|
|
216
|
+
parameters: {
|
|
217
|
+
test: {
|
|
218
|
+
displayName: "Testing",
|
|
219
|
+
type: "array",
|
|
220
|
+
subType: "boolean"
|
|
221
|
+
},
|
|
222
|
+
test2: {
|
|
223
|
+
displayName: "Testing 2",
|
|
224
|
+
type: "array",
|
|
225
|
+
subType: "string"
|
|
226
|
+
},
|
|
227
|
+
test3: {
|
|
228
|
+
displayName: "Testing 3",
|
|
229
|
+
type: "number"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
events: {
|
|
233
|
+
myEvent: {
|
|
234
|
+
displayName: "My Event",
|
|
235
|
+
parameterUpdateIds: ["test", "test2"]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
expectTypeOf().toMatchTypeOf();
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test.js","names":["describe","expectTypeOf","it","defineConfig","id","name","description","type","parameters","test","displayName","test2","events","toEqualTypeOf","toMatchTypeOf","subType","test3","myEvent","parameterUpdateIds","myEvent2"],"sources":["config.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expectTypeOf, it } from \"vitest\";\nimport {\n type AsyncParameterValueMap,\n defineConfig,\n type EventId,\n type EventParameterIdList,\n type EventParameterValueMap,\n type ParameterId,\n type ParameterValueMap,\n} from \"./config.js\";\nimport type { ParameterValue } from \"./parameters.js\";\n\ndescribe(\"WidgetConfig\", () => {\n describe(\"ParameterConfigId\", () => {\n it(\"should be able to infer the type of the parameter ID\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"string\",\n },\n },\n events: {},\n });\n expectTypeOf<ParameterId<(typeof test)[\"parameters\"]>>().toEqualTypeOf<\n \"test\" | \"test2\"\n >();\n });\n\n it(\"should construct a type safe map of async parameter values\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"string\",\n },\n },\n events: {},\n });\n expectTypeOf<AsyncParameterValueMap<typeof test>>().toMatchTypeOf<{\n test: ParameterValue.Boolean;\n test2: ParameterValue.String;\n }>();\n });\n\n it(\"should construct a type safe map of async parameter values with arrays\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {},\n });\n expectTypeOf<AsyncParameterValueMap<typeof test>>().toMatchTypeOf<{\n test: ParameterValue.BooleanArray;\n test2: ParameterValue.StringArray;\n test3: ParameterValue.Number;\n }>();\n });\n\n it(\"should construct a type safe map of parameter values\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {},\n });\n expectTypeOf<ParameterValueMap<typeof test>>().toMatchTypeOf<{\n test: boolean[];\n test2: string[];\n test3: number;\n }>();\n });\n\n it(\"should construct a type safe map of events that reference parameters\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\"],\n },\n },\n });\n expectTypeOf<\n EventParameterIdList<typeof test, \"myEvent\">\n >().toMatchTypeOf<[\"test\"]>();\n });\n\n it(\"will not extract an event that references a parameter ID that doesn't exist\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test4\"],\n },\n },\n });\n expectTypeOf<\n // @ts-expect-error\n EventParameterIdList<typeof test, \"myEvent\">\n >().toMatchTypeOf<never>();\n });\n\n it(\"should extract event IDs correctly\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\", \"test2\"],\n },\n myEvent2: {\n displayName: \"My second event\",\n parameterUpdateIds: [],\n },\n },\n });\n expectTypeOf<EventId<typeof test>>().toEqualTypeOf<\n \"myEvent\" | \"myEvent2\"\n >();\n });\n\n it(\"should extract an event to the parameter values\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\", \"test2\"],\n },\n },\n });\n expectTypeOf<\n EventParameterValueMap<typeof test, \"myEvent\">\n >().toMatchTypeOf<{\n test: boolean[];\n test2: string[];\n }>();\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AACnD,SAEEC,YAAY,QAMP,aAAa;AAGpBH,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC7BA,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IAClCE,EAAE,CAAC,sDAAsD,EAAE,MAAM;MAClDC,YAAY,CAAC;QACxBC,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,aAAa;QACnBC,WAAW,EAAE,oBAAoB;QACjCC,IAAI,EAAE,UAAU;QAChBC,UAAU,EAAE;UACVC,IAAI,EAAE;YACJC,WAAW,EAAE,SAAS;YACtBH,IAAI,EAAE;UACR,CAAC;UACDI,KAAK,EAAE;YACLD,WAAW,EAAE,WAAW;YACxBH,IAAI,EAAE;UACR;QACF,CAAC;QACDK,MAAM,EAAE,CAAC;MACX,CAAC,CAAC;MACFX,YAAY,CAA2C,CAAC,CAACY,aAAa,CAEpE,CAAC;IACL,CAAC,CAAC;IAEFX,EAAE,CAAC,4DAA4D,EAAE,MAAM;MACxDC,YAAY,CAAC;QACxBC,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,aAAa;QACnBC,WAAW,EAAE,oBAAoB;QACjCC,IAAI,EAAE,UAAU;QAChBC,UAAU,EAAE;UACV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ACDJ,KAAK,EAAE;YACLD,WAAW,EAAE,WAAW;YACxBH,IAAI,EAAE,OAAO;YACbQ,OAAO,EAAE;UACX,CAAC;UACDC,KAAK,EAAE;YACLN,WAAW,EAAE,WAAW;YACxBH,IAAI,EAAE;UACR;QACF,CAAC;QACDK,MAAM,EAAE;UACNK,OAAO,EAAE;YACPP,WAAW,EAAE,UAAU;YACvBQ,kBAAkB,EAAE,CAAC,MAAM,EAAE,OAAO;UACtC;QACF;MACF,CAAC,CAAC;MACFjB,YAAY,CAEV,CAAC,CAACa,aAAa,CAGd,CAAC;IACN,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export { defineConfig } from "./config.js";
|
|
18
|
+
export { MANIFEST_FILE_LOCATION } from "./manifest.js";
|
|
19
|
+
export { HostMessage, isHostParametersUpdatedMessage, visitHostMessage } from "./messages/hostMessages.js";
|
|
20
|
+
export { isWidgetEmitEventMessage, isWidgetReadyMessage, visitWidgetMessage } from "./messages/widgetMessages.js";
|
|
21
|
+
export { META_TAG_HOST_ORIGIN } from "./metaTags.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["defineConfig","MANIFEST_FILE_LOCATION","HostMessage","isHostParametersUpdatedMessage","visitHostMessage","isWidgetEmitEventMessage","isWidgetReadyMessage","visitWidgetMessage","META_TAG_HOST_ORIGIN"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type {\n AsyncParameterValueMap,\n EventId,\n EventParameterValueMap,\n ParameterConfig,\n ParameterDefinition,\n ParameterValueMap,\n WidgetConfig,\n} from \"./config.js\";\nexport { defineConfig } from \"./config.js\";\nexport type {\n WidgetManifestConfigV1 as WidgetManifestConfig,\n WidgetSetManifestV1 as WidgetSetManifest,\n} from \"./manifest.js\";\nexport { MANIFEST_FILE_LOCATION } from \"./manifest.js\";\nexport {\n HostMessage,\n isHostParametersUpdatedMessage,\n visitHostMessage,\n} from \"./messages/hostMessages.js\";\nexport {\n isWidgetEmitEventMessage,\n isWidgetReadyMessage,\n visitWidgetMessage,\n} from \"./messages/widgetMessages.js\";\nexport type { WidgetMessage } from \"./messages/widgetMessages.js\";\nexport { META_TAG_HOST_ORIGIN } from \"./metaTags.js\";\nexport type { ParameterValue } from \"./parameters.js\";\nexport type {\n AsyncFailedValue,\n AsyncLoadedValue,\n AsyncLoadingValue,\n AsyncNotStartedLoadingValue,\n AsyncReloadingValue,\n AsyncValue,\n} from \"./utils/asyncValue.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SAASA,YAAY,QAAQ,aAAa;AAK1C,SAASC,sBAAsB,QAAQ,eAAe;AACtD,SACEC,WAAW,EACXC,8BAA8B,EAC9BC,gBAAgB,QACX,4BAA4B;AACnC,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,kBAAkB,QACb,8BAA8B;AAErC,SAASC,oBAAoB,QAAQ,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const MANIFEST_FILE_LOCATION = ".palantir/widgets.config.json";
|
|
18
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","names":["MANIFEST_FILE_LOCATION"],"sources":["manifest.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n EventDefinition,\n ParameterConfig,\n ParameterDefinition,\n} from \"./config.js\";\n\nexport interface WidgetSetManifestV1 {\n manifestVersion: \"1.0.0\";\n widgetSet: WidgetSetManifestContentV1;\n}\n\nexport interface WidgetSetManifestContentV1 {\n /**\n * RID of the widget set that this config corresponds to\n */\n rid: string;\n\n /**\n * The version of the widget to publish as\n */\n version: string;\n\n /**\n * Set of widgets that are available to be rendered.\n * The key can be arbitrary, and is usually the name of your entrypoint, e.g. \"main\"\n */\n widgets: Record<string, WidgetManifestConfigV1>;\n}\n\nexport interface WidgetManifestConfigV1 {\n /**\n * The ID of this widget. Must be unique within the widget set\n */\n id: string;\n\n /**\n * The user friendly name of this widget\n */\n name: string;\n\n /**\n * A user friendly description of this widget\n */\n description?: string;\n\n /**\n * The target Foundry UI that this widget is intended to be used in\n */\n type: \"workshopWidgetV1\";\n\n /**\n * List of entrypoint JS files to be loaded, in order. These will be placed on the page in script tags\n */\n entrypointJs: Array<{\n /** Relative path of the JS file to load */\n path: string;\n\n /** The type to use in the script tag when loading this JS file */\n type: \"module\" | \"text/javascript\";\n }>;\n\n /**\n * Any CSS files to be loaded, in order.\n * @optional\n */\n entrypointCss?: Array<{\n /** Relative path of the CSS file to load */\n path: string;\n }>;\n\n /**\n * The map of parameter IDs to their definition\n */\n parameters: Record<string, ParameterDefinition>;\n\n /**\n * The map of events to their definition. Any parameter IDs referenced must be defined in the `parameters` field\n */\n events: Record<string, EventDefinition<ParameterConfig>>;\n}\n\nexport const MANIFEST_FILE_LOCATION = \".palantir/widgets.config.json\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmFA,OAAO,MAAMA,sBAAsB,GAAG,+BAA+B","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { expectTypeOf, test } from "vitest";
|
|
18
|
+
const EXAMPLE_WIDGET_SET_MANIFEST = {
|
|
19
|
+
"manifestVersion": "1.0.0",
|
|
20
|
+
"widgetSet": {
|
|
21
|
+
"rid": "ri.widgetregistry..widget-set.placeholder",
|
|
22
|
+
"version": "0.1.0",
|
|
23
|
+
"widgets": {
|
|
24
|
+
"widget1": {
|
|
25
|
+
"id": "widget1",
|
|
26
|
+
"name": "My name",
|
|
27
|
+
"description": "My description",
|
|
28
|
+
"type": "workshopWidgetV1",
|
|
29
|
+
"entrypointJs": [{
|
|
30
|
+
"path": "app.js",
|
|
31
|
+
"type": "module"
|
|
32
|
+
}],
|
|
33
|
+
"entrypointCss": [{
|
|
34
|
+
"path": "app.css"
|
|
35
|
+
}],
|
|
36
|
+
"parameters": {
|
|
37
|
+
"myString": {
|
|
38
|
+
"displayName": "My String",
|
|
39
|
+
"type": "string"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"events": {
|
|
43
|
+
"event1": {
|
|
44
|
+
"displayName": "Event 1",
|
|
45
|
+
"parameterUpdateIds": ["myString"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// These tests don't actually need executing, as compilation is enough to verify the types are correct
|
|
54
|
+
test("WidgetSetManifestV1", () => {
|
|
55
|
+
expectTypeOf(EXAMPLE_WIDGET_SET_MANIFEST).toEqualTypeOf();
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=manifest.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.test.js","names":["expectTypeOf","test","EXAMPLE_WIDGET_SET_MANIFEST","toEqualTypeOf"],"sources":["manifest.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { expectTypeOf, test } from \"vitest\";\nimport type { WidgetSetManifestV1 } from \"./manifest.js\";\n\nconst EXAMPLE_WIDGET_SET_MANIFEST: WidgetSetManifestV1 = {\n \"manifestVersion\": \"1.0.0\" as const,\n \"widgetSet\": {\n \"rid\": \"ri.widgetregistry..widget-set.placeholder\",\n \"version\": \"0.1.0\",\n \"widgets\": {\n \"widget1\": {\n \"id\": \"widget1\",\n \"name\": \"My name\",\n \"description\": \"My description\",\n \"type\": \"workshopWidgetV1\",\n \"entrypointJs\": [\n {\n \"path\": \"app.js\",\n \"type\": \"module\",\n },\n ],\n \"entrypointCss\": [\n {\n \"path\": \"app.css\",\n },\n ],\n \"parameters\": {\n \"myString\": {\n \"displayName\": \"My String\",\n \"type\": \"string\",\n },\n },\n \"events\": {\n \"event1\": {\n \"displayName\": \"Event 1\",\n \"parameterUpdateIds\": [\n \"myString\",\n ],\n },\n },\n },\n },\n },\n};\n\n// These tests don't actually need executing, as compilation is enough to verify the types are correct\ntest(\"WidgetSetManifestV1\", () => {\n expectTypeOf(EXAMPLE_WIDGET_SET_MANIFEST).toEqualTypeOf<\n WidgetSetManifestV1\n >();\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,EAAEC,IAAI,QAAQ,QAAQ;AAG3C,MAAMC,2BAAgD,GAAG;EACvD,iBAAiB,EAAE,OAAgB;EACnC,WAAW,EAAE;IACX,KAAK,EAAE,2CAA2C;IAClD,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE;MACT,SAAS,EAAE;QACT,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,aAAa,EAAE,gBAAgB;QAC/B,MAAM,EAAE,kBAAkB;QAC1B,cAAc,EAAE,CACd;UACE,MAAM,EAAE,QAAQ;UAChB,MAAM,EAAE;QACV,CAAC,CACF;QACD,eAAe,EAAE,CACf;UACE,MAAM,EAAE;QACV,CAAC,CACF;QACD,YAAY,EAAE;UACZ,UAAU,EAAE;YACV,aAAa,EAAE,WAAW;YAC1B,MAAM,EAAE;UACV;QACF,CAAC;QACD,QAAQ,EAAE;UACR,QAAQ,EAAE;YACR,aAAa,EAAE,SAAS;YACxB,oBAAoB,EAAE,CACpB,UAAU;UAEd;QACF;MACF;IACF;EACF;AACF,CAAC;;AAED;AACAD,IAAI,CAAC,qBAAqB,EAAE,MAAM;EAChCD,YAAY,CAACE,2BAA2B,CAAC,CAACC,aAAa,CAErD,CAAC;AACL,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
// Interfaces and type guards for messages passed from the host Foundry UI to the widget
|
|
17
|
+
export let HostMessage;
|
|
18
|
+
(function (_HostMessage) {
|
|
19
|
+
_HostMessage.Version = "1.0.0";
|
|
20
|
+
})(HostMessage || (HostMessage = {}));
|
|
21
|
+
export function isHostParametersUpdatedMessage(event) {
|
|
22
|
+
return event.type === "host.update-parameters";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Strongly typed visitor to handle every type of host message
|
|
26
|
+
*/
|
|
27
|
+
export function visitHostMessage(message, visitor) {
|
|
28
|
+
const {
|
|
29
|
+
type,
|
|
30
|
+
payload
|
|
31
|
+
} = message;
|
|
32
|
+
const handler = visitor[type];
|
|
33
|
+
if (handler) {
|
|
34
|
+
// Typescript creates an & of the parameters instead of a union
|
|
35
|
+
handler(payload);
|
|
36
|
+
} else {
|
|
37
|
+
visitor._unknown(type);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=hostMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostMessages.js","names":["HostMessage","_HostMessage","Version","isHostParametersUpdatedMessage","event","type","visitHostMessage","message","visitor","payload","handler","_unknown"],"sources":["hostMessages.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AsyncParameterValueMap, WidgetConfig } from \"../config.js\";\n\n// Interfaces and type guards for messages passed from the host Foundry UI to the widget\ninterface HostBaseMessage<T extends string, P = unknown> {\n type: T;\n payload: P;\n}\n\nexport namespace HostMessage {\n export const Version = \"1.0.0\";\n export type Version = typeof Version;\n\n export namespace Payload {\n export interface UpdateParameters<C extends WidgetConfig<C[\"parameters\"]>> {\n parameters: AsyncParameterValueMap<C>;\n }\n }\n\n export type Payload = Payload.UpdateParameters<any>;\n\n export interface UpdateParameters<C extends WidgetConfig<C[\"parameters\"]>>\n extends\n HostBaseMessage<\n \"host.update-parameters\",\n Payload.UpdateParameters<C>\n >\n {}\n}\n\nexport type HostMessage<C extends WidgetConfig<C[\"parameters\"]>> =\n HostMessage.UpdateParameters<C>;\n\nexport function isHostParametersUpdatedMessage<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(event: HostMessage<C>): event is HostMessage.UpdateParameters<C> {\n return event.type === \"host.update-parameters\";\n}\n\ntype HostMessageVisitor<C extends WidgetConfig<C[\"parameters\"]>> =\n & {\n [T in HostMessage<C>[\"type\"]]: (\n payload: Extract<HostMessage<C>, { type: T }> extends {\n payload: infer P;\n } ? P\n : never,\n ) => void;\n }\n & {\n _unknown: (type: string) => void;\n };\n\n/**\n * Strongly typed visitor to handle every type of host message\n */\nexport function visitHostMessage<C extends WidgetConfig<C[\"parameters\"]>>(\n message: HostMessage<C>,\n visitor: HostMessageVisitor<C>,\n): void {\n const { type, payload } = message;\n const handler = visitor[type];\n if (handler) {\n // Typescript creates an & of the parameters instead of a union\n (handler as any)(payload);\n } else {\n visitor._unknown(type);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAAA,WAMiBA,WAAW;AAAA,WAAAC,YAAA;EAAAA,YAAA,CAAAC,OAAA,GACH,OAAO;AAAA,GADfF,WAAW,KAAXA,WAAW;AAwB5B,OAAO,SAASG,8BAA8BA,CAE5CC,KAAqB,EAA4C;EACjE,OAAOA,KAAK,CAACC,IAAI,KAAK,wBAAwB;AAChD;AAeA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,OAAuB,EACvBC,OAA8B,EACxB;EACN,MAAM;IAAEH,IAAI;IAAEI;EAAQ,CAAC,GAAGF,OAAO;EACjC,MAAMG,OAAO,GAAGF,OAAO,CAACH,IAAI,CAAC;EAC7B,IAAIK,OAAO,EAAE;IACX;IACCA,OAAO,CAASD,OAAO,CAAC;EAC3B,CAAC,MAAM;IACLD,OAAO,CAACG,QAAQ,CAACN,IAAI,CAAC;EACxB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
// Interfaces and type guards for messages passed from the widget to the host Foundry UI
|
|
17
|
+
export let WidgetMessage;
|
|
18
|
+
export function isWidgetReadyMessage(event) {
|
|
19
|
+
return event.type === "widget.ready";
|
|
20
|
+
}
|
|
21
|
+
export function isWidgetEmitEventMessage(event) {
|
|
22
|
+
return event.type === "widget.emit-event";
|
|
23
|
+
}
|
|
24
|
+
export function visitWidgetMessage(message, visitor) {
|
|
25
|
+
const {
|
|
26
|
+
type,
|
|
27
|
+
payload
|
|
28
|
+
} = message;
|
|
29
|
+
const handler = visitor[type];
|
|
30
|
+
if (handler) {
|
|
31
|
+
// Typescript creates an & of the parameters instead of a union
|
|
32
|
+
handler(payload);
|
|
33
|
+
} else {
|
|
34
|
+
visitor._unknown(type);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=widgetMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgetMessages.js","names":["WidgetMessage","isWidgetReadyMessage","event","type","isWidgetEmitEventMessage","visitWidgetMessage","message","visitor","payload","handler","_unknown"],"sources":["widgetMessages.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n EventId,\n EventParameterValueMap,\n WidgetConfig,\n} from \"../config.js\";\nimport type { HostMessage } from \"./hostMessages.js\";\n\n// Interfaces and type guards for messages passed from the widget to the host Foundry UI\n\ninterface WidgetBaseMessage<T extends string, P = unknown> {\n type: T;\n payload: P;\n}\n\ntype EmitEventIdMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [K in EventId<C>]: {\n eventId: K;\n parameterUpdates: EventParameterValueMap<C, K>;\n };\n};\n\nexport namespace WidgetMessage {\n export namespace Payload {\n export interface Ready {\n apiVersion: HostMessage.Version;\n }\n\n export type EmitEvent<C extends WidgetConfig<C[\"parameters\"]>> =\n EmitEventIdMap<C>[EventId<C>];\n }\n\n export type Payload<C extends WidgetConfig<C[\"parameters\"]>> =\n | Payload.Ready\n | Payload.EmitEvent<C>;\n\n /**\n * Emit when the widget is ready to start receiving messages from the host Foundry UI\n */\n export interface Ready\n extends WidgetBaseMessage<\"widget.ready\", Payload.Ready>\n {}\n\n /**\n * Event payload that the widget sends to the host Foundry UI\n */\n export interface EmitEvent<C extends WidgetConfig<C[\"parameters\"]>>\n extends WidgetBaseMessage<\"widget.emit-event\", Payload.EmitEvent<C>>\n {}\n}\n\nexport type WidgetMessage<C extends WidgetConfig<C[\"parameters\"]>> =\n | WidgetMessage.Ready\n | WidgetMessage.EmitEvent<C>;\n\nexport function isWidgetReadyMessage<C extends WidgetConfig<C[\"parameters\"]>>(\n event: WidgetMessage<C>,\n): event is WidgetMessage.Ready {\n return event.type === \"widget.ready\";\n}\n\nexport function isWidgetEmitEventMessage<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(event: WidgetMessage<C>): event is WidgetMessage.EmitEvent<C> {\n return event.type === \"widget.emit-event\";\n}\n\ntype WidgetMessageVisitor<C extends WidgetConfig<C[\"parameters\"]>> =\n & {\n [T in WidgetMessage<C>[\"type\"]]: (\n payload: Extract<WidgetMessage<C>, { type: T }> extends {\n payload: infer P;\n } ? P\n : never,\n ) => void;\n }\n & {\n _unknown: (type: string) => void;\n };\n\nexport function visitWidgetMessage<C extends WidgetConfig<C[\"parameters\"]>>(\n message: WidgetMessage<C>,\n visitor: WidgetMessageVisitor<C>,\n): void {\n const { type, payload } = message;\n const handler = visitor[type];\n if (handler) {\n // Typescript creates an & of the parameters instead of a union\n (handler as any)(payload);\n } else {\n visitor._unknown(type);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA;AAAA,WAciBA,aAAa;AAiC9B,OAAO,SAASC,oBAAoBA,CAClCC,KAAuB,EACO;EAC9B,OAAOA,KAAK,CAACC,IAAI,KAAK,cAAc;AACtC;AAEA,OAAO,SAASC,wBAAwBA,CAEtCF,KAAuB,EAAuC;EAC9D,OAAOA,KAAK,CAACC,IAAI,KAAK,mBAAmB;AAC3C;AAeA,OAAO,SAASE,kBAAkBA,CAChCC,OAAyB,EACzBC,OAAgC,EAC1B;EACN,MAAM;IAAEJ,IAAI;IAAEK;EAAQ,CAAC,GAAGF,OAAO;EACjC,MAAMG,OAAO,GAAGF,OAAO,CAACJ,IAAI,CAAC;EAC7B,IAAIM,OAAO,EAAE;IACX;IACCA,OAAO,CAASD,OAAO,CAAC;EAC3B,CAAC,MAAM;IACLD,OAAO,CAACG,QAAQ,CAACP,IAAI,CAAC;EACxB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, expectTypeOf, it } from "vitest";
|
|
18
|
+
import { defineConfig } from "../config.js";
|
|
19
|
+
describe("WidgetMessages", () => {
|
|
20
|
+
describe("EmitEvent", () => {
|
|
21
|
+
it("should emit an event with the correct payload", () => {
|
|
22
|
+
defineConfig({
|
|
23
|
+
id: "widgetId",
|
|
24
|
+
name: "Widget Name",
|
|
25
|
+
description: "Widget Description",
|
|
26
|
+
type: "workshop",
|
|
27
|
+
parameters: {
|
|
28
|
+
test: {
|
|
29
|
+
displayName: "Testing",
|
|
30
|
+
type: "array",
|
|
31
|
+
subType: "boolean"
|
|
32
|
+
},
|
|
33
|
+
test2: {
|
|
34
|
+
displayName: "Testing 2",
|
|
35
|
+
type: "array",
|
|
36
|
+
subType: "string"
|
|
37
|
+
},
|
|
38
|
+
test3: {
|
|
39
|
+
displayName: "Testing 3",
|
|
40
|
+
type: "number"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
events: {
|
|
44
|
+
myEvent: {
|
|
45
|
+
displayName: "My Event",
|
|
46
|
+
parameterUpdateIds: ["test"]
|
|
47
|
+
},
|
|
48
|
+
myEvent2: {
|
|
49
|
+
displayName: "My Event 2",
|
|
50
|
+
parameterUpdateIds: ["test", "test2"]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
expectTypeOf().toMatchTypeOf();
|
|
55
|
+
expectTypeOf().toMatchTypeOf();
|
|
56
|
+
});
|
|
57
|
+
it("should be able to assign specific events to the union", () => {
|
|
58
|
+
defineConfig({
|
|
59
|
+
id: "widgetId",
|
|
60
|
+
name: "Widget Name",
|
|
61
|
+
description: "Widget Description",
|
|
62
|
+
type: "workshop",
|
|
63
|
+
parameters: {
|
|
64
|
+
test: {
|
|
65
|
+
displayName: "Testing",
|
|
66
|
+
type: "array",
|
|
67
|
+
subType: "boolean"
|
|
68
|
+
},
|
|
69
|
+
test2: {
|
|
70
|
+
displayName: "Testing 2",
|
|
71
|
+
type: "array",
|
|
72
|
+
subType: "string"
|
|
73
|
+
},
|
|
74
|
+
test3: {
|
|
75
|
+
displayName: "Testing 3",
|
|
76
|
+
type: "number"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
events: {
|
|
80
|
+
myEvent: {
|
|
81
|
+
displayName: "My Event",
|
|
82
|
+
parameterUpdateIds: ["test"]
|
|
83
|
+
},
|
|
84
|
+
myEvent2: {
|
|
85
|
+
displayName: "My Event 2",
|
|
86
|
+
parameterUpdateIds: ["test", "test2"]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
expectTypeOf().toMatchTypeOf();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=widgetMessages.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgetMessages.test.js","names":["describe","expectTypeOf","it","defineConfig","id","name","description","type","parameters","test","displayName","subType","test2","test3","events","myEvent","parameterUpdateIds","myEvent2","toMatchTypeOf"],"sources":["widgetMessages.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expectTypeOf, it } from \"vitest\";\nimport { defineConfig } from \"../config.js\";\nimport type { WidgetMessage } from \"./widgetMessages.js\";\n\ndescribe(\"WidgetMessages\", () => {\n describe(\"EmitEvent\", () => {\n it(\"should emit an event with the correct payload\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\"],\n },\n myEvent2: {\n displayName: \"My Event 2\",\n parameterUpdateIds: [\"test\", \"test2\"],\n },\n },\n });\n expectTypeOf<{\n type: \"widget.emit-event\";\n payload: {\n eventId: \"myEvent\";\n parameterUpdates: {\n test: boolean[];\n };\n };\n }>().toMatchTypeOf<WidgetMessage<typeof test>>();\n expectTypeOf<{\n eventId: \"myEvent2\";\n parameterUpdates: {\n test: boolean[];\n test2: string[];\n };\n }>().toMatchTypeOf<WidgetMessage.Payload.EmitEvent<typeof test>>();\n });\n\n it(\"should be able to assign specific events to the union\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\"],\n },\n myEvent2: {\n displayName: \"My Event 2\",\n parameterUpdateIds: [\"test\", \"test2\"],\n },\n },\n });\n expectTypeOf<{\n type: \"widget.emit-event\";\n payload: {\n eventId: \"myEvent\";\n parameterUpdates: {\n test: boolean[];\n };\n };\n }>().toMatchTypeOf<WidgetMessage<typeof test>>();\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AACnD,SAASC,YAAY,QAAQ,cAAc;AAG3CH,QAAQ,CAAC,gBAAgB,EAAE,MAAM;EAC/BA,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC1BE,EAAE,CAAC,+CAA+C,EAAE,MAAM;MAC3CC,YAAY,CAAC;QACxBC,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,aAAa;QACnBC,WAAW,EAAE,oBAAoB;QACjCC,IAAI,EAAE,UAAU;QAChBC,UAAU,EAAE;UACVC,IAAI,EAAE;YACJC,WAAW,EAAE,SAAS;YACtBH,IAAI,EAAE,OAAO;YACbI,OAAO,EAAE;UACX,CAAC;UACDC,KAAK,EAAE;YACLF,WAAW,EAAE,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CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const META_TAG_HOST_ORIGIN = "x-palantir-widgets-host-origin";
|
|
18
|
+
//# sourceMappingURL=metaTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metaTags.js","names":["META_TAG_HOST_ORIGIN"],"sources":["metaTags.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const META_TAG_HOST_ORIGIN = \"x-palantir-widgets-host-origin\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,oBAAoB,GAAG,gCAAgC","ignoreList":[]}
|