@osdk/widget.api 3.2.0-beta.4 → 3.3.0-beta.1
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 +6 -0
- package/build/browser/config.js.map +1 -1
- package/build/browser/config.test.js +24 -0
- package/build/browser/config.test.js.map +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/manifest.js.map +1 -1
- package/build/browser/parameters.js.map +1 -1
- package/build/cjs/index.d.cts +33 -5
- package/build/esm/config.js.map +1 -1
- package/build/esm/config.test.js +24 -0
- package/build/esm/config.test.js.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/manifest.js.map +1 -1
- package/build/esm/parameters.js.map +1 -1
- package/build/types/config.d.ts +17 -3
- package/build/types/config.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/manifest.d.ts +2 -2
- package/build/types/manifest.d.ts.map +1 -1
- package/build/types/parameters.d.ts +15 -1
- package/build/types/parameters.d.ts.map +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1 +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> = NotEmptyObject<\n {\n [P in EventParameterIdList<C, K>[number]]: ParameterValueMap<C>[P];\n }\n>;\n\ntype NotEmptyObject<T extends Record<string, any>> = T extends\n Record<string, never> ? Record<string, never>\n : T;\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;;
|
|
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 { ObjectType, 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}\ninterface ObjectSetParameterDefinition<T extends ObjectType> {\n type: \"objectSet\";\n displayName: string;\n objectType: T;\n}\nexport type ParameterDefinition =\n | PrimitiveParameterDefinition<ParameterValue.PrimitiveType>\n | ArrayParameterDefinition<ParameterValue.PrimitiveType>\n | ObjectSetParameterDefinition<ObjectType>;\n\ninterface ManifestObjectSetParameterDefinition<T extends ObjectType> {\n type: ObjectSetParameterDefinition<T>[\"type\"];\n displayName: string;\n objectTypeRids: [string];\n}\n\nexport type ManifestParameterDefinition =\n | PrimitiveParameterDefinition<ParameterValue.PrimitiveType>\n | ArrayParameterDefinition<ParameterValue.PrimitiveType>\n | ManifestObjectSetParameterDefinition<ObjectType>;\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 : C[\"parameters\"][K] extends ObjectSetParameterDefinition<infer T>\n ? ParameterValue.ObjectSet<T>[\"value\"] extends AsyncValue<infer P> ? {\n type: \"objectSet\";\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 : C[\"parameters\"][K] extends ObjectSetParameterDefinition<infer T>\n ? ParameterValue.ObjectSet<T>[\"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> = NotEmptyObject<\n {\n [P in EventParameterIdList<C, K>[number]]: ParameterValueMap<C>[P];\n }\n>;\n\ntype NotEmptyObject<T extends Record<string, any>> = T extends\n Record<string, never> ? Record<string, never>\n : T;\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;;AAoDA;AACA;AACA;;AAGA;AACA;AACA;;AAiCA;AACA;AACA;;AAwBA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAcA,OAAO,SAASA,YAAYA,CAAoCC,CAAI,EAAK;EACvE,OAAOA,CAAC;AACV","ignoreList":[]}
|
|
@@ -238,6 +238,30 @@ describe("WidgetConfig", () => {
|
|
|
238
238
|
});
|
|
239
239
|
expectTypeOf().toMatchTypeOf();
|
|
240
240
|
});
|
|
241
|
+
it("should support objectSet parameter types with generic object type", () => {
|
|
242
|
+
defineConfig({
|
|
243
|
+
id: "widgetId",
|
|
244
|
+
name: "Widget Name",
|
|
245
|
+
description: "Widget Description",
|
|
246
|
+
type: "workshop",
|
|
247
|
+
parameters: {
|
|
248
|
+
myObjectSet: {
|
|
249
|
+
displayName: "My Object Set",
|
|
250
|
+
type: "objectSet",
|
|
251
|
+
objectType: {
|
|
252
|
+
type: "object",
|
|
253
|
+
apiName: "employee",
|
|
254
|
+
experimentalDoNotUseMetadata: {
|
|
255
|
+
rid: "ri.object-type.employee"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
events: {}
|
|
261
|
+
});
|
|
262
|
+
expectTypeOf().toEqualTypeOf();
|
|
263
|
+
expectTypeOf().toEqualTypeOf();
|
|
264
|
+
});
|
|
241
265
|
});
|
|
242
266
|
});
|
|
243
267
|
//# sourceMappingURL=config.test.js.map
|
|
@@ -1 +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;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,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
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","myObjectSet","objectType","apiName","experimentalDoNotUseMetadata","rid"],"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 type { ObjectTypeDefinition } from \"@osdk/api\";\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 { ObjectType, ParameterValue } from \"./parameters.js\";\nimport type { AsyncValue } from \"./utils/asyncValue.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 it(\"should support objectSet parameter types with generic object type\", () => {\n const Employee = {\n type: \"object\",\n apiName: \"employee\",\n experimentalDoNotUseMetadata: {\n rid: \"ri.object-type.employee\",\n },\n } as const satisfies ObjectTypeDefinition & {\n experimentalDoNotUseMetadata: { rid: string };\n } & ObjectType;\n\n type Employee = typeof Employee;\n\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n myObjectSet: {\n displayName: \"My Object Set\",\n type: \"objectSet\",\n objectType: Employee,\n },\n },\n events: {},\n });\n\n expectTypeOf<ParameterValueMap<typeof test>>().toEqualTypeOf<{\n myObjectSet: {\n objectSetRid: string;\n };\n }>();\n\n expectTypeOf<AsyncParameterValueMap<typeof test>>().toEqualTypeOf<{\n myObjectSet: {\n type: \"objectSet\";\n value: AsyncValue<{\n objectSetRid: string;\n }>;\n };\n }>();\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AACnD,SAEEC,YAAY,QAMP,aAAa;AAIpBH,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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,CAIzD,CAAC;MAEJZ,YAAY,CAAsC,CAAC,CAACY,aAAa,CAO9D,CAAC;IACN,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["defineConfig","MANIFEST_FILE_LOCATION","HostMessage","isHostParametersUpdatedMessage","visitHostMessage","isWidgetEmitEventMessage","isWidgetReadyMessage","visitWidgetMessage"],"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 OntologySdkInputSpecV1 as OntologySdkInputSpec,\n WidgetManifestConfigV1 as WidgetManifestConfig,\n WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec,\n WidgetSetInputSpecV1 as WidgetSetInputSpec,\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 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;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["defineConfig","MANIFEST_FILE_LOCATION","HostMessage","isHostParametersUpdatedMessage","visitHostMessage","isWidgetEmitEventMessage","isWidgetReadyMessage","visitWidgetMessage"],"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 ManifestParameterDefinition,\n ParameterConfig,\n ParameterDefinition,\n ParameterValueMap,\n WidgetConfig,\n} from \"./config.js\";\nexport { defineConfig } from \"./config.js\";\nexport type {\n OntologySdkInputSpecV1 as OntologySdkInputSpec,\n WidgetManifestConfigV1 as WidgetManifestConfig,\n WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec,\n WidgetSetInputSpecV1 as WidgetSetInputSpec,\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 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;;AAYA,SAASA,YAAY,QAAQ,aAAa;AAQ1C,SAASC,sBAAsB,QAAQ,eAAe;AACtD,SACEC,WAAW,EACXC,8BAA8B,EAC9BC,gBAAgB,QACX,4BAA4B;AACnC,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,kBAAkB,QACb,8BAA8B","ignoreList":[]}
|
|
@@ -1 +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
|
|
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 ManifestParameterDefinition,\n ParameterConfig,\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 /**\n * The input specification for Foundry data required by the widget set.\n * @optional\n */\n inputSpec?: WidgetSetInputSpecV1;\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, ManifestParameterDefinition>;\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 interface WidgetSetInputSpecV1 {\n /**\n * The input specification for the widget set that was automatically discovered from the project's dependencies.\n * @optional\n */\n discovered?: WidgetSetDiscoveredInputSpecV1;\n}\n\nexport interface WidgetSetDiscoveredInputSpecV1 {\n /**\n * The discovered Ontology SDK packages in the project's dependencies.\n */\n sdks: Array<OntologySdkInputSpecV1>;\n}\n\nexport interface OntologySdkInputSpecV1 {\n /** The Ontology SDK package rid */\n rid: string;\n /** The Ontology SDK package version */\n version: string;\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;;AA+GA,OAAO,MAAMA,sBAAsB,GAAG,+BAA+B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.js","names":["ParameterValue"],"sources":["parameters.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 { AsyncValue } from \"./utils/asyncValue.js\";\n\n/**\n * Map of the name of the type to the corresponding JavaScript type.\n */\ntype PrimitiveParameterTypes = {\n boolean: boolean;\n /** Formatted as an ISO date string, e.g. YYYY-MM-DD */\n date: string;\n number: number;\n string: string;\n /** Formatted as an ISO datetime string */\n timestamp: string;\n};\ntype PrimitiveParameterType = keyof PrimitiveParameterTypes;\n\nexport interface AbstractParameterValue<T extends PrimitiveParameterType> {\n type: T;\n value: AsyncValue<PrimitiveParameterTypes[T]>;\n}\n\nexport interface GenericArrayParameterValue<T extends PrimitiveParameterType> {\n type: \"array\";\n subType: T;\n value: AsyncValue<PrimitiveParameterTypes[T][]>;\n}\n\n/**\n * Wire format of parameter values that will be sent through postMessage events to custom widgets.\n */\nexport namespace ParameterValue {\n export type String = AbstractParameterValue<\"string\">;\n export type Number = AbstractParameterValue<\"number\">;\n export type Boolean = AbstractParameterValue<\"boolean\">;\n export type Date = AbstractParameterValue<\"date\">;\n export type Timestamp = AbstractParameterValue<\"timestamp\">;\n\n export type StringArray = GenericArrayParameterValue<\"string\">;\n export type NumberArray = GenericArrayParameterValue<\"number\">;\n export type BooleanArray = GenericArrayParameterValue<\"boolean\">;\n export type DateArray = GenericArrayParameterValue<\"date\">;\n export type TimestampArray = GenericArrayParameterValue<\"timestamp\">;\n export type Array =\n | StringArray\n | NumberArray\n | BooleanArray\n | DateArray\n | TimestampArray;\n\n export type Type = ParameterValue[\"type\"];\n export type PrimitiveType = PrimitiveParameterType;\n}\nexport type ParameterValue =\n | ParameterValue.String\n | ParameterValue.Number\n | ParameterValue.Boolean\n | ParameterValue.Date\n | ParameterValue.Timestamp\n | ParameterValue.Array;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"parameters.js","names":["ParameterValue"],"sources":["parameters.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 { AsyncValue } from \"./utils/asyncValue.js\";\n\nexport type ObjectType = {\n type: \"object\";\n apiName: string;\n internalDoNotUseMetadata?: {\n rid: string;\n };\n};\n\n/**\n * Map of the name of the type to the corresponding JavaScript type.\n */\ntype PrimitiveParameterTypes = {\n boolean: boolean;\n /** Formatted as an ISO date string, e.g. YYYY-MM-DD */\n date: string;\n number: number;\n string: string;\n /** Formatted as an ISO datetime string */\n timestamp: string;\n};\ntype PrimitiveParameterType = keyof PrimitiveParameterTypes;\n\nexport interface AbstractParameterValue<T extends PrimitiveParameterType> {\n type: T;\n value: AsyncValue<PrimitiveParameterTypes[T]>;\n}\n\nexport interface ObjectSetParameterValue<T extends ObjectType> {\n type: \"objectSet\";\n value: AsyncValue<{\n objectSetRid: string;\n }>;\n}\n\nexport interface GenericArrayParameterValue<T extends PrimitiveParameterType> {\n type: \"array\";\n subType: T;\n value: AsyncValue<PrimitiveParameterTypes[T][]>;\n}\n\n/**\n * Wire format of parameter values that will be sent through postMessage events to custom widgets.\n */\nexport namespace ParameterValue {\n export type String = AbstractParameterValue<\"string\">;\n export type Number = AbstractParameterValue<\"number\">;\n export type Boolean = AbstractParameterValue<\"boolean\">;\n export type Date = AbstractParameterValue<\"date\">;\n export type Timestamp = AbstractParameterValue<\"timestamp\">;\n export type ObjectSet<T extends ObjectType = ObjectType> =\n ObjectSetParameterValue<T>;\n\n export type StringArray = GenericArrayParameterValue<\"string\">;\n export type NumberArray = GenericArrayParameterValue<\"number\">;\n export type BooleanArray = GenericArrayParameterValue<\"boolean\">;\n export type DateArray = GenericArrayParameterValue<\"date\">;\n export type TimestampArray = GenericArrayParameterValue<\"timestamp\">;\n export type Array =\n | StringArray\n | NumberArray\n | BooleanArray\n | DateArray\n | TimestampArray;\n\n export type Type = ParameterValue[\"type\"];\n export type PrimitiveType = PrimitiveParameterType;\n}\nexport type ParameterValue =\n | ParameterValue.String\n | ParameterValue.Number\n | ParameterValue.Boolean\n | ParameterValue.Date\n | ParameterValue.Timestamp\n | ParameterValue.ObjectSet\n | ParameterValue.Array;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AA8BA;AACA;AACA;AAFA,WAGiBA,cAAc","ignoreList":[]}
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -31,6 +31,13 @@ interface AsyncFailedValue<V, E = Error> {
|
|
|
31
31
|
*/
|
|
32
32
|
type AsyncValue<V, E = Error> = AsyncNotStartedLoadingValue | AsyncLoadingValue | AsyncLoadedValue<V> | AsyncReloadingValue<V> | AsyncFailedValue<V, E>;
|
|
33
33
|
|
|
34
|
+
type ObjectType = {
|
|
35
|
+
type: "object";
|
|
36
|
+
apiName: string;
|
|
37
|
+
internalDoNotUseMetadata?: {
|
|
38
|
+
rid: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
34
41
|
/**
|
|
35
42
|
* Map of the name of the type to the corresponding JavaScript type.
|
|
36
43
|
*/
|
|
@@ -48,6 +55,12 @@ interface AbstractParameterValue<T extends PrimitiveParameterType> {
|
|
|
48
55
|
type: T;
|
|
49
56
|
value: AsyncValue<PrimitiveParameterTypes[T]>;
|
|
50
57
|
}
|
|
58
|
+
interface ObjectSetParameterValue<T extends ObjectType> {
|
|
59
|
+
type: "objectSet";
|
|
60
|
+
value: AsyncValue<{
|
|
61
|
+
objectSetRid: string;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
51
64
|
interface GenericArrayParameterValue<T extends PrimitiveParameterType> {
|
|
52
65
|
type: "array";
|
|
53
66
|
subType: T;
|
|
@@ -62,6 +75,7 @@ declare namespace ParameterValue {
|
|
|
62
75
|
type Boolean = AbstractParameterValue<"boolean">;
|
|
63
76
|
type Date = AbstractParameterValue<"date">;
|
|
64
77
|
type Timestamp = AbstractParameterValue<"timestamp">;
|
|
78
|
+
type ObjectSet<T extends ObjectType = ObjectType> = ObjectSetParameterValue<T>;
|
|
65
79
|
type StringArray = GenericArrayParameterValue<"string">;
|
|
66
80
|
type NumberArray = GenericArrayParameterValue<"number">;
|
|
67
81
|
type BooleanArray = GenericArrayParameterValue<"boolean">;
|
|
@@ -71,7 +85,7 @@ declare namespace ParameterValue {
|
|
|
71
85
|
type Type = ParameterValue["type"];
|
|
72
86
|
type PrimitiveType = PrimitiveParameterType;
|
|
73
87
|
}
|
|
74
|
-
type ParameterValue = ParameterValue.String | ParameterValue.Number | ParameterValue.Boolean | ParameterValue.Date | ParameterValue.Timestamp | ParameterValue.Array;
|
|
88
|
+
type ParameterValue = ParameterValue.String | ParameterValue.Number | ParameterValue.Boolean | ParameterValue.Date | ParameterValue.Timestamp | ParameterValue.ObjectSet | ParameterValue.Array;
|
|
75
89
|
|
|
76
90
|
interface PrimitiveParameterDefinition<T extends ParameterValue.PrimitiveType> {
|
|
77
91
|
type: T;
|
|
@@ -82,7 +96,18 @@ interface ArrayParameterDefinition<S extends ParameterValue.PrimitiveType> {
|
|
|
82
96
|
displayName: string;
|
|
83
97
|
subType: S;
|
|
84
98
|
}
|
|
85
|
-
|
|
99
|
+
interface ObjectSetParameterDefinition<T extends ObjectType> {
|
|
100
|
+
type: "objectSet";
|
|
101
|
+
displayName: string;
|
|
102
|
+
objectType: T;
|
|
103
|
+
}
|
|
104
|
+
type ParameterDefinition = PrimitiveParameterDefinition<ParameterValue.PrimitiveType> | ArrayParameterDefinition<ParameterValue.PrimitiveType> | ObjectSetParameterDefinition<ObjectType>;
|
|
105
|
+
interface ManifestObjectSetParameterDefinition<T extends ObjectType> {
|
|
106
|
+
type: ObjectSetParameterDefinition<T>["type"];
|
|
107
|
+
displayName: string;
|
|
108
|
+
objectTypeRids: [string];
|
|
109
|
+
}
|
|
110
|
+
type ManifestParameterDefinition = PrimitiveParameterDefinition<ParameterValue.PrimitiveType> | ArrayParameterDefinition<ParameterValue.PrimitiveType> | ManifestObjectSetParameterDefinition<ObjectType>;
|
|
86
111
|
interface EventDefinition<P extends ParameterConfig> {
|
|
87
112
|
displayName: string;
|
|
88
113
|
parameterUpdateIds: Array<ParameterId<P>>;
|
|
@@ -113,6 +138,9 @@ type AsyncParameterValueMap<C extends WidgetConfig<C["parameters"]>> = {
|
|
|
113
138
|
type: "array";
|
|
114
139
|
subType: S;
|
|
115
140
|
value: AsyncValue<P>;
|
|
141
|
+
} : never : C["parameters"][K] extends ObjectSetParameterDefinition<infer T> ? ParameterValue.ObjectSet<T>["value"] extends AsyncValue<infer P> ? {
|
|
142
|
+
type: "objectSet";
|
|
143
|
+
value: AsyncValue<P>;
|
|
116
144
|
} : never : Extract<ParameterValue, {
|
|
117
145
|
type: C["parameters"][K]["type"];
|
|
118
146
|
}>["value"] extends AsyncValue<infer P> ? {
|
|
@@ -127,7 +155,7 @@ type ParameterValueMap<C extends WidgetConfig<C["parameters"]>> = {
|
|
|
127
155
|
[K in ParameterId<C["parameters"]>]: C["parameters"][K] extends ArrayParameterDefinition<infer S> ? Extract<ParameterValue.Array, {
|
|
128
156
|
type: C["parameters"][K]["type"];
|
|
129
157
|
subType: S;
|
|
130
|
-
}>["value"] extends AsyncValue<infer P> ? P : never : Extract<ParameterValue, {
|
|
158
|
+
}>["value"] extends AsyncValue<infer P> ? P : never : C["parameters"][K] extends ObjectSetParameterDefinition<infer T> ? ParameterValue.ObjectSet<T>["value"] extends AsyncValue<infer P> ? P : never : Extract<ParameterValue, {
|
|
131
159
|
type: C["parameters"][K]["type"];
|
|
132
160
|
}>["value"] extends AsyncValue<infer P> ? P : never;
|
|
133
161
|
};
|
|
@@ -207,7 +235,7 @@ interface WidgetManifestConfigV1 {
|
|
|
207
235
|
/**
|
|
208
236
|
* The map of parameter IDs to their definition
|
|
209
237
|
*/
|
|
210
|
-
parameters: Record<string,
|
|
238
|
+
parameters: Record<string, ManifestParameterDefinition>;
|
|
211
239
|
/**
|
|
212
240
|
* The map of events to their definition. Any parameter IDs referenced must be defined in the `parameters` field
|
|
213
241
|
*/
|
|
@@ -309,4 +337,4 @@ type WidgetMessageVisitor<C extends WidgetConfig<C["parameters"]>> = {
|
|
|
309
337
|
};
|
|
310
338
|
declare function visitWidgetMessage<C extends WidgetConfig<C["parameters"]>>(message: WidgetMessage<C>, visitor: WidgetMessageVisitor<C>): void;
|
|
311
339
|
|
|
312
|
-
export { type AsyncFailedValue, type AsyncLoadedValue, type AsyncLoadingValue, type AsyncNotStartedLoadingValue, type AsyncParameterValueMap, type AsyncReloadingValue, type AsyncValue, type EventId, type EventParameterValueMap, HostMessage, MANIFEST_FILE_LOCATION, type OntologySdkInputSpecV1 as OntologySdkInputSpec, type ParameterConfig, type ParameterDefinition, ParameterValue, type ParameterValueMap, type WidgetConfig, type WidgetManifestConfigV1 as WidgetManifestConfig, WidgetMessage, type WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec, type WidgetSetInputSpecV1 as WidgetSetInputSpec, type WidgetSetManifestV1 as WidgetSetManifest, defineConfig, isHostParametersUpdatedMessage, isWidgetEmitEventMessage, isWidgetReadyMessage, visitHostMessage, visitWidgetMessage };
|
|
340
|
+
export { type AsyncFailedValue, type AsyncLoadedValue, type AsyncLoadingValue, type AsyncNotStartedLoadingValue, type AsyncParameterValueMap, type AsyncReloadingValue, type AsyncValue, type EventId, type EventParameterValueMap, HostMessage, MANIFEST_FILE_LOCATION, type ManifestParameterDefinition, type OntologySdkInputSpecV1 as OntologySdkInputSpec, type ParameterConfig, type ParameterDefinition, ParameterValue, type ParameterValueMap, type WidgetConfig, type WidgetManifestConfigV1 as WidgetManifestConfig, WidgetMessage, type WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec, type WidgetSetInputSpecV1 as WidgetSetInputSpec, type WidgetSetManifestV1 as WidgetSetManifest, defineConfig, isHostParametersUpdatedMessage, isWidgetEmitEventMessage, isWidgetReadyMessage, visitHostMessage, visitWidgetMessage };
|
package/build/esm/config.js.map
CHANGED
|
@@ -1 +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> = NotEmptyObject<\n {\n [P in EventParameterIdList<C, K>[number]]: ParameterValueMap<C>[P];\n }\n>;\n\ntype NotEmptyObject<T extends Record<string, any>> = T extends\n Record<string, never> ? Record<string, never>\n : T;\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;;
|
|
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 { ObjectType, 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}\ninterface ObjectSetParameterDefinition<T extends ObjectType> {\n type: \"objectSet\";\n displayName: string;\n objectType: T;\n}\nexport type ParameterDefinition =\n | PrimitiveParameterDefinition<ParameterValue.PrimitiveType>\n | ArrayParameterDefinition<ParameterValue.PrimitiveType>\n | ObjectSetParameterDefinition<ObjectType>;\n\ninterface ManifestObjectSetParameterDefinition<T extends ObjectType> {\n type: ObjectSetParameterDefinition<T>[\"type\"];\n displayName: string;\n objectTypeRids: [string];\n}\n\nexport type ManifestParameterDefinition =\n | PrimitiveParameterDefinition<ParameterValue.PrimitiveType>\n | ArrayParameterDefinition<ParameterValue.PrimitiveType>\n | ManifestObjectSetParameterDefinition<ObjectType>;\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 : C[\"parameters\"][K] extends ObjectSetParameterDefinition<infer T>\n ? ParameterValue.ObjectSet<T>[\"value\"] extends AsyncValue<infer P> ? {\n type: \"objectSet\";\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 : C[\"parameters\"][K] extends ObjectSetParameterDefinition<infer T>\n ? ParameterValue.ObjectSet<T>[\"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> = NotEmptyObject<\n {\n [P in EventParameterIdList<C, K>[number]]: ParameterValueMap<C>[P];\n }\n>;\n\ntype NotEmptyObject<T extends Record<string, any>> = T extends\n Record<string, never> ? Record<string, never>\n : T;\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;;AAoDA;AACA;AACA;;AAGA;AACA;AACA;;AAiCA;AACA;AACA;;AAwBA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAcA,OAAO,SAASA,YAAYA,CAAoCC,CAAI,EAAK;EACvE,OAAOA,CAAC;AACV","ignoreList":[]}
|
package/build/esm/config.test.js
CHANGED
|
@@ -238,6 +238,30 @@ describe("WidgetConfig", () => {
|
|
|
238
238
|
});
|
|
239
239
|
expectTypeOf().toMatchTypeOf();
|
|
240
240
|
});
|
|
241
|
+
it("should support objectSet parameter types with generic object type", () => {
|
|
242
|
+
defineConfig({
|
|
243
|
+
id: "widgetId",
|
|
244
|
+
name: "Widget Name",
|
|
245
|
+
description: "Widget Description",
|
|
246
|
+
type: "workshop",
|
|
247
|
+
parameters: {
|
|
248
|
+
myObjectSet: {
|
|
249
|
+
displayName: "My Object Set",
|
|
250
|
+
type: "objectSet",
|
|
251
|
+
objectType: {
|
|
252
|
+
type: "object",
|
|
253
|
+
apiName: "employee",
|
|
254
|
+
experimentalDoNotUseMetadata: {
|
|
255
|
+
rid: "ri.object-type.employee"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
events: {}
|
|
261
|
+
});
|
|
262
|
+
expectTypeOf().toEqualTypeOf();
|
|
263
|
+
expectTypeOf().toEqualTypeOf();
|
|
264
|
+
});
|
|
241
265
|
});
|
|
242
266
|
});
|
|
243
267
|
//# sourceMappingURL=config.test.js.map
|
|
@@ -1 +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;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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;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":[]}
|
|
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","myObjectSet","objectType","apiName","experimentalDoNotUseMetadata","rid"],"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 type { ObjectTypeDefinition } from \"@osdk/api\";\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 { ObjectType, ParameterValue } from \"./parameters.js\";\nimport type { AsyncValue } from \"./utils/asyncValue.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 it(\"should support objectSet parameter types with generic object type\", () => {\n const Employee = {\n type: \"object\",\n apiName: \"employee\",\n experimentalDoNotUseMetadata: {\n rid: \"ri.object-type.employee\",\n },\n } as const satisfies ObjectTypeDefinition & {\n experimentalDoNotUseMetadata: { rid: string };\n } & ObjectType;\n\n type Employee = typeof Employee;\n\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n myObjectSet: {\n displayName: \"My Object Set\",\n type: \"objectSet\",\n objectType: Employee,\n },\n },\n events: {},\n });\n\n expectTypeOf<ParameterValueMap<typeof test>>().toEqualTypeOf<{\n myObjectSet: {\n objectSetRid: string;\n };\n }>();\n\n expectTypeOf<AsyncParameterValueMap<typeof test>>().toEqualTypeOf<{\n myObjectSet: {\n type: \"objectSet\";\n value: AsyncValue<{\n objectSetRid: string;\n }>;\n };\n }>();\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AACnD,SAEEC,YAAY,QAMP,aAAa;AAIpBH,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC7BA,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IAClCE,EAAE,CAAC,sDAAsD,E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,EArBC;cACfd,IAAI,EAAE,QAAQ;cACde,OAAO,EAAE,UAAU;cACnBC,4BAA4B,EAAE;gBAC5BC,GAAG,EAAE;cACP;YACF;UAgBI;QACF,CAAC;QACDZ,MAAM,EAAE,CAAC;MACX,CAAC,CAAC;MAEFX,YAAY,CAAiC,CAAC,CAACY,aAAa,CAIzD,CAAC;MAEJZ,YAAY,CAAsC,CAAC,CAACY,aAAa,CAO9D,CAAC;IACN,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["defineConfig","MANIFEST_FILE_LOCATION","HostMessage","isHostParametersUpdatedMessage","visitHostMessage","isWidgetEmitEventMessage","isWidgetReadyMessage","visitWidgetMessage"],"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 OntologySdkInputSpecV1 as OntologySdkInputSpec,\n WidgetManifestConfigV1 as WidgetManifestConfig,\n WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec,\n WidgetSetInputSpecV1 as WidgetSetInputSpec,\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 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;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["defineConfig","MANIFEST_FILE_LOCATION","HostMessage","isHostParametersUpdatedMessage","visitHostMessage","isWidgetEmitEventMessage","isWidgetReadyMessage","visitWidgetMessage"],"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 ManifestParameterDefinition,\n ParameterConfig,\n ParameterDefinition,\n ParameterValueMap,\n WidgetConfig,\n} from \"./config.js\";\nexport { defineConfig } from \"./config.js\";\nexport type {\n OntologySdkInputSpecV1 as OntologySdkInputSpec,\n WidgetManifestConfigV1 as WidgetManifestConfig,\n WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec,\n WidgetSetInputSpecV1 as WidgetSetInputSpec,\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 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;;AAYA,SAASA,YAAY,QAAQ,aAAa;AAQ1C,SAASC,sBAAsB,QAAQ,eAAe;AACtD,SACEC,WAAW,EACXC,8BAA8B,EAC9BC,gBAAgB,QACX,4BAA4B;AACnC,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,kBAAkB,QACb,8BAA8B","ignoreList":[]}
|
|
@@ -1 +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
|
|
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 ManifestParameterDefinition,\n ParameterConfig,\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 /**\n * The input specification for Foundry data required by the widget set.\n * @optional\n */\n inputSpec?: WidgetSetInputSpecV1;\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, ManifestParameterDefinition>;\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 interface WidgetSetInputSpecV1 {\n /**\n * The input specification for the widget set that was automatically discovered from the project's dependencies.\n * @optional\n */\n discovered?: WidgetSetDiscoveredInputSpecV1;\n}\n\nexport interface WidgetSetDiscoveredInputSpecV1 {\n /**\n * The discovered Ontology SDK packages in the project's dependencies.\n */\n sdks: Array<OntologySdkInputSpecV1>;\n}\n\nexport interface OntologySdkInputSpecV1 {\n /** The Ontology SDK package rid */\n rid: string;\n /** The Ontology SDK package version */\n version: string;\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;;AA+GA,OAAO,MAAMA,sBAAsB,GAAG,+BAA+B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.js","names":["ParameterValue"],"sources":["parameters.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 { AsyncValue } from \"./utils/asyncValue.js\";\n\n/**\n * Map of the name of the type to the corresponding JavaScript type.\n */\ntype PrimitiveParameterTypes = {\n boolean: boolean;\n /** Formatted as an ISO date string, e.g. YYYY-MM-DD */\n date: string;\n number: number;\n string: string;\n /** Formatted as an ISO datetime string */\n timestamp: string;\n};\ntype PrimitiveParameterType = keyof PrimitiveParameterTypes;\n\nexport interface AbstractParameterValue<T extends PrimitiveParameterType> {\n type: T;\n value: AsyncValue<PrimitiveParameterTypes[T]>;\n}\n\nexport interface GenericArrayParameterValue<T extends PrimitiveParameterType> {\n type: \"array\";\n subType: T;\n value: AsyncValue<PrimitiveParameterTypes[T][]>;\n}\n\n/**\n * Wire format of parameter values that will be sent through postMessage events to custom widgets.\n */\nexport namespace ParameterValue {\n export type String = AbstractParameterValue<\"string\">;\n export type Number = AbstractParameterValue<\"number\">;\n export type Boolean = AbstractParameterValue<\"boolean\">;\n export type Date = AbstractParameterValue<\"date\">;\n export type Timestamp = AbstractParameterValue<\"timestamp\">;\n\n export type StringArray = GenericArrayParameterValue<\"string\">;\n export type NumberArray = GenericArrayParameterValue<\"number\">;\n export type BooleanArray = GenericArrayParameterValue<\"boolean\">;\n export type DateArray = GenericArrayParameterValue<\"date\">;\n export type TimestampArray = GenericArrayParameterValue<\"timestamp\">;\n export type Array =\n | StringArray\n | NumberArray\n | BooleanArray\n | DateArray\n | TimestampArray;\n\n export type Type = ParameterValue[\"type\"];\n export type PrimitiveType = PrimitiveParameterType;\n}\nexport type ParameterValue =\n | ParameterValue.String\n | ParameterValue.Number\n | ParameterValue.Boolean\n | ParameterValue.Date\n | ParameterValue.Timestamp\n | ParameterValue.Array;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"parameters.js","names":["ParameterValue"],"sources":["parameters.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 { AsyncValue } from \"./utils/asyncValue.js\";\n\nexport type ObjectType = {\n type: \"object\";\n apiName: string;\n internalDoNotUseMetadata?: {\n rid: string;\n };\n};\n\n/**\n * Map of the name of the type to the corresponding JavaScript type.\n */\ntype PrimitiveParameterTypes = {\n boolean: boolean;\n /** Formatted as an ISO date string, e.g. YYYY-MM-DD */\n date: string;\n number: number;\n string: string;\n /** Formatted as an ISO datetime string */\n timestamp: string;\n};\ntype PrimitiveParameterType = keyof PrimitiveParameterTypes;\n\nexport interface AbstractParameterValue<T extends PrimitiveParameterType> {\n type: T;\n value: AsyncValue<PrimitiveParameterTypes[T]>;\n}\n\nexport interface ObjectSetParameterValue<T extends ObjectType> {\n type: \"objectSet\";\n value: AsyncValue<{\n objectSetRid: string;\n }>;\n}\n\nexport interface GenericArrayParameterValue<T extends PrimitiveParameterType> {\n type: \"array\";\n subType: T;\n value: AsyncValue<PrimitiveParameterTypes[T][]>;\n}\n\n/**\n * Wire format of parameter values that will be sent through postMessage events to custom widgets.\n */\nexport namespace ParameterValue {\n export type String = AbstractParameterValue<\"string\">;\n export type Number = AbstractParameterValue<\"number\">;\n export type Boolean = AbstractParameterValue<\"boolean\">;\n export type Date = AbstractParameterValue<\"date\">;\n export type Timestamp = AbstractParameterValue<\"timestamp\">;\n export type ObjectSet<T extends ObjectType = ObjectType> =\n ObjectSetParameterValue<T>;\n\n export type StringArray = GenericArrayParameterValue<\"string\">;\n export type NumberArray = GenericArrayParameterValue<\"number\">;\n export type BooleanArray = GenericArrayParameterValue<\"boolean\">;\n export type DateArray = GenericArrayParameterValue<\"date\">;\n export type TimestampArray = GenericArrayParameterValue<\"timestamp\">;\n export type Array =\n | StringArray\n | NumberArray\n | BooleanArray\n | DateArray\n | TimestampArray;\n\n export type Type = ParameterValue[\"type\"];\n export type PrimitiveType = PrimitiveParameterType;\n}\nexport type ParameterValue =\n | ParameterValue.String\n | ParameterValue.Number\n | ParameterValue.Boolean\n | ParameterValue.Date\n | ParameterValue.Timestamp\n | ParameterValue.ObjectSet\n | ParameterValue.Array;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AA8BA;AACA;AACA;AAFA,WAGiBA,cAAc","ignoreList":[]}
|
package/build/types/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParameterValue } from "./parameters.js";
|
|
1
|
+
import type { ObjectType, ParameterValue } from "./parameters.js";
|
|
2
2
|
import type { AsyncValue } from "./utils/asyncValue.js";
|
|
3
3
|
interface PrimitiveParameterDefinition<T extends ParameterValue.PrimitiveType> {
|
|
4
4
|
type: T;
|
|
@@ -9,7 +9,18 @@ interface ArrayParameterDefinition<S extends ParameterValue.PrimitiveType> {
|
|
|
9
9
|
displayName: string;
|
|
10
10
|
subType: S;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface ObjectSetParameterDefinition<T extends ObjectType> {
|
|
13
|
+
type: "objectSet";
|
|
14
|
+
displayName: string;
|
|
15
|
+
objectType: T;
|
|
16
|
+
}
|
|
17
|
+
export type ParameterDefinition = PrimitiveParameterDefinition<ParameterValue.PrimitiveType> | ArrayParameterDefinition<ParameterValue.PrimitiveType> | ObjectSetParameterDefinition<ObjectType>;
|
|
18
|
+
interface ManifestObjectSetParameterDefinition<T extends ObjectType> {
|
|
19
|
+
type: ObjectSetParameterDefinition<T>["type"];
|
|
20
|
+
displayName: string;
|
|
21
|
+
objectTypeRids: [string];
|
|
22
|
+
}
|
|
23
|
+
export type ManifestParameterDefinition = PrimitiveParameterDefinition<ParameterValue.PrimitiveType> | ArrayParameterDefinition<ParameterValue.PrimitiveType> | ManifestObjectSetParameterDefinition<ObjectType>;
|
|
13
24
|
export interface EventDefinition<P extends ParameterConfig> {
|
|
14
25
|
displayName: string;
|
|
15
26
|
parameterUpdateIds: Array<ParameterId<P>>;
|
|
@@ -39,6 +50,9 @@ export type AsyncParameterValueMap<C extends WidgetConfig<C["parameters"]>> = {
|
|
|
39
50
|
type: "array"
|
|
40
51
|
subType: S
|
|
41
52
|
value: AsyncValue<P>
|
|
53
|
+
} : never : C["parameters"][K] extends ObjectSetParameterDefinition<infer T> ? ParameterValue.ObjectSet<T>["value"] extends AsyncValue<infer P> ? {
|
|
54
|
+
type: "objectSet"
|
|
55
|
+
value: AsyncValue<P>
|
|
42
56
|
} : never : Extract<ParameterValue, {
|
|
43
57
|
type: C["parameters"][K]["type"]
|
|
44
58
|
}>["value"] extends AsyncValue<infer P> ? {
|
|
@@ -51,7 +65,7 @@ export type AsyncParameterValueMap<C extends WidgetConfig<C["parameters"]>> = {
|
|
|
51
65
|
export type ParameterValueMap<C extends WidgetConfig<C["parameters"]>> = { [K in ParameterId<C["parameters"]>] : C["parameters"][K] extends ArrayParameterDefinition<infer S> ? Extract<ParameterValue.Array, {
|
|
52
66
|
type: C["parameters"][K]["type"]
|
|
53
67
|
subType: S
|
|
54
|
-
}>["value"] extends AsyncValue<infer P> ? P : never : Extract<ParameterValue, {
|
|
68
|
+
}>["value"] extends AsyncValue<infer P> ? P : never : C["parameters"][K] extends ObjectSetParameterDefinition<infer T> ? ParameterValue.ObjectSet<T>["value"] extends AsyncValue<infer P> ? P : never : Extract<ParameterValue, {
|
|
55
69
|
type: C["parameters"][K]["type"]
|
|
56
70
|
}>["value"] extends AsyncValue<infer P> ? P : never };
|
|
57
71
|
export type EventId<C extends WidgetConfig<C["parameters"]>> = keyof C["events"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,sBAAsB,iBAAkB;
|
|
1
|
+
{"mappings":"AAgBA,cAAc,YAAY,sBAAsB,iBAAkB;AAClE,cAAc,kBAAkB,uBAAwB;UAE9C,6BAA6B,UAAU,eAAe,eAAe;CAC7E,MAAM;CACN;AACD;UACS,yBAAyB,UAAU,eAAe,eAAe;CACzE,MAAM,eAAe,MAAM;CAC3B;CACA,SAAS;AACV;UACS,6BAA6B,UAAU,YAAY;CAC3D,MAAM;CACN;CACA,YAAY;AACb;AACD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,iBAAiB,iBAAiB,KAAK,YAErE,QACA,gBACA;CAAE,MAAM,EAAE,cAAc,GAAG;AAAS,GACpC,iBAAiB,iBAAiB,KAAK;AAI7C,YAAY,QAAQ,UAAU,aAAa,EAAE,wBACrC,EAAE;;;;;AAMV,YAAY;CACV,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;IAChB,EAAE,UAAU,GAAG,8BACjB,MAAM,YAAY,EAAE,kBAAkB,EAAE,UAAU,GAAG;;;;AAMvD,YAAY;CACV,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;IAChB,kBAEC,KAAK,qBAAqB,GAAG,cAAa,kBAAkB,GAAG;KAI/D,eAAe,UAAU,uBAAuB,UACnD,wBAAwB,wBACtB;AAEJ,OAAO,iBAAS,mBAAmB,UAAU,mBAAmBA,GAAG,IAAI","names":["c: C"],"sources":["../../src/config.ts"],"version":3,"file":"config.d.ts"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AsyncParameterValueMap, EventId, EventParameterValueMap, ParameterConfig, ParameterDefinition, ParameterValueMap, WidgetConfig } from "./config.js";
|
|
1
|
+
export type { AsyncParameterValueMap, EventId, EventParameterValueMap, ManifestParameterDefinition, ParameterConfig, ParameterDefinition, ParameterValueMap, WidgetConfig } from "./config.js";
|
|
2
2
|
export { defineConfig } from "./config.js";
|
|
3
3
|
export type { OntologySdkInputSpecV1 as OntologySdkInputSpec, WidgetManifestConfigV1 as WidgetManifestConfig, WidgetSetDiscoveredInputSpecV1 as WidgetSetDiscoveredInputSpec, WidgetSetInputSpecV1 as WidgetSetInputSpec, WidgetSetManifestV1 as WidgetSetManifest } from "./manifest.js";
|
|
4
4
|
export { MANIFEST_FILE_LOCATION } from "./manifest.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,wBACA,SACA,wBACA,iBACA,qBACA,mBACA,oBACK;AACP,SAAS,oBAAoB;AAC7B,cACE,0BAA0B,sBAC1B,0BAA0B,sBAC1B,kCAAkC,8BAClC,wBAAwB,oBACxB,uBAAuB,yBAClB;AACP,SAAS,8BAA8B;AACvC,SACE,aACA,gCACA,wBACK;AACP,SACE,0BACA,sBACA,0BACK;AACP,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cACE,kBACA,kBACA,mBACA,6BACA,qBACA,kBACK","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,cACE,wBACA,SACA,wBACA,6BACA,iBACA,qBACA,mBACA,oBACK;AACP,SAAS,oBAAoB;AAC7B,cACE,0BAA0B,sBAC1B,0BAA0B,sBAC1B,kCAAkC,8BAClC,wBAAwB,oBACxB,uBAAuB,yBAClB;AACP,SAAS,8BAA8B;AACvC,SACE,aACA,gCACA,wBACK;AACP,SACE,0BACA,sBACA,0BACK;AACP,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cACE,kBACA,kBACA,mBACA,6BACA,qBACA,kBACK","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventDefinition,
|
|
1
|
+
import type { EventDefinition, ManifestParameterDefinition, ParameterConfig } from "./config.js";
|
|
2
2
|
export interface WidgetSetManifestV1 {
|
|
3
3
|
manifestVersion: "1.0.0";
|
|
4
4
|
widgetSet: WidgetSetManifestContentV1;
|
|
@@ -60,7 +60,7 @@ export interface WidgetManifestConfigV1 {
|
|
|
60
60
|
/**
|
|
61
61
|
* The map of parameter IDs to their definition
|
|
62
62
|
*/
|
|
63
|
-
parameters: Record<string,
|
|
63
|
+
parameters: Record<string, ManifestParameterDefinition>;
|
|
64
64
|
/**
|
|
65
65
|
* The map of events to their definition. Any parameter IDs referenced must be defined in the `parameters` field
|
|
66
66
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,iBACA,
|
|
1
|
+
{"mappings":"AAgBA,cACE,iBACA,6BACA,uBACK,aAAc;AAErB,iBAAiB,oBAAoB;CACnC,iBAAiB;CACjB,WAAW;AACZ;AAED,iBAAiB,2BAA2B;;;;CAI1C;;;;CAKA;;;;;CAMA,SAAS,eAAe;;;;;CAMxB,YAAY;AACb;AAED,iBAAiB,uBAAuB;;;;CAItC;;;;CAKA;;;;CAKA;;;;CAKA,MAAM;;;;CAKN,cAAc,MAAM;;EAElB;;EAGA,MAAM,WAAW;CAClB;;;;;CAMD,gBAAgB,MAAM;;EAEpB;CACD;;;;CAKD,YAAY,eAAe;;;;CAK3B,QAAQ,eAAe,gBAAgB;AACxC;AAED,iBAAiB,qBAAqB;;;;;CAKpC,aAAa;AACd;AAED,iBAAiB,+BAA+B;;;;CAI9C,MAAM,MAAM;AACb;AAED,iBAAiB,uBAAuB;;CAEtC;;CAEA;AACD;AAED,OAAO,cAAM,yBAAyB","names":[],"sources":["../../src/manifest.ts"],"version":3,"file":"manifest.d.ts"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { AsyncValue } from "./utils/asyncValue.js";
|
|
2
|
+
export type ObjectType = {
|
|
3
|
+
type: "object"
|
|
4
|
+
apiName: string
|
|
5
|
+
internalDoNotUseMetadata?: {
|
|
6
|
+
rid: string
|
|
7
|
+
}
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* Map of the name of the type to the corresponding JavaScript type.
|
|
4
11
|
*/
|
|
@@ -16,6 +23,12 @@ export interface AbstractParameterValue<T extends PrimitiveParameterType> {
|
|
|
16
23
|
type: T;
|
|
17
24
|
value: AsyncValue<PrimitiveParameterTypes[T]>;
|
|
18
25
|
}
|
|
26
|
+
export interface ObjectSetParameterValue<T extends ObjectType> {
|
|
27
|
+
type: "objectSet";
|
|
28
|
+
value: AsyncValue<{
|
|
29
|
+
objectSetRid: string
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
19
32
|
export interface GenericArrayParameterValue<T extends PrimitiveParameterType> {
|
|
20
33
|
type: "array";
|
|
21
34
|
subType: T;
|
|
@@ -30,6 +43,7 @@ export declare namespace ParameterValue {
|
|
|
30
43
|
type Boolean = AbstractParameterValue<"boolean">;
|
|
31
44
|
type Date = AbstractParameterValue<"date">;
|
|
32
45
|
type Timestamp = AbstractParameterValue<"timestamp">;
|
|
46
|
+
type ObjectSet<T extends ObjectType = ObjectType> = ObjectSetParameterValue<T>;
|
|
33
47
|
type StringArray = GenericArrayParameterValue<"string">;
|
|
34
48
|
type NumberArray = GenericArrayParameterValue<"number">;
|
|
35
49
|
type BooleanArray = GenericArrayParameterValue<"boolean">;
|
|
@@ -39,5 +53,5 @@ export declare namespace ParameterValue {
|
|
|
39
53
|
type Type = ParameterValue["type"];
|
|
40
54
|
type PrimitiveType = PrimitiveParameterType;
|
|
41
55
|
}
|
|
42
|
-
export type ParameterValue = ParameterValue.String | ParameterValue.Number | ParameterValue.Boolean | ParameterValue.Date | ParameterValue.Timestamp | ParameterValue.Array;
|
|
56
|
+
export type ParameterValue = ParameterValue.String | ParameterValue.Number | ParameterValue.Boolean | ParameterValue.Date | ParameterValue.Timestamp | ParameterValue.ObjectSet | ParameterValue.Array;
|
|
43
57
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,kBAAkB,uBAAwB;;;;
|
|
1
|
+
{"mappings":"AAgBA,cAAc,kBAAkB,uBAAwB;AAExD,YAAY,aAAa;CACvB,MAAM;CACN;CACA,2BAA2B;EACzB;CACD;AACF;;;;KAKI,0BAA0B;CAC7B;;CAEA;CACA;CACA;;CAEA;AACD;KACI,+BAA+B;AAEpC,iBAAiB,uBAAuB,UAAU,wBAAwB;CACxE,MAAM;CACN,OAAO,WAAW,wBAAwB;AAC3C;AAED,iBAAiB,wBAAwB,UAAU,YAAY;CAC7D,MAAM;CACN,OAAO,WAAW;EAChB;CACD;AACF;AAED,iBAAiB,2BAA2B,UAAU,wBAAwB;CAC5E,MAAM;CACN,SAAS;CACT,OAAO,WAAW,wBAAwB;AAC3C;;;;AAKD,yBAAiB;MACH,SAAS,uBAAuB;MAChC,SAAS,uBAAuB;MAChC,UAAU,uBAAuB;MACjC,OAAO,uBAAuB;MAC9B,YAAY,uBAAuB;MACnC,UAAU,UAAU,aAAa,cAC3C,wBAAwB;MAEd,cAAc,2BAA2B;MACzC,cAAc,2BAA2B;MACzC,eAAe,2BAA2B;MAC1C,YAAY,2BAA2B;MACvC,iBAAiB,2BAA2B;MAC5C,QACR,cACA,cACA,eACA,YACA;MAEQ,OAAO,eAAe;MACtB,gBAAgB;;AAE9B,YAAY,iBACR,eAAe,SACf,eAAe,SACf,eAAe,UACf,eAAe,OACf,eAAe,YACf,eAAe,YACf,eAAe","names":[],"sources":["../../src/parameters.ts"],"version":3,"file":"parameters.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/widget.api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0-beta.1",
|
|
4
4
|
"description": "API contract between Foundry UIs that can embed custom widgets and the custom widgets themselves",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
"ts-expect": "^1.3.0",
|
|
33
33
|
"typescript": "~5.5.4",
|
|
34
34
|
"vitest": "^3.2.4",
|
|
35
|
-
"@osdk/
|
|
36
|
-
"@osdk/monorepo.
|
|
35
|
+
"@osdk/api": "~2.6.0-beta.1",
|
|
36
|
+
"@osdk/monorepo.api-extractor": "~0.5.0-beta.1",
|
|
37
|
+
"@osdk/monorepo.tsconfig": "~0.5.0-beta.1"
|
|
37
38
|
},
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public"
|