@osdk/widget.vite-plugin 3.53.0 → 3.54.0-main-e8584ece14b283cd7995920e66dc275e9ab9edbe
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 +11 -0
- package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js +1 -1
- package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js.map +1 -1
- package/build/esm/build-plugin/getWidgetSetInputSpec.js +38 -3
- package/build/esm/build-plugin/getWidgetSetInputSpec.js.map +1 -1
- package/build/esm/common/ResourcesJson.js +2 -0
- package/build/esm/common/ResourcesJson.js.map +1 -0
- package/build/esm/dev-plugin/buildDevModeManifest.js +1 -1
- package/build/esm/dev-plugin/buildDevModeManifest.js.map +1 -1
- package/build/types/build-plugin/getWidgetSetInputSpec.d.ts +1 -1
- package/build/types/build-plugin/getWidgetSetInputSpec.d.ts.map +1 -1
- package/build/types/common/ResourcesJson.d.ts +8 -0
- package/build/types/common/ResourcesJson.d.ts.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @osdk/widget.vite-plugin
|
|
2
2
|
|
|
3
|
+
## 3.54.0-main-e8584ece14b283cd7995920e66dc275e9ab9edbe
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 47c66c3: Generate widget set manifest authorizations defined in a resources.json file
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [47c66c3]
|
|
12
|
+
- @osdk/widget.api@3.54.0-main-e8584ece14b283cd7995920e66dc275e9ab9edbe
|
|
13
|
+
|
|
3
14
|
## 3.53.0
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -64,7 +64,7 @@ export function FoundryWidgetBuildPlugin(options) {
|
|
|
64
64
|
// Build widget set manifest
|
|
65
65
|
const widgetSetVersion = await computeWidgetSetVersion(foundryConfig);
|
|
66
66
|
const widgetBuilds = await Promise.all(htmlEntrypoints.map(input => getWidgetBuildOutputs(bundle, input, config.build.outDir, server)));
|
|
67
|
-
const widgetSetInputSpec = await getWidgetSetInputSpec(path.resolve(process.cwd(), "package.json"));
|
|
67
|
+
const widgetSetInputSpec = await getWidgetSetInputSpec(path.resolve(process.cwd(), "package.json"), path.resolve(process.cwd(), "resources.json"));
|
|
68
68
|
const widgetSetManifest = buildWidgetSetManifest(foundryConfig.foundryConfig.widgetSet.rid, widgetSetVersion, widgetBuilds, widgetSetInputSpec, options);
|
|
69
69
|
|
|
70
70
|
// Write the manifest to the dist directory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoundryWidgetBuildPlugin.js","names":["fs","path","autoVersion","loadFoundryConfig","MANIFEST_FILE_LOCATION","createServer","BUILD_PLUGIN_ID","MODULE_EVALUATION_MODE","getInputHtmlEntrypoints","buildWidgetSetManifest","getWidgetBuildOutputs","getWidgetSetInputSpec","FoundryWidgetBuildPlugin","options","htmlEntrypoints","config","name","enforce","apply","buildStart","configResolved","_config","writeBundle","_","bundle","foundryConfig","Error","server","createModuleEvaluationServer","widgetSetVersion","computeWidgetSetVersion","widgetBuilds","Promise","all","map","input","build","outDir","widgetSetInputSpec","resolve","process","cwd","widgetSetManifest","widgetSet","rid","writeManifest","close","configFile","mode","type","manifestPath","join","mkdirSync","dirname","recursive","writeFileSync","JSON","stringify"],"sources":["FoundryWidgetBuildPlugin.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nimport type { LoadedFoundryConfig } from \"@osdk/foundry-config-json\";\nimport { autoVersion, loadFoundryConfig } from \"@osdk/foundry-config-json\";\nimport type { WidgetSetManifest } from \"@osdk/widget.api\";\nimport { MANIFEST_FILE_LOCATION } from \"@osdk/widget.api\";\nimport type { Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport { createServer } from \"vite\";\n\nimport {\n BUILD_PLUGIN_ID,\n MODULE_EVALUATION_MODE,\n} from \"../common/constants.js\";\nimport { getInputHtmlEntrypoints } from \"../common/getInputHtmlEntrypoints.js\";\nimport type { FoundryWidgetPluginOptions } from \"../index.js\";\nimport { buildWidgetSetManifest } from \"./buildWidgetSetManifest.js\";\nimport { getWidgetBuildOutputs } from \"./getWidgetBuildOutputs.js\";\nimport { getWidgetSetInputSpec } from \"./getWidgetSetInputSpec.js\";\n\nexport function FoundryWidgetBuildPlugin(\n options?: FoundryWidgetPluginOptions,\n): Plugin {\n // The root HTML entrypoints of the build process\n let htmlEntrypoints: string[];\n // Store the resolved Vite config for use in later build steps\n let config: ResolvedConfig;\n\n return {\n name: BUILD_PLUGIN_ID,\n enforce: \"pre\",\n // Only apply this plugin during build\n apply: \"build\",\n\n /**\n * Capture the entrypoints from the Vite config for use in later build steps.\n */\n buildStart(options) {\n htmlEntrypoints = getInputHtmlEntrypoints(options);\n },\n\n /**\n * Store the resolved Vite config for use in later build steps.\n */\n configResolved(_config) {\n config = _config;\n },\n\n /**\n * Once the build is complete, generate the widget set manifest based on the entrypoints and\n * configuration files that were found.\n *\n * Write the manifest to the expected location in the dist directory.\n */\n async writeBundle(_, bundle) {\n const foundryConfig = await loadFoundryConfig(\"widgetSet\");\n if (foundryConfig == null) {\n throw new Error(\"foundry.config.json file not found.\");\n }\n\n // Create a Vite server to evaluate widget config modules\n const server = await createModuleEvaluationServer(config);\n\n try {\n // Build widget set manifest\n const widgetSetVersion = await computeWidgetSetVersion(foundryConfig);\n const widgetBuilds = await Promise.all(\n htmlEntrypoints.map((input) =>\n getWidgetBuildOutputs(bundle, input, config.build.outDir, server),\n ),\n );\n const widgetSetInputSpec = await getWidgetSetInputSpec(\n path.resolve(process.cwd(), \"package.json\"),\n );\n const widgetSetManifest = buildWidgetSetManifest(\n foundryConfig.foundryConfig.widgetSet.rid,\n widgetSetVersion,\n widgetBuilds,\n widgetSetInputSpec,\n options,\n );\n\n // Write the manifest to the dist directory\n writeManifest(widgetSetManifest, config.build.outDir);\n } finally {\n await server.close();\n }\n },\n };\n}\n\n/**\n * Create a Vite server for widget config module evaluation during the build process.\n * Must prevent loading the dev plugin to avoid triggering dev mode build steps.\n */\nasync function createModuleEvaluationServer(\n config: ResolvedConfig,\n): Promise<ViteDevServer> {\n return await createServer({\n // Reference the existing config file in order to respect any custom config\n configFile: config.configFile,\n // Custom mode to prevent dev plugin execution\n mode: MODULE_EVALUATION_MODE,\n });\n}\n\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nasync function computeWidgetSetVersion(\n foundryConfig: LoadedFoundryConfig<\"widgetSet\">,\n): Promise<string> {\n return autoVersion(\n foundryConfig.foundryConfig.widgetSet.autoVersion ?? {\n type: \"package-json\",\n },\n );\n}\n\nfunction writeManifest(\n widgetSetManifest: WidgetSetManifest,\n outDir: string,\n): void {\n const manifestPath = path.join(outDir, MANIFEST_FILE_LOCATION);\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true });\n fs.writeFileSync(manifestPath, JSON.stringify(widgetSetManifest, null, 2));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAGvB,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,2BAA2B;AAE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AAMW,kBAAkB,GAAG,MAAM3B,qBAAqB,CACpDV,IAAI,CAACsC,OAAO,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"FoundryWidgetBuildPlugin.js","names":["fs","path","autoVersion","loadFoundryConfig","MANIFEST_FILE_LOCATION","createServer","BUILD_PLUGIN_ID","MODULE_EVALUATION_MODE","getInputHtmlEntrypoints","buildWidgetSetManifest","getWidgetBuildOutputs","getWidgetSetInputSpec","FoundryWidgetBuildPlugin","options","htmlEntrypoints","config","name","enforce","apply","buildStart","configResolved","_config","writeBundle","_","bundle","foundryConfig","Error","server","createModuleEvaluationServer","widgetSetVersion","computeWidgetSetVersion","widgetBuilds","Promise","all","map","input","build","outDir","widgetSetInputSpec","resolve","process","cwd","widgetSetManifest","widgetSet","rid","writeManifest","close","configFile","mode","type","manifestPath","join","mkdirSync","dirname","recursive","writeFileSync","JSON","stringify"],"sources":["FoundryWidgetBuildPlugin.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nimport type { LoadedFoundryConfig } from \"@osdk/foundry-config-json\";\nimport { autoVersion, loadFoundryConfig } from \"@osdk/foundry-config-json\";\nimport type { WidgetSetManifest } from \"@osdk/widget.api\";\nimport { MANIFEST_FILE_LOCATION } from \"@osdk/widget.api\";\nimport type { Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport { createServer } from \"vite\";\n\nimport {\n BUILD_PLUGIN_ID,\n MODULE_EVALUATION_MODE,\n} from \"../common/constants.js\";\nimport { getInputHtmlEntrypoints } from \"../common/getInputHtmlEntrypoints.js\";\nimport type { FoundryWidgetPluginOptions } from \"../index.js\";\nimport { buildWidgetSetManifest } from \"./buildWidgetSetManifest.js\";\nimport { getWidgetBuildOutputs } from \"./getWidgetBuildOutputs.js\";\nimport { getWidgetSetInputSpec } from \"./getWidgetSetInputSpec.js\";\n\nexport function FoundryWidgetBuildPlugin(\n options?: FoundryWidgetPluginOptions,\n): Plugin {\n // The root HTML entrypoints of the build process\n let htmlEntrypoints: string[];\n // Store the resolved Vite config for use in later build steps\n let config: ResolvedConfig;\n\n return {\n name: BUILD_PLUGIN_ID,\n enforce: \"pre\",\n // Only apply this plugin during build\n apply: \"build\",\n\n /**\n * Capture the entrypoints from the Vite config for use in later build steps.\n */\n buildStart(options) {\n htmlEntrypoints = getInputHtmlEntrypoints(options);\n },\n\n /**\n * Store the resolved Vite config for use in later build steps.\n */\n configResolved(_config) {\n config = _config;\n },\n\n /**\n * Once the build is complete, generate the widget set manifest based on the entrypoints and\n * configuration files that were found.\n *\n * Write the manifest to the expected location in the dist directory.\n */\n async writeBundle(_, bundle) {\n const foundryConfig = await loadFoundryConfig(\"widgetSet\");\n if (foundryConfig == null) {\n throw new Error(\"foundry.config.json file not found.\");\n }\n\n // Create a Vite server to evaluate widget config modules\n const server = await createModuleEvaluationServer(config);\n\n try {\n // Build widget set manifest\n const widgetSetVersion = await computeWidgetSetVersion(foundryConfig);\n const widgetBuilds = await Promise.all(\n htmlEntrypoints.map((input) =>\n getWidgetBuildOutputs(bundle, input, config.build.outDir, server),\n ),\n );\n const widgetSetInputSpec = await getWidgetSetInputSpec(\n path.resolve(process.cwd(), \"package.json\"),\n path.resolve(process.cwd(), \"resources.json\"),\n );\n const widgetSetManifest = buildWidgetSetManifest(\n foundryConfig.foundryConfig.widgetSet.rid,\n widgetSetVersion,\n widgetBuilds,\n widgetSetInputSpec,\n options,\n );\n\n // Write the manifest to the dist directory\n writeManifest(widgetSetManifest, config.build.outDir);\n } finally {\n await server.close();\n }\n },\n };\n}\n\n/**\n * Create a Vite server for widget config module evaluation during the build process.\n * Must prevent loading the dev plugin to avoid triggering dev mode build steps.\n */\nasync function createModuleEvaluationServer(\n config: ResolvedConfig,\n): Promise<ViteDevServer> {\n return await createServer({\n // Reference the existing config file in order to respect any custom config\n configFile: config.configFile,\n // Custom mode to prevent dev plugin execution\n mode: MODULE_EVALUATION_MODE,\n });\n}\n\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nasync function computeWidgetSetVersion(\n foundryConfig: LoadedFoundryConfig<\"widgetSet\">,\n): Promise<string> {\n return autoVersion(\n foundryConfig.foundryConfig.widgetSet.autoVersion ?? {\n type: \"package-json\",\n },\n );\n}\n\nfunction writeManifest(\n widgetSetManifest: WidgetSetManifest,\n outDir: string,\n): void {\n const manifestPath = path.join(outDir, MANIFEST_FILE_LOCATION);\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true });\n fs.writeFileSync(manifestPath, JSON.stringify(widgetSetManifest, null, 2));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAGvB,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,2BAA2B;AAE1E,SAASC,sBAAsB,QAAQ,kBAAkB;AAEzD,SAASC,YAAY,QAAQ,MAAM;AAEnC,SACEC,eAAe,EACfC,sBAAsB,QACjB,wBAAwB;AAC/B,SAASC,uBAAuB,QAAQ,sCAAsC;AAE9E,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,qBAAqB,QAAQ,4BAA4B;AAElE,OAAO,SAASC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ACkB,SAAS,CAACC,GAAG,EACzCf,gBAAgB,EAChBE,YAAY,EACZO,kBAAkB,EAClBzB,OACF,CAAC;;QAED;QACAgC,aAAa,CAACH,iBAAiB,EAAE3B,MAAM,CAACqB,KAAK,CAACC,MAAM,CAAC;MACvD,CAAC,SAAS;QACR,MAAMV,MAAM,CAACmB,KAAK,CAAC,CAAC;MACtB;IACF;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,eAAelB,4BAA4BA,CACzCb,MAAsB,EACE;EACxB,OAAO,MAAMV,YAAY,CAAC;IACxB;IACA0C,UAAU,EAAEhC,MAAM,CAACgC,UAAU;IAC7B;IACAC,IAAI,EAAEzC;EACR,CAAC,CAAC;AACJ;;AAEA;AACA;AACA,eAAeuB,uBAAuBA,CACpCL,aAA+C,EAC9B;EACjB,OAAOvB,WAAW,CAChBuB,aAAa,CAACA,aAAa,CAACkB,SAAS,CAACzC,WAAW,IAAI;IACnD+C,IAAI,EAAE;EACR,CACF,CAAC;AACH;AAEA,SAASJ,aAAaA,CACpBH,iBAAoC,EACpCL,MAAc,EACR;EACN,MAAMa,YAAY,GAAGjD,IAAI,CAACkD,IAAI,CAACd,MAAM,EAAEjC,sBAAsB,CAAC;EAC9DJ,EAAE,CAACoD,SAAS,CAACnD,IAAI,CAACoD,OAAO,CAACH,YAAY,CAAC,EAAE;IAAEI,SAAS,EAAE;EAAK,CAAC,CAAC;EAC7DtD,EAAE,CAACuD,aAAa,CAACL,YAAY,EAAEM,IAAI,CAACC,SAAS,CAACf,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5E","ignoreList":[]}
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { readFile } from "fs/promises";
|
|
17
18
|
import { visitNpmPackages } from "../common/visitNpmPackages.js";
|
|
18
|
-
export async function getWidgetSetInputSpec(packageJsonPath) {
|
|
19
|
-
const sdks = await discoverOntologySdkInputSpecs(packageJsonPath);
|
|
19
|
+
export async function getWidgetSetInputSpec(packageJsonPath, resourcesJsonPath) {
|
|
20
|
+
const [sdks, authorizations] = await Promise.all([discoverOntologySdkInputSpecs(packageJsonPath), getAuthorizations(resourcesJsonPath)]);
|
|
20
21
|
return {
|
|
21
22
|
discovered: {
|
|
22
|
-
sdks
|
|
23
|
+
sdks,
|
|
24
|
+
authorizations
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
}
|
|
@@ -41,4 +43,37 @@ const fromKey = key => {
|
|
|
41
43
|
version
|
|
42
44
|
};
|
|
43
45
|
};
|
|
46
|
+
async function getAuthorizations(resourcesJsonPath) {
|
|
47
|
+
const parsedResourcesJson = await parseResourcesJson(resourcesJsonPath);
|
|
48
|
+
if (parsedResourcesJson == null) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const {
|
|
52
|
+
read,
|
|
53
|
+
requiredRead
|
|
54
|
+
} = parsedResourcesJson.authorizations ?? {};
|
|
55
|
+
return {
|
|
56
|
+
read,
|
|
57
|
+
requiredRead
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function parseResourcesJson(resourcesJsonPath) {
|
|
61
|
+
let content;
|
|
62
|
+
try {
|
|
63
|
+
content = await readFile(resourcesJsonPath, "utf-8");
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (err.code === "ENOENT") {
|
|
66
|
+
// the file is not present in the repo
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(content);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
throw new Error(`Failed to parse resources.json content from file "${resourcesJsonPath}"`, {
|
|
75
|
+
cause: err
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
44
79
|
//# sourceMappingURL=getWidgetSetInputSpec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWidgetSetInputSpec.js","names":["visitNpmPackages","getWidgetSetInputSpec","packageJsonPath","sdks","discoverOntologySdkInputSpecs","discovered","Set","_packageJsonPath","packageJson","osdk","packageRid","add","toKey","version","map","fromKey","SEPARATOR","rid","key","split"],"sources":["getWidgetSetInputSpec.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologySdkInputSpec,\n WidgetSetInputSpec,\n} from \"@osdk/widget.api\";\n\nimport type { PackageJson } from \"../common/PackageJson.js\";\nimport { visitNpmPackages } from \"../common/visitNpmPackages.js\";\n\nexport async function getWidgetSetInputSpec(\n packageJsonPath: string,\n): Promise<WidgetSetInputSpec> {\n const sdks = await discoverOntologySdkInputSpecs(packageJsonPath);\n return {\n discovered: {\n sdks,\n },\n };\n}\n\nasync function discoverOntologySdkInputSpecs(\n packageJsonPath: string,\n): Promise<Array<OntologySdkInputSpec>> {\n const sdks = new Set<string>();\n const onVisit = (_packageJsonPath: string, packageJson: PackageJson) => {\n if (packageJson.osdk?.packageRid != null) {\n sdks.add(toKey(packageJson.osdk.packageRid, packageJson.version));\n }\n };\n await visitNpmPackages(packageJsonPath, onVisit);\n return [...sdks].map(fromKey);\n}\n\nconst SEPARATOR = \"//\";\nconst toKey = (rid: string, version: string) => `${rid}${SEPARATOR}${version}`;\nconst fromKey = (key: string): OntologySdkInputSpec => {\n const [rid, version] = key.split(SEPARATOR);\n return {\n rid,\n version,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"file":"getWidgetSetInputSpec.js","names":["readFile","visitNpmPackages","getWidgetSetInputSpec","packageJsonPath","resourcesJsonPath","sdks","authorizations","Promise","all","discoverOntologySdkInputSpecs","getAuthorizations","discovered","Set","_packageJsonPath","packageJson","osdk","packageRid","add","toKey","version","map","fromKey","SEPARATOR","rid","key","split","parsedResourcesJson","parseResourcesJson","undefined","read","requiredRead","content","err","code","JSON","parse","Error","cause"],"sources":["getWidgetSetInputSpec.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readFile } from \"fs/promises\";\n\nimport type {\n OntologySdkInputSpec,\n WidgetSetAuthorizationsInputSpec,\n WidgetSetInputSpec,\n} from \"@osdk/widget.api\";\n\nimport type { PackageJson } from \"../common/PackageJson.js\";\nimport type { ResourcesJson } from \"../common/ResourcesJson.js\";\nimport { visitNpmPackages } from \"../common/visitNpmPackages.js\";\n\nexport async function getWidgetSetInputSpec(\n packageJsonPath: string,\n resourcesJsonPath: string,\n): Promise<WidgetSetInputSpec> {\n const [sdks, authorizations] = await Promise.all([\n discoverOntologySdkInputSpecs(packageJsonPath),\n getAuthorizations(resourcesJsonPath),\n ]);\n return {\n discovered: {\n sdks,\n authorizations,\n },\n };\n}\n\nasync function discoverOntologySdkInputSpecs(\n packageJsonPath: string,\n): Promise<Array<OntologySdkInputSpec>> {\n const sdks = new Set<string>();\n const onVisit = (_packageJsonPath: string, packageJson: PackageJson) => {\n if (packageJson.osdk?.packageRid != null) {\n sdks.add(toKey(packageJson.osdk.packageRid, packageJson.version));\n }\n };\n await visitNpmPackages(packageJsonPath, onVisit);\n return [...sdks].map(fromKey);\n}\n\nconst SEPARATOR = \"//\";\nconst toKey = (rid: string, version: string) => `${rid}${SEPARATOR}${version}`;\nconst fromKey = (key: string): OntologySdkInputSpec => {\n const [rid, version] = key.split(SEPARATOR);\n return {\n rid,\n version,\n };\n};\n\nasync function getAuthorizations(\n resourcesJsonPath: string,\n): Promise<WidgetSetAuthorizationsInputSpec | undefined> {\n const parsedResourcesJson: ResourcesJson | undefined =\n await parseResourcesJson(resourcesJsonPath);\n if (parsedResourcesJson == null) {\n return undefined;\n }\n const { read, requiredRead } = parsedResourcesJson.authorizations ?? {};\n return {\n read,\n requiredRead,\n };\n}\n\nasync function parseResourcesJson(\n resourcesJsonPath: string,\n): Promise<ResourcesJson | undefined> {\n let content: string;\n try {\n content = await readFile(resourcesJsonPath, \"utf-8\");\n } catch (err) {\n if ((err as { code?: string }).code === \"ENOENT\") {\n // the file is not present in the repo\n return undefined;\n }\n throw err;\n }\n\n try {\n return JSON.parse(content) as ResourcesJson;\n } catch (err) {\n throw new Error(\n `Failed to parse resources.json content from file \"${resourcesJsonPath}\"`,\n { cause: err },\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,aAAa;AAUtC,SAASC,gBAAgB,QAAQ,+BAA+B;AAEhE,OAAO,eAAeC,qBAAqBA,CACzCC,eAAuB,EACvBC,iBAAyB,EACI;EAC7B,MAAM,CAACC,IAAI,EAAEC,cAAc,CAAC,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC,CAC/CC,6BAA6B,CAACN,eAAe,CAAC,EAC9CO,iBAAiB,CAACN,iBAAiB,CAAC,CACrC,CAAC;EACF,OAAO;IACLO,UAAU,EAAE;MACVN,IAAI;MACJC;IACF;EACF,CAAC;AACH;AAEA,eAAeG,6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4B,GAAG,EAAE;IACZ,IAAKA,GAAG,CAAuBC,IAAI,KAAK,QAAQ,EAAE;MAChD;MACA,OAAOL,SAAS;IAClB;IACA,MAAMI,GAAG;EACX;EAEA,IAAI;IACF,OAAOE,IAAI,CAACC,KAAK,CAACJ,OAAO,CAAC;EAC5B,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ,MAAM,IAAII,KAAK,CACb,qDAAqDhC,iBAAiB,GAAG,EACzE;MAAEiC,KAAK,EAAEL;IAAI,CACf,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourcesJson.js","names":[],"sources":["ResourcesJson.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { WidgetSetAuthorizationsInputSpec } from \"@osdk/widget.api\";\n\ntype DeclaredWidgetSetAuthorizations = Pick<\n WidgetSetAuthorizationsInputSpec,\n \"read\" | \"requiredRead\"\n>;\n\ninterface ResourcesJsonV1 {\n authorizations: DeclaredWidgetSetAuthorizations;\n version: 1;\n}\n\nexport type ResourcesJson = ResourcesJsonV1;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -33,7 +33,7 @@ export async function buildDevModeManifest(server, codeEntrypoints, configFileTo
|
|
|
33
33
|
})), [], pluginOptions);
|
|
34
34
|
return [widgetConfig.id, manifest];
|
|
35
35
|
})));
|
|
36
|
-
const inputSpec = await getWidgetSetInputSpec(path.resolve(server.config.root, "package.json"));
|
|
36
|
+
const inputSpec = await getWidgetSetInputSpec(path.resolve(server.config.root, "package.json"), path.resolve(server.config.root, "resources.json"));
|
|
37
37
|
return {
|
|
38
38
|
manifestVersion: "1.0.0",
|
|
39
39
|
devSettings: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildDevModeManifest.js","names":["path","buildWidgetManifestConfig","getWidgetSetInputSpec","VITE_INJECTIONS_PATH","extractWidgetConfig","extractInjectedScripts","buildDevModeManifest","server","codeEntrypoints","configFileToEntrypoint","baseHref","pluginOptions","injectedScripts","widgets","Object","fromEntries","Promise","all","keys","map","configFile","widgetConfig","entrypointFile","entrypointRelativePath","scriptPaths","scriptSources","script","removeBasePath","slice","manifest","p","type","id","inputSpec","resolve","config","root","manifestVersion","devSettings","scriptPath","baseHrefPath","URL","pathname","replace"],"sources":["buildDevModeManifest.ts"],"sourcesContent":["/*\n * Copyright 2026 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 path from \"node:path\";\n\nimport type {\n WidgetManifestConfig,\n WidgetSetInputSpec,\n} from \"@osdk/widget.api\";\nimport type { ViteDevServer } from \"vite\";\n\nimport { buildWidgetManifestConfig } from \"../build-plugin/buildWidgetSetManifest.js\";\nimport { getWidgetSetInputSpec } from \"../build-plugin/getWidgetSetInputSpec.js\";\nimport { VITE_INJECTIONS_PATH } from \"../common/constants.js\";\nimport { extractWidgetConfig } from \"../common/extractWidgetConfig.js\";\nimport type { FoundryWidgetPluginOptions } from \"../index.js\";\nimport { extractInjectedScripts } from \"./extractInjectedScripts.js\";\n\nexport interface DevModeManifest {\n manifestVersion: \"1.0.0\";\n devSettings: {\n baseHref: string;\n widgets: Record<string, WidgetManifestConfig>;\n inputSpec?: WidgetSetInputSpec;\n };\n}\n\nexport async function buildDevModeManifest(\n server: ViteDevServer,\n codeEntrypoints: Record<string, string>,\n configFileToEntrypoint: Record<string, string>,\n baseHref: string,\n pluginOptions?: FoundryWidgetPluginOptions,\n): Promise<DevModeManifest> {\n const injectedScripts = await extractInjectedScripts(server);\n\n const widgets: Record<string, WidgetManifestConfig> = Object.fromEntries(\n await Promise.all(\n Object.keys(configFileToEntrypoint).map(async (configFile) => {\n const widgetConfig = await extractWidgetConfig(configFile, server);\n const entrypointFile = configFileToEntrypoint[configFile];\n const entrypointRelativePath = codeEntrypoints[entrypointFile];\n\n const scriptPaths = [\n VITE_INJECTIONS_PATH,\n ...injectedScripts.scriptSources.map((script) =>\n removeBasePath(script, baseHref),\n ),\n entrypointRelativePath.slice(1),\n ];\n\n const manifest = buildWidgetManifestConfig(\n widgetConfig,\n scriptPaths.map((p) => ({\n path: `${baseHref}${p}`,\n type: \"module\" as const,\n })),\n [],\n pluginOptions,\n );\n\n return [widgetConfig.id, manifest];\n }),\n ),\n );\n\n const inputSpec = await getWidgetSetInputSpec(\n path.resolve(server.config.root, \"package.json\"),\n );\n\n return {\n manifestVersion: \"1.0.0\",\n devSettings: {\n baseHref,\n widgets,\n inputSpec,\n },\n };\n}\n\nfunction removeBasePath(scriptPath: string, baseHref: string): string {\n const baseHrefPath = new URL(baseHref).pathname;\n return scriptPath.replace(baseHrefPath, \"\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,WAAW;AAQ5B,SAASC,yBAAyB,QAAQ,2CAA2C;AACrF,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,kCAAkC;AAEtE,SAASC,sBAAsB,QAAQ,6BAA6B;AAWpE,OAAO,eAAeC,oBAAoBA,CACxCC,MAAqB,EACrBC,eAAuC,EACvCC,sBAA8C,EAC9CC,QAAgB,EAChBC,aAA0C,EAChB;EAC1B,MAAMC,eAAe,GAAG,MAAMP,sBAAsB,CAACE,MAAM,CAAC;EAE5D,MAAMM,OAA6C,GAAGC,MAAM,CAACC,WAAW,CACtE,MAAMC,OAAO,CAACC,GAAG,CACfH,MAAM,CAACI,IAAI,CAACT,sBAAsB,CAAC,CAACU,GAAG,CAAC,MAAOC,UAAU,IAAK;IAC5D,MAAMC,YAAY,GAAG,MAAMjB,mBAAmB,CAACgB,UAAU,EAAEb,MAAM,CAAC;IAClE,MAAMe,cAAc,GAAGb,sBAAsB,CAACW,UAAU,CAAC;IACzD,MAAMG,sBAAsB,GAAGf,eAAe,CAACc,cAAc,CAAC;IAE9D,MAAME,WAAW,GAAG,CAClBrB,oBAAoB,EACpB,GAAGS,eAAe,CAACa,aAAa,CAACN,GAAG,CAAEO,MAAM,IAC1CC,cAAc,CAACD,MAAM,EAAEhB,QAAQ,CACjC,CAAC,EACDa,sBAAsB,CAACK,KAAK,CAAC,CAAC,CAAC,CAChC;IAED,MAAMC,QAAQ,GAAG5B,yBAAyB,CACxCoB,YAAY,EACZG,WAAW,CAACL,GAAG,CAAEW,CAAC,KAAM;MACtB9B,IAAI,EAAE,GAAGU,QAAQ,GAAGoB,CAAC,EAAE;MACvBC,IAAI,EAAE;IACR,CAAC,CAAC,CAAC,EACH,EAAE,EACFpB,aACF,CAAC;IAED,OAAO,CAACU,YAAY,CAACW,EAAE,EAAEH,QAAQ,CAAC;EACpC,CAAC,CACH,CACF,CAAC;EAED,MAAMI,SAAS,GAAG,MAAM/B,qBAAqB,CAC3CF,IAAI,CAACkC,OAAO,CAAC3B,MAAM,CAAC4B,MAAM,CAACC,IAAI,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"buildDevModeManifest.js","names":["path","buildWidgetManifestConfig","getWidgetSetInputSpec","VITE_INJECTIONS_PATH","extractWidgetConfig","extractInjectedScripts","buildDevModeManifest","server","codeEntrypoints","configFileToEntrypoint","baseHref","pluginOptions","injectedScripts","widgets","Object","fromEntries","Promise","all","keys","map","configFile","widgetConfig","entrypointFile","entrypointRelativePath","scriptPaths","scriptSources","script","removeBasePath","slice","manifest","p","type","id","inputSpec","resolve","config","root","manifestVersion","devSettings","scriptPath","baseHrefPath","URL","pathname","replace"],"sources":["buildDevModeManifest.ts"],"sourcesContent":["/*\n * Copyright 2026 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 path from \"node:path\";\n\nimport type {\n WidgetManifestConfig,\n WidgetSetInputSpec,\n} from \"@osdk/widget.api\";\nimport type { ViteDevServer } from \"vite\";\n\nimport { buildWidgetManifestConfig } from \"../build-plugin/buildWidgetSetManifest.js\";\nimport { getWidgetSetInputSpec } from \"../build-plugin/getWidgetSetInputSpec.js\";\nimport { VITE_INJECTIONS_PATH } from \"../common/constants.js\";\nimport { extractWidgetConfig } from \"../common/extractWidgetConfig.js\";\nimport type { FoundryWidgetPluginOptions } from \"../index.js\";\nimport { extractInjectedScripts } from \"./extractInjectedScripts.js\";\n\nexport interface DevModeManifest {\n manifestVersion: \"1.0.0\";\n devSettings: {\n baseHref: string;\n widgets: Record<string, WidgetManifestConfig>;\n inputSpec?: WidgetSetInputSpec;\n };\n}\n\nexport async function buildDevModeManifest(\n server: ViteDevServer,\n codeEntrypoints: Record<string, string>,\n configFileToEntrypoint: Record<string, string>,\n baseHref: string,\n pluginOptions?: FoundryWidgetPluginOptions,\n): Promise<DevModeManifest> {\n const injectedScripts = await extractInjectedScripts(server);\n\n const widgets: Record<string, WidgetManifestConfig> = Object.fromEntries(\n await Promise.all(\n Object.keys(configFileToEntrypoint).map(async (configFile) => {\n const widgetConfig = await extractWidgetConfig(configFile, server);\n const entrypointFile = configFileToEntrypoint[configFile];\n const entrypointRelativePath = codeEntrypoints[entrypointFile];\n\n const scriptPaths = [\n VITE_INJECTIONS_PATH,\n ...injectedScripts.scriptSources.map((script) =>\n removeBasePath(script, baseHref),\n ),\n entrypointRelativePath.slice(1),\n ];\n\n const manifest = buildWidgetManifestConfig(\n widgetConfig,\n scriptPaths.map((p) => ({\n path: `${baseHref}${p}`,\n type: \"module\" as const,\n })),\n [],\n pluginOptions,\n );\n\n return [widgetConfig.id, manifest];\n }),\n ),\n );\n\n const inputSpec = await getWidgetSetInputSpec(\n path.resolve(server.config.root, \"package.json\"),\n path.resolve(server.config.root, \"resources.json\"),\n );\n\n return {\n manifestVersion: \"1.0.0\",\n devSettings: {\n baseHref,\n widgets,\n inputSpec,\n },\n };\n}\n\nfunction removeBasePath(scriptPath: string, baseHref: string): string {\n const baseHrefPath = new URL(baseHref).pathname;\n return scriptPath.replace(baseHrefPath, \"\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,WAAW;AAQ5B,SAASC,yBAAyB,QAAQ,2CAA2C;AACrF,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,kCAAkC;AAEtE,SAASC,sBAAsB,QAAQ,6BAA6B;AAWpE,OAAO,eAAeC,oBAAoBA,CACxCC,MAAqB,EACrBC,eAAuC,EACvCC,sBAA8C,EAC9CC,QAAgB,EAChBC,aAA0C,EAChB;EAC1B,MAAMC,eAAe,GAAG,MAAMP,sBAAsB,CAACE,MAAM,CAAC;EAE5D,MAAMM,OAA6C,GAAGC,MAAM,CAACC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,CAAC/B,QAAQ,CAAC,CAACgC,QAAQ;EAC/C,OAAOH,UAAU,CAACI,OAAO,CAACH,YAAY,EAAE,EAAE,CAAC;AAC7C","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { WidgetSetInputSpec } from "@osdk/widget.api";
|
|
2
|
-
export declare function getWidgetSetInputSpec(packageJsonPath: string): Promise<WidgetSetInputSpec>;
|
|
2
|
+
export declare function getWidgetSetInputSpec(packageJsonPath: string, resourcesJsonPath: string): Promise<WidgetSetInputSpec>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":"AAkBA,cAGE,0BACK,kBAAmB;AAM1B,OAAO,iBAAe,sBACpBA,yBACAC,4BACC,QAAQ","names":["packageJsonPath: string","resourcesJsonPath: string"],"sources":["../../../src/build-plugin/getWidgetSetInputSpec.ts"],"version":3,"file":"getWidgetSetInputSpec.d.ts"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WidgetSetAuthorizationsInputSpec } from "@osdk/widget.api";
|
|
2
|
+
type DeclaredWidgetSetAuthorizations = Pick<WidgetSetAuthorizationsInputSpec, "read" | "requiredRead">;
|
|
3
|
+
interface ResourcesJsonV1 {
|
|
4
|
+
authorizations: DeclaredWidgetSetAuthorizations;
|
|
5
|
+
version: 1;
|
|
6
|
+
}
|
|
7
|
+
export type ResourcesJson = ResourcesJsonV1;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,wCAAwC,kBAAmB;KAEpE,kCAAkC,KACrC,kCACA,SAAS;UAGD,gBAAgB;CACxB,gBAAgB;CAChB,SAAS;AACV;AAED,YAAY,gBAAgB","names":[],"sources":["../../../src/common/ResourcesJson.ts"],"version":3,"file":"ResourcesJson.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/widget.vite-plugin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.54.0-main-e8584ece14b283cd7995920e66dc275e9ab9edbe",
|
|
4
4
|
"description": "A vite plugin that will extract parameter definitions from TS/JS files + entrypoint info into a manifest file to be uploaded to Foundry ",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"resolve-package-path": "^4.0.3",
|
|
32
32
|
"sirv": "^3.0.2",
|
|
33
33
|
"@osdk/foundry-config-json": "~1.12.0",
|
|
34
|
-
"@osdk/widget.api": "~3.
|
|
34
|
+
"@osdk/widget.api": "~3.54.0-main-e8584ece14b283cd7995920e66dc275e9ab9edbe"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"vite": "^6.3.6 || ^7.3.1"
|