@osdk/widget.vite-plugin 3.5.0-beta.2 → 3.5.0-beta.20
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 +139 -0
- package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js +2 -2
- package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js.map +1 -1
- package/build/esm/build-plugin/buildWidgetSetManifest.js +8 -6
- package/build/esm/build-plugin/buildWidgetSetManifest.js.map +1 -1
- package/build/esm/common/validateWidgetConfig.js +2 -2
- package/build/esm/common/validateWidgetConfig.js.map +1 -1
- package/build/esm/dev-plugin/FoundryWidgetDevPlugin.js +10 -0
- package/build/esm/dev-plugin/FoundryWidgetDevPlugin.js.map +1 -1
- package/build/esm/index.js +2 -2
- package/build/esm/index.js.map +1 -1
- package/build/site/assets/{allPaths-DIfrnzgS.js → allPaths-DQ44lpsR.js} +1 -1
- package/build/site/assets/{allPathsLoader-D2qNtTEN.js → allPathsLoader-DxfybG1q.js} +2 -2
- package/build/site/assets/index-BAmk2r3A.css +1 -0
- package/build/site/assets/index-y3oyBPN4.js +8 -0
- package/build/site/assets/{splitPathsBySizeLoader-CuGV5Hrn.js → splitPathsBySizeLoader-B7rF-lK3.js} +1 -1
- package/build/site/index.html +2 -2
- package/build/types/build-plugin/FoundryWidgetBuildPlugin.d.ts +2 -1
- package/build/types/build-plugin/FoundryWidgetBuildPlugin.d.ts.map +1 -1
- package/build/types/build-plugin/buildWidgetSetManifest.d.ts +2 -1
- package/build/types/build-plugin/buildWidgetSetManifest.d.ts.map +1 -1
- package/build/types/index.d.ts +13 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/build/esm/build-plugin/__tests__/buildWidgetSetManifest.test.js +0 -163
- package/build/esm/build-plugin/__tests__/buildWidgetSetManifest.test.js.map +0 -1
- package/build/esm/build-plugin/__tests__/extractBuildOutputs.test.js +0 -133
- package/build/esm/build-plugin/__tests__/extractBuildOutputs.test.js.map +0 -1
- package/build/esm/build-plugin/__tests__/getWidgetBuildOutputs.test.js +0 -153
- package/build/esm/build-plugin/__tests__/getWidgetBuildOutputs.test.js.map +0 -1
- package/build/esm/build-plugin/__tests__/getWidgetSetInputSpec.test.js +0 -96
- package/build/esm/build-plugin/__tests__/getWidgetSetInputSpec.test.js.map +0 -1
- package/build/esm/build-plugin/__tests__/isConfigFile.test.js +0 -26
- package/build/esm/build-plugin/__tests__/isConfigFile.test.js.map +0 -1
- package/build/esm/build-plugin/__tests__/validateWidgetSet.test.js +0 -44
- package/build/esm/build-plugin/__tests__/validateWidgetSet.test.js.map +0 -1
- package/build/esm/common/__tests__/extractWidgetConfig.test.js +0 -95
- package/build/esm/common/__tests__/extractWidgetConfig.test.js.map +0 -1
- package/build/esm/common/__tests__/getInputHtmlEntrypoints.test.js +0 -38
- package/build/esm/common/__tests__/getInputHtmlEntrypoints.test.js.map +0 -1
- package/build/esm/common/__tests__/standardizePathAndFileExtension.test.js +0 -77
- package/build/esm/common/__tests__/standardizePathAndFileExtension.test.js.map +0 -1
- package/build/esm/common/__tests__/validateWidgetConfig.test.js +0 -136
- package/build/esm/common/__tests__/validateWidgetConfig.test.js.map +0 -1
- package/build/esm/common/__tests__/visitNpmPackages.test.js +0 -74
- package/build/esm/common/__tests__/visitNpmPackages.test.js.map +0 -1
- package/build/esm/dev-plugin/__tests__/codeWorkspacesMode.test.js +0 -87
- package/build/esm/dev-plugin/__tests__/codeWorkspacesMode.test.js.map +0 -1
- package/build/esm/dev-plugin/__tests__/extractInjectedScripts.test.js +0 -34
- package/build/esm/dev-plugin/__tests__/extractInjectedScripts.test.js.map +0 -1
- package/build/esm/dev-plugin/__tests__/getBaseHref.test.js +0 -48
- package/build/esm/dev-plugin/__tests__/getBaseHref.test.js.map +0 -1
- package/build/esm/dev-plugin/__tests__/getWidgetIdOverrideMap.test.js +0 -71
- package/build/esm/dev-plugin/__tests__/getWidgetIdOverrideMap.test.js.map +0 -1
- package/build/esm/dev-plugin/__tests__/validateDevEnvironment.test.js +0 -66
- package/build/esm/dev-plugin/__tests__/validateDevEnvironment.test.js.map +0 -1
- package/build/site/assets/index-7niI6nVb.css +0 -1
- package/build/site/assets/index-D6Sm-vP3.js +0 -44
- package/build/types/build-plugin/__tests__/buildWidgetSetManifest.test.d.ts +0 -1
- package/build/types/build-plugin/__tests__/buildWidgetSetManifest.test.d.ts.map +0 -1
- package/build/types/build-plugin/__tests__/extractBuildOutputs.test.d.ts +0 -1
- package/build/types/build-plugin/__tests__/extractBuildOutputs.test.d.ts.map +0 -1
- package/build/types/build-plugin/__tests__/getWidgetBuildOutputs.test.d.ts +0 -1
- package/build/types/build-plugin/__tests__/getWidgetBuildOutputs.test.d.ts.map +0 -1
- package/build/types/build-plugin/__tests__/getWidgetSetInputSpec.test.d.ts +0 -1
- package/build/types/build-plugin/__tests__/getWidgetSetInputSpec.test.d.ts.map +0 -1
- package/build/types/build-plugin/__tests__/isConfigFile.test.d.ts +0 -1
- package/build/types/build-plugin/__tests__/isConfigFile.test.d.ts.map +0 -1
- package/build/types/build-plugin/__tests__/validateWidgetSet.test.d.ts +0 -1
- package/build/types/build-plugin/__tests__/validateWidgetSet.test.d.ts.map +0 -1
- package/build/types/common/__tests__/extractWidgetConfig.test.d.ts +0 -1
- package/build/types/common/__tests__/extractWidgetConfig.test.d.ts.map +0 -1
- package/build/types/common/__tests__/getInputHtmlEntrypoints.test.d.ts +0 -1
- package/build/types/common/__tests__/getInputHtmlEntrypoints.test.d.ts.map +0 -1
- package/build/types/common/__tests__/standardizePathAndFileExtension.test.d.ts +0 -1
- package/build/types/common/__tests__/standardizePathAndFileExtension.test.d.ts.map +0 -1
- package/build/types/common/__tests__/validateWidgetConfig.test.d.ts +0 -1
- package/build/types/common/__tests__/validateWidgetConfig.test.d.ts.map +0 -1
- package/build/types/common/__tests__/visitNpmPackages.test.d.ts +0 -1
- package/build/types/common/__tests__/visitNpmPackages.test.d.ts.map +0 -1
- package/build/types/dev-plugin/__tests__/codeWorkspacesMode.test.d.ts +0 -1
- package/build/types/dev-plugin/__tests__/codeWorkspacesMode.test.d.ts.map +0 -1
- package/build/types/dev-plugin/__tests__/extractInjectedScripts.test.d.ts +0 -1
- package/build/types/dev-plugin/__tests__/extractInjectedScripts.test.d.ts.map +0 -1
- package/build/types/dev-plugin/__tests__/getBaseHref.test.d.ts +0 -1
- package/build/types/dev-plugin/__tests__/getBaseHref.test.d.ts.map +0 -1
- package/build/types/dev-plugin/__tests__/getWidgetIdOverrideMap.test.d.ts +0 -1
- package/build/types/dev-plugin/__tests__/getWidgetIdOverrideMap.test.d.ts.map +0 -1
- package/build/types/dev-plugin/__tests__/validateDevEnvironment.test.d.ts +0 -1
- package/build/types/dev-plugin/__tests__/validateDevEnvironment.test.d.ts.map +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { resolve } from "path";
|
|
18
|
-
import { expect, test, vi } from "vitest";
|
|
19
|
-
import { visitNpmPackages } from "../../common/visitNpmPackages.js";
|
|
20
|
-
import { getWidgetSetInputSpec } from "../getWidgetSetInputSpec.js";
|
|
21
|
-
vi.mock("../../common/visitNpmPackages.ts");
|
|
22
|
-
test("getWidgetSetInputSpec successfully discovers OSDK packages", async () => {
|
|
23
|
-
const packageJson1 = {
|
|
24
|
-
name: "package1",
|
|
25
|
-
version: "0.1.0",
|
|
26
|
-
dependencies: {
|
|
27
|
-
"package2": "0.2.0",
|
|
28
|
-
"package3": "0.3.0"
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const packageJson2 = {
|
|
32
|
-
name: "package2",
|
|
33
|
-
version: "0.2.0",
|
|
34
|
-
dependencies: {
|
|
35
|
-
"package3": "0.3.0",
|
|
36
|
-
"package4": "0.4.0"
|
|
37
|
-
},
|
|
38
|
-
osdk: {
|
|
39
|
-
packageRid: "ridPackage2"
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const packageJson3 = {
|
|
43
|
-
name: "package3",
|
|
44
|
-
version: "0.3.0",
|
|
45
|
-
dependencies: {
|
|
46
|
-
"package4": "0.4.1"
|
|
47
|
-
},
|
|
48
|
-
osdk: {
|
|
49
|
-
packageRid: "ridPackage3"
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const packageJson4 = {
|
|
53
|
-
name: "package4",
|
|
54
|
-
version: "0.4.0",
|
|
55
|
-
osdk: {
|
|
56
|
-
packageRid: "ridPackage4"
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const packageJson4_1 = {
|
|
60
|
-
name: "package4",
|
|
61
|
-
version: "0.4.1",
|
|
62
|
-
osdk: {
|
|
63
|
-
packageRid: "ridPackage4"
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
vi.mocked(visitNpmPackages).mockImplementation((packageJsonPath, onVisit) => {
|
|
67
|
-
onVisit(packageJsonPath, packageJson1);
|
|
68
|
-
onVisit(resolve(packageJsonPath, "/node_modules/package2@0.2.0/package.json"), packageJson2);
|
|
69
|
-
onVisit(resolve(packageJsonPath, "/node_modules/package3@0.3.0/package.json"), packageJson3);
|
|
70
|
-
// Handle multiple versions of same OSDK package
|
|
71
|
-
onVisit(resolve(packageJsonPath, "/node_modules/package4@0.4.0/package.json"), packageJson4);
|
|
72
|
-
onVisit(resolve(packageJsonPath, "/node_modules/package4@0.4.1/package.json"), packageJson4_1);
|
|
73
|
-
// Handle multiple occurrences of same version of OSDK package
|
|
74
|
-
onVisit(resolve(packageJsonPath, "/node_modules/package4@0.4.1/package.json"), packageJson4_1);
|
|
75
|
-
return Promise.resolve();
|
|
76
|
-
});
|
|
77
|
-
const widgetSetInputSpec = await getWidgetSetInputSpec("/path/to/package.json");
|
|
78
|
-
expect(widgetSetInputSpec).toEqual({
|
|
79
|
-
discovered: {
|
|
80
|
-
sdks: [{
|
|
81
|
-
rid: "ridPackage2",
|
|
82
|
-
version: "0.2.0"
|
|
83
|
-
}, {
|
|
84
|
-
rid: "ridPackage3",
|
|
85
|
-
version: "0.3.0"
|
|
86
|
-
}, {
|
|
87
|
-
rid: "ridPackage4",
|
|
88
|
-
version: "0.4.0"
|
|
89
|
-
}, {
|
|
90
|
-
rid: "ridPackage4",
|
|
91
|
-
version: "0.4.1"
|
|
92
|
-
}]
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
//# sourceMappingURL=getWidgetSetInputSpec.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getWidgetSetInputSpec.test.js","names":["resolve","expect","test","vi","visitNpmPackages","getWidgetSetInputSpec","mock","packageJson1","name","version","dependencies","packageJson2","osdk","packageRid","packageJson3","packageJson4","packageJson4_1","mocked","mockImplementation","packageJsonPath","onVisit","Promise","widgetSetInputSpec","toEqual","discovered","sdks","rid"],"sources":["getWidgetSetInputSpec.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { resolve } from \"path\";\nimport { expect, test, vi } from \"vitest\";\nimport type { PackageJson } from \"../../common/PackageJson.js\";\nimport { visitNpmPackages } from \"../../common/visitNpmPackages.js\";\nimport { getWidgetSetInputSpec } from \"../getWidgetSetInputSpec.js\";\n\nvi.mock(\"../../common/visitNpmPackages.ts\");\n\ntest(\"getWidgetSetInputSpec successfully discovers OSDK packages\", async () => {\n const packageJson1: PackageJson = {\n name: \"package1\",\n version: \"0.1.0\",\n dependencies: {\n \"package2\": \"0.2.0\",\n \"package3\": \"0.3.0\",\n },\n };\n const packageJson2: PackageJson = {\n name: \"package2\",\n version: \"0.2.0\",\n dependencies: {\n \"package3\": \"0.3.0\",\n \"package4\": \"0.4.0\",\n },\n osdk: {\n packageRid: \"ridPackage2\",\n },\n };\n const packageJson3: PackageJson = {\n name: \"package3\",\n version: \"0.3.0\",\n dependencies: {\n \"package4\": \"0.4.1\",\n },\n osdk: {\n packageRid: \"ridPackage3\",\n },\n };\n const packageJson4: PackageJson = {\n name: \"package4\",\n version: \"0.4.0\",\n osdk: {\n packageRid: \"ridPackage4\",\n },\n };\n const packageJson4_1: PackageJson = {\n name: \"package4\",\n version: \"0.4.1\",\n osdk: {\n packageRid: \"ridPackage4\",\n },\n };\n\n vi.mocked(visitNpmPackages).mockImplementation(\n (packageJsonPath, onVisit) => {\n onVisit(packageJsonPath, packageJson1);\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package2@0.2.0/package.json\"),\n packageJson2,\n );\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package3@0.3.0/package.json\"),\n packageJson3,\n );\n // Handle multiple versions of same OSDK package\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package4@0.4.0/package.json\"),\n packageJson4,\n );\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package4@0.4.1/package.json\"),\n packageJson4_1,\n );\n // Handle multiple occurrences of same version of OSDK package\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package4@0.4.1/package.json\"),\n packageJson4_1,\n );\n return Promise.resolve();\n },\n );\n const widgetSetInputSpec = await getWidgetSetInputSpec(\n \"/path/to/package.json\",\n );\n\n expect(widgetSetInputSpec).toEqual({\n discovered: {\n sdks: [\n { rid: \"ridPackage2\", version: \"0.2.0\" },\n { rid: \"ridPackage3\", version: \"0.3.0\" },\n { rid: \"ridPackage4\", version: \"0.4.0\" },\n { rid: \"ridPackage4\", version: \"0.4.1\" },\n ],\n },\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,MAAM;AAC9B,SAASC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAQ,QAAQ;AAEzC,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,qBAAqB,QAAQ,6BAA6B;AAEnEF,EAAE,CAACG,IAAI,CAAC,kCAAkC,CAAC;AAE3CJ,IAAI,CAAC,4DAA4D,EAAE,YAAY;EAC7E,MAAMK,YAAyB,GAAG;IAChCC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE,OAAO;IAChBC,YAAY,EAAE;MACZ,UAAU,EAAE,OAAO;MACnB,UAAU,EAAE;IACd;EACF,CAAC;EACD,MAAMC,YAAyB,GAAG;IAChCH,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE,OAAO;IAChBC,YAAY,EAAE;MACZ,UAAU,EAAE,OAAO;MACnB,UAAU,EAAE;IACd,CAAC;IACDE,IAAI,EAAE;MACJC,UAAU,EAAE;IACd;EACF,CAAC;EACD,MAAMC,YAAyB,GAAG;IAChCN,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE,OAAO;IAChBC,YAAY,EAAE;MACZ,UAAU,EAAE;IACd,CAAC;IACDE,IAAI,EAAE;MACJC,UAAU,EAAE;IACd;EACF,CAAC;EACD,MAAME,YAAyB,GAAG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O,EAAE;MAAQ,CAAC;IAE5C;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { expect, test } from "vitest";
|
|
18
|
-
import { isConfigFile } from "../isConfigFile.js";
|
|
19
|
-
test("isConfigFile identifies config files", () => {
|
|
20
|
-
expect(isConfigFile("./widget.config.ts")).toBe(true);
|
|
21
|
-
expect(isConfigFile("./widget.config.js")).toBe(true);
|
|
22
|
-
expect(isConfigFile("/my-assets/widget.config")).toBe(true);
|
|
23
|
-
expect(isConfigFile("/assets/config")).toBe(false);
|
|
24
|
-
expect(isConfigFile("")).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=isConfigFile.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isConfigFile.test.js","names":["expect","test","isConfigFile","toBe"],"sources":["isConfigFile.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { expect, test } from \"vitest\";\nimport { isConfigFile } from \"../isConfigFile.js\";\n\ntest(\"isConfigFile identifies config files\", () => {\n expect(isConfigFile(\"./widget.config.ts\")).toBe(true);\n expect(isConfigFile(\"./widget.config.js\")).toBe(true);\n expect(isConfigFile(\"/my-assets/widget.config\")).toBe(true);\n\n expect(isConfigFile(\"/assets/config\")).toBe(false);\n expect(isConfigFile(\"\")).toBe(false);\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AACrC,SAASC,YAAY,QAAQ,oBAAoB;AAEjDD,IAAI,CAAC,sCAAsC,EAAE,MAAM;EACjDD,MAAM,CAACE,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;EACrDH,MAAM,CAACE,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;EACrDH,MAAM,CAACE,YAAY,CAAC,0BAA0B,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;EAE3DH,MAAM,CAACE,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,CAAC;EAClDH,MAAM,CAACE,YAAY,CAAC,EAAE,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,CAAC;AACtC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { describe, expect, it } from "vitest";
|
|
18
|
-
import { validateWidgetSet } from "../validateWidgetSet.js";
|
|
19
|
-
describe("validateWidgetSet", () => {
|
|
20
|
-
describe("validateWidgetIds", () => {
|
|
21
|
-
it("should not throw when all widget IDs are unique", () => {
|
|
22
|
-
const widgetBuilds = [createWidgetBuild("widget1"), createWidgetBuild("widget2"), createWidgetBuild("widget3")];
|
|
23
|
-
expect(() => validateWidgetSet(widgetBuilds)).not.toThrow();
|
|
24
|
-
});
|
|
25
|
-
it("should throw when duplicate widget IDs are found", () => {
|
|
26
|
-
const widgetBuilds = [createWidgetBuild("widget1"), createWidgetBuild("widget2"), createWidgetBuild("widget1")];
|
|
27
|
-
expect(() => validateWidgetSet(widgetBuilds)).toThrow("Duplicate widget ID: widget1. Each widget must have a unique ID.");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
function createWidgetBuild(id) {
|
|
32
|
-
return {
|
|
33
|
-
widgetConfig: {
|
|
34
|
-
id,
|
|
35
|
-
name: `Widget ${id}`,
|
|
36
|
-
type: "workshop",
|
|
37
|
-
parameters: {},
|
|
38
|
-
events: {}
|
|
39
|
-
},
|
|
40
|
-
scripts: [],
|
|
41
|
-
stylesheets: []
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=validateWidgetSet.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateWidgetSet.test.js","names":["describe","expect","it","validateWidgetSet","widgetBuilds","createWidgetBuild","not","toThrow","id","widgetConfig","name","type","parameters","events","scripts","stylesheets"],"sources":["validateWidgetSet.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\nimport type { WidgetBuildOutputs } from \"../getWidgetBuildOutputs.js\";\nimport { validateWidgetSet } from \"../validateWidgetSet.js\";\n\ndescribe(\"validateWidgetSet\", () => {\n describe(\"validateWidgetIds\", () => {\n it(\"should not throw when all widget IDs are unique\", () => {\n const widgetBuilds: WidgetBuildOutputs[] = [\n createWidgetBuild(\"widget1\"),\n createWidgetBuild(\"widget2\"),\n createWidgetBuild(\"widget3\"),\n ];\n\n expect(() => validateWidgetSet(widgetBuilds)).not.toThrow();\n });\n\n it(\"should throw when duplicate widget IDs are found\", () => {\n const widgetBuilds: WidgetBuildOutputs[] = [\n createWidgetBuild(\"widget1\"),\n createWidgetBuild(\"widget2\"),\n createWidgetBuild(\"widget1\"),\n ];\n\n expect(() => validateWidgetSet(widgetBuilds)).toThrow(\n \"Duplicate widget ID: widget1. Each widget must have a unique ID.\",\n );\n });\n });\n});\n\nfunction createWidgetBuild(id: string): WidgetBuildOutputs {\n return {\n widgetConfig: {\n id,\n name: `Widget ${id}`,\n type: \"workshop\",\n parameters: {},\n events: {},\n },\n scripts: [],\n stylesheets: [],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,iBAAiB,QAAQ,yBAAyB;AAE3DH,QAAQ,CAAC,mBAAmB,EAAE,MAAM;EAClCA,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IAClCE,EAAE,CAAC,iDAAiD,EAAE,MAAM;MAC1D,MAAME,YAAkC,GAAG,CACzCC,iBAAiB,CAAC,SAAS,CAAC,EAC5BA,iBAAiB,CAAC,SAAS,CAAC,EAC5BA,iBAAiB,CAAC,SAAS,CAAC,CAC7B;MAEDJ,MAAM,CAAC,MAAME,iBAAiB,CAACC,YAAY,CAAC,CAAC,CAACE,GAAG,CAACC,OAAO,CAAC,CAAC;IAC7D,CAAC,CAAC;IAEFL,EAAE,CAAC,kDAAkD,EAAE,MAAM;MAC3D,MAAME,YAAkC,GAAG,CACzCC,iBAAiB,CAAC,SAAS,CAAC,EAC5BA,iBAAiB,CAAC,SAAS,CAAC,EAC5BA,iBAAiB,CAAC,SAAS,CAAC,CAC7B;MAEDJ,MAAM,CAAC,MAAME,iBAAiB,CAACC,YAAY,CAAC,CAAC,CAACG,OAAO,CACnD,kEACF,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,SAASF,iBAAiBA,CAACG,EAAU,EAAsB;EACzD,OAAO;IACLC,YAAY,EAAE;MACZD,EAAE;MACFE,IAAI,EAAE,UAAUF,EAAE,EAAE;MACpBG,IAAI,EAAE,UAAU;MAChBC,UAAU,EAAE,CAAC,CAAC;MACdC,MAAM,EAAE,CAAC;IACX,CAAC;IACDC,OAAO,EAAE,EAAE;IACXC,WAAW,EAAE;EACf,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
18
|
-
import { extractWidgetConfig } from "../extractWidgetConfig.js";
|
|
19
|
-
import * as validateWidgetConfigModule from "../validateWidgetConfig.js";
|
|
20
|
-
const MOCK_SERVER = {
|
|
21
|
-
ssrLoadModule: vi.fn()
|
|
22
|
-
};
|
|
23
|
-
describe("extractWidgetConfig", () => {
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
vi.restoreAllMocks();
|
|
26
|
-
});
|
|
27
|
-
test("extracts valid widget configuration", async () => {
|
|
28
|
-
vi.mocked(MOCK_SERVER.ssrLoadModule).mockResolvedValue({
|
|
29
|
-
default: MOCK_CONFIG
|
|
30
|
-
});
|
|
31
|
-
const validateSpy = vi.spyOn(validateWidgetConfigModule, "validateWidgetConfig");
|
|
32
|
-
const result = await extractWidgetConfig("/path/to/config.ts", MOCK_SERVER);
|
|
33
|
-
expect(result).toEqual(MOCK_CONFIG);
|
|
34
|
-
expect(validateSpy).toHaveBeenCalledWith(MOCK_CONFIG);
|
|
35
|
-
});
|
|
36
|
-
test("throws for invalid widget configuration", async () => {
|
|
37
|
-
vi.mocked(MOCK_SERVER.ssrLoadModule).mockResolvedValue({
|
|
38
|
-
default: {
|
|
39
|
-
id: "Invalid-Id",
|
|
40
|
-
name: "Test Widget",
|
|
41
|
-
type: "workshop",
|
|
42
|
-
parameters: {}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
vi.spyOn(validateWidgetConfigModule, "validateWidgetConfig").mockImplementation(config => {
|
|
46
|
-
throw new Error(`Widget id "${config.id}" does not match allowed pattern (must be camelCase)`);
|
|
47
|
-
});
|
|
48
|
-
await expect(extractWidgetConfig("/path/to/config.ts", MOCK_SERVER)).rejects.toThrow(expect.objectContaining({
|
|
49
|
-
message: "Encountered error: 'Widget id \"Invalid-Id\" does not match allowed pattern (must be camelCase)' while loading widget config from /path/to/config.ts",
|
|
50
|
-
cause: expect.objectContaining({
|
|
51
|
-
message: `Widget id "Invalid-Id" does not match allowed pattern (must be camelCase)`
|
|
52
|
-
})
|
|
53
|
-
}));
|
|
54
|
-
});
|
|
55
|
-
test("throws for missing default export", async () => {
|
|
56
|
-
vi.mocked(MOCK_SERVER.ssrLoadModule).mockResolvedValue({
|
|
57
|
-
notDefault: {
|
|
58
|
-
id: "test"
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
await expect(extractWidgetConfig("/path/to/config.ts", MOCK_SERVER)).rejects.toThrow(expect.objectContaining({
|
|
62
|
-
message: "Encountered error: 'No default export found in /path/to/config.ts' while loading widget config from /path/to/config.ts",
|
|
63
|
-
cause: expect.objectContaining({
|
|
64
|
-
message: "No default export found in /path/to/config.ts"
|
|
65
|
-
})
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
test("throws for invalid module path", async () => {
|
|
69
|
-
vi.mocked(MOCK_SERVER.ssrLoadModule).mockRejectedValue(new Error("Module loading failed"));
|
|
70
|
-
await expect(extractWidgetConfig("/invalid/path/config.ts", MOCK_SERVER)).rejects.toThrow("Encountered error: 'Module loading failed' while loading widget config from /invalid/path/config.ts");
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
const MOCK_CONFIG = {
|
|
74
|
-
id: "testWidget",
|
|
75
|
-
name: "Test Widget",
|
|
76
|
-
description: "A test widget",
|
|
77
|
-
type: "workshop",
|
|
78
|
-
parameters: {
|
|
79
|
-
paramOne: {
|
|
80
|
-
displayName: "Parameter One",
|
|
81
|
-
type: "string"
|
|
82
|
-
},
|
|
83
|
-
paramTwo: {
|
|
84
|
-
displayName: "Parameter Two",
|
|
85
|
-
type: "string"
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
events: {
|
|
89
|
-
updateParameters: {
|
|
90
|
-
displayName: "Update Parameters",
|
|
91
|
-
parameterUpdateIds: ["paramOne", "paramTwo"]
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=extractWidgetConfig.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractWidgetConfig.test.js","names":["beforeEach","describe","expect","test","vi","extractWidgetConfig","validateWidgetConfigModule","MOCK_SERVER","ssrLoadModule","fn","restoreAllMocks","mocked","mockResolvedValue","default","MOCK_CONFIG","validateSpy","spyOn","result","toEqual","toHaveBeenCalledWith","id","name","type","parameters","mockImplementation","config","Error","rejects","toThrow","objectContaining","message","cause","notDefault","mockRejectedValue","description","paramOne","displayName","paramTwo","events","updateParameters","parameterUpdateIds"],"sources":["extractWidgetConfig.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ViteDevServer } from \"vite\";\nimport { beforeEach, describe, expect, test, vi } from \"vitest\";\nimport { extractWidgetConfig } from \"../extractWidgetConfig.js\";\nimport * as validateWidgetConfigModule from \"../validateWidgetConfig.js\";\n\nconst MOCK_SERVER = {\n ssrLoadModule: vi.fn(),\n} as unknown as ViteDevServer;\n\ndescribe(\"extractWidgetConfig\", () => {\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n test(\"extracts valid widget configuration\", async () => {\n vi.mocked(MOCK_SERVER.ssrLoadModule).mockResolvedValue({\n default: MOCK_CONFIG,\n });\n\n const validateSpy = vi.spyOn(\n validateWidgetConfigModule,\n \"validateWidgetConfig\",\n );\n\n const result = await extractWidgetConfig(\"/path/to/config.ts\", MOCK_SERVER);\n expect(result).toEqual(MOCK_CONFIG);\n expect(validateSpy).toHaveBeenCalledWith(MOCK_CONFIG);\n });\n\n test(\"throws for invalid widget configuration\", async () => {\n const INVALID_CONFIG = {\n id: \"Invalid-Id\",\n name: \"Test Widget\",\n type: \"workshop\",\n parameters: {},\n };\n\n vi.mocked(MOCK_SERVER.ssrLoadModule).mockResolvedValue({\n default: INVALID_CONFIG,\n });\n\n vi.spyOn(validateWidgetConfigModule, \"validateWidgetConfig\")\n .mockImplementation(config => {\n throw new Error(\n `Widget id \"${config.id}\" does not match allowed pattern (must be camelCase)`,\n );\n });\n\n await expect(extractWidgetConfig(\"/path/to/config.ts\", MOCK_SERVER))\n .rejects.toThrow(\n expect.objectContaining({\n message:\n \"Encountered error: 'Widget id \\\"Invalid-Id\\\" does not match allowed pattern (must be camelCase)' while loading widget config from /path/to/config.ts\",\n cause: expect.objectContaining({\n message:\n `Widget id \"Invalid-Id\" does not match allowed pattern (must be camelCase)`,\n }),\n }),\n );\n });\n\n test(\"throws for missing default export\", async () => {\n vi.mocked(MOCK_SERVER.ssrLoadModule).mockResolvedValue({\n notDefault: { id: \"test\" },\n });\n\n await expect(extractWidgetConfig(\"/path/to/config.ts\", MOCK_SERVER))\n .rejects.toThrow(\n expect.objectContaining({\n message:\n \"Encountered error: 'No default export found in /path/to/config.ts' while loading widget config from /path/to/config.ts\",\n cause: expect.objectContaining({\n message: \"No default export found in /path/to/config.ts\",\n }),\n }),\n );\n });\n\n test(\"throws for invalid module path\", async () => {\n vi.mocked(MOCK_SERVER.ssrLoadModule).mockRejectedValue(\n new Error(\"Module loading failed\"),\n );\n\n await expect(extractWidgetConfig(\"/invalid/path/config.ts\", MOCK_SERVER))\n .rejects.toThrow(\n \"Encountered error: 'Module loading failed' while loading widget config from /invalid/path/config.ts\",\n );\n });\n});\n\nconst MOCK_CONFIG = {\n id: \"testWidget\",\n name: \"Test Widget\",\n description: \"A test widget\",\n type: \"workshop\",\n parameters: {\n paramOne: {\n displayName: \"Parameter One\",\n type: \"string\",\n },\n paramTwo: {\n displayName: \"Parameter Two\",\n type: \"string\",\n },\n },\n events: {\n updateParameters: {\n displayName: \"Update Parameters\",\n parameterUpdateIds: [\"paramOne\", \"paramTwo\"],\n },\n },\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAQ,QAAQ;AAC/D,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,OAAO,KAAKC,0BAA0B,MAAM,4BAA4B;AAExE,MAAMC,WAAW,GAAG;EAClBC,aAAa,EAAEJ,EAAE,CAACK,EAAE,CAAC;AACvB,CAA6B;AAE7BR,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCD,UAAU,CAAC,MAAM;IACfI,EAAE,CAACM,eAAe,CAAC,CAAC;EACtB,CAAC,CAAC;EAEFP,IAAI,CAAC,qCAAqC,EAAE,YAAY;IACtDC,EAAE,CAACO,MAAM,CAACJ,WAAW,CAACC,aAAa,CAAC,CAACI,iBAAiB,CAAC;MACrDC,OAAO,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMC,WAAW,GAAGX,EAAE,CAACY,KAAK,CAC1BV,0BAA0B,EAC1B,sBACF,CAAC;IAED,MAAMW,MAAM,GAAG,MAAMZ,mBAAmB,CAAC,oBAAoB,EAAEE,WAAW,CAAC;IAC3EL,MAAM,CAACe,MAAM,CAAC,CAACC,OAAO,CAACJ,WAAW,CAAC;IACnCZ,MAAM,CAACa,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C,CACH,CAAC;EACL,CAAC,CAAC;EAEF3B,IAAI,CAAC,gCAAgC,EAAE,YAAY;IACjDC,EAAE,CAACO,MAAM,CAACJ,WAAW,CAACC,aAAa,CAAC,CAACyB,iBAAiB,CACpD,IAAIP,KAAK,CAAC,uBAAuB,CACnC,CAAC;IAED,MAAMxB,MAAM,CAACG,mBAAmB,CAAC,yBAAyB,EAAEE,WAAW,CAAC,CAAC,CACtEoB,OAAO,CAACC,OAAO,CACd,qGACF,CAAC;EACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAMd,WAAW,GAAG;EAClBM,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,aAAa;EACnBa,WAAW,EAAE,eAAe;EAC5BZ,IAAI,EAAE,UAAU;EAChBC,UAAU,EAAE;IACVY,QAAQ,EAAE;MACRC,WAAW,EAAE,eAAe;MAC5Bd,IAAI,EAAE;IACR,CAAC;IACDe,QAAQ,EAAE;MACRD,WAAW,EAAE,eAAe;MAC5Bd,IAAI,EAAE;IACR;EACF,CAAC;EACDgB,MAAM,EAAE;IACNC,gBAAgB,EAAE;MAChBH,WAAW,EAAE,mBAAmB;MAChCI,kBAAkB,EAAE,CAAC,UAAU,EAAE,UAAU;IAC7C;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { expect, test } from "vitest";
|
|
18
|
-
import { getInputHtmlEntrypoints } from "../getInputHtmlEntrypoints.js";
|
|
19
|
-
function mockOptions(input) {
|
|
20
|
-
return {
|
|
21
|
-
input
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
test("getInputHtmlEntrypoints with array input", () => {
|
|
25
|
-
const options = mockOptions(["one.html", "two.html", "three.html"]);
|
|
26
|
-
const result = getInputHtmlEntrypoints(options);
|
|
27
|
-
expect(result).toEqual(["one.html", "two.html", "three.html"]);
|
|
28
|
-
});
|
|
29
|
-
test("getInputHtmlEntrypoints with object input", () => {
|
|
30
|
-
const options = mockOptions({
|
|
31
|
-
main: "one.html",
|
|
32
|
-
unrelated: "two.html",
|
|
33
|
-
three: "three.html"
|
|
34
|
-
});
|
|
35
|
-
const result = getInputHtmlEntrypoints(options);
|
|
36
|
-
expect(result).toEqual(["one.html", "two.html", "three.html"]);
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=getInputHtmlEntrypoints.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getInputHtmlEntrypoints.test.js","names":["expect","test","getInputHtmlEntrypoints","mockOptions","input","options","result","toEqual","main","unrelated","three"],"sources":["getInputHtmlEntrypoints.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Rollup } from \"vite\";\nimport { expect, test } from \"vitest\";\nimport { getInputHtmlEntrypoints } from \"../getInputHtmlEntrypoints.js\";\n\nfunction mockOptions(\n input: Rollup.NormalizedInputOptions[\"input\"],\n) {\n return { input } as Rollup.NormalizedInputOptions;\n}\n\ntest(\"getInputHtmlEntrypoints with array input\", () => {\n const options = mockOptions([\"one.html\", \"two.html\", \"three.html\"]);\n const result = getInputHtmlEntrypoints(options);\n expect(result).toEqual([\"one.html\", \"two.html\", \"three.html\"]);\n});\n\ntest(\"getInputHtmlEntrypoints with object input\", () => {\n const options = mockOptions({\n main: \"one.html\",\n unrelated: \"two.html\",\n three: \"three.html\",\n });\n\n const result = getInputHtmlEntrypoints(options);\n expect(result).toEqual([\"one.html\", \"two.html\", \"three.html\"]);\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AACrC,SAASC,uBAAuB,QAAQ,+BAA+B;AAEvE,SAASC,WAAWA,CAClBC,KAA6C,EAC7C;EACA,OAAO;IAAEA;EAAM,CAAC;AAClB;AAEAH,IAAI,CAAC,0CAA0C,EAAE,MAAM;EACrD,MAAMI,OAAO,GAAGF,WAAW,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;EACnE,MAAMG,MAAM,GAAGJ,uBAAuB,CAACG,OAAO,CAAC;EAC/CL,MAAM,CAACM,MAAM,CAAC,CAACC,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAChE,CAAC,CAAC;AAEFN,IAAI,CAAC,2CAA2C,EAAE,MAAM;EACtD,MAAMI,OAAO,GAAGF,WAAW,CAAC;IAC1BK,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,UAAU;IACrBC,KAAK,EAAE;EACT,CAAC,CAAC;EAEF,MAAMJ,MAAM,GAAGJ,uBAAuB,CAACG,OAAO,CAAC;EAC/CL,MAAM,CAACM,MAAM,CAAC,CAACC,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAChE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { describe, expect, it } from "vitest";
|
|
18
|
-
import { standardizePathAndFileExtension } from "../standardizePathAndFileExtension.js";
|
|
19
|
-
describe("standardizePathAndFileExtension", () => {
|
|
20
|
-
describe("file extension standardization", () => {
|
|
21
|
-
it("should replace .ts extension with .js", () => {
|
|
22
|
-
expect(standardizePathAndFileExtension("/path/to/file.ts")).toBe("/path/to/file.js");
|
|
23
|
-
});
|
|
24
|
-
it("should replace .tsx extension with .js", () => {
|
|
25
|
-
expect(standardizePathAndFileExtension("/path/to/component.tsx")).toBe("/path/to/component.js");
|
|
26
|
-
});
|
|
27
|
-
it("should replace .jsx extension with .js", () => {
|
|
28
|
-
expect(standardizePathAndFileExtension("/path/to/component.jsx")).toBe("/path/to/component.js");
|
|
29
|
-
});
|
|
30
|
-
it("should keep .js extension as is", () => {
|
|
31
|
-
expect(standardizePathAndFileExtension("/path/to/file.js")).toBe("/path/to/file.js");
|
|
32
|
-
});
|
|
33
|
-
it("should append .js to config files", () => {
|
|
34
|
-
expect(standardizePathAndFileExtension("/path/to/widget.config")).toBe("/path/to/widget.config.js");
|
|
35
|
-
});
|
|
36
|
-
it("should handle files without extensions", () => {
|
|
37
|
-
expect(standardizePathAndFileExtension("/path/to/file")).toBe("/path/to/file");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe("path normalization", () => {
|
|
41
|
-
it("should normalize Windows paths with backslashes to forward slashes", () => {
|
|
42
|
-
expect(standardizePathAndFileExtension("C:\\Users\\project\\src\\file.ts")).toBe("C:/Users/project/src/file.js");
|
|
43
|
-
});
|
|
44
|
-
it("should normalize Windows paths with mixed separators", () => {
|
|
45
|
-
expect(standardizePathAndFileExtension("C:\\Users/project\\src/file.tsx")).toBe("C:/Users/project/src/file.js");
|
|
46
|
-
});
|
|
47
|
-
it("should preserve paths that already use forward slashes", () => {
|
|
48
|
-
expect(standardizePathAndFileExtension("/Users/project/src/file.ts")).toBe("/Users/project/src/file.js");
|
|
49
|
-
});
|
|
50
|
-
it("should handle Windows config file paths", () => {
|
|
51
|
-
expect(standardizePathAndFileExtension("D:\\workspace\\widgets\\my-widget.config")).toBe("D:/workspace/widgets/my-widget.config.js");
|
|
52
|
-
});
|
|
53
|
-
it("should handle Windows paths without file extensions", () => {
|
|
54
|
-
expect(standardizePathAndFileExtension("C:\\Users\\project\\README")).toBe("C:/Users/project/README");
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe("edge cases", () => {
|
|
58
|
-
it("should handle empty string", () => {
|
|
59
|
-
expect(standardizePathAndFileExtension("")).toBe("");
|
|
60
|
-
});
|
|
61
|
-
it("should handle paths with multiple dots", () => {
|
|
62
|
-
expect(standardizePathAndFileExtension("/path/to/file.test.ts")).toBe("/path/to/file.test.js");
|
|
63
|
-
});
|
|
64
|
-
it("should handle Windows paths with multiple dots", () => {
|
|
65
|
-
expect(standardizePathAndFileExtension("C:\\path\\to\\file.test.tsx")).toBe("C:/path/to/file.test.js");
|
|
66
|
-
});
|
|
67
|
-
it("should handle virtual paths with @fs prefix", () => {
|
|
68
|
-
expect(standardizePathAndFileExtension("/@fs/C:\\Users\\project\\src\\file.ts")).toBe("/@fs/C:/Users/project/src/file.js");
|
|
69
|
-
});
|
|
70
|
-
it("should handle paths with /src/ directory for Windows", () => {
|
|
71
|
-
const result = standardizePathAndFileExtension("C:\\projects\\my-app\\src\\components\\Widget.tsx");
|
|
72
|
-
expect(result).toBe("C:/projects/my-app/src/components/Widget.js");
|
|
73
|
-
expect(result.includes("/src/")).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=standardizePathAndFileExtension.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standardizePathAndFileExtension.test.js","names":["describe","expect","it","standardizePathAndFileExtension","toBe","result","includes"],"sources":["standardizePathAndFileExtension.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\nimport { standardizePathAndFileExtension } from \"../standardizePathAndFileExtension.js\";\n\ndescribe(\"standardizePathAndFileExtension\", () => {\n describe(\"file extension standardization\", () => {\n it(\"should replace .ts extension with .js\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/file.ts\")).toBe(\n \"/path/to/file.js\",\n );\n });\n\n it(\"should replace .tsx extension with .js\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/component.tsx\")).toBe(\n \"/path/to/component.js\",\n );\n });\n\n it(\"should replace .jsx extension with .js\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/component.jsx\")).toBe(\n \"/path/to/component.js\",\n );\n });\n\n it(\"should keep .js extension as is\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/file.js\")).toBe(\n \"/path/to/file.js\",\n );\n });\n\n it(\"should append .js to config files\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/widget.config\")).toBe(\n \"/path/to/widget.config.js\",\n );\n });\n\n it(\"should handle files without extensions\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/file\")).toBe(\n \"/path/to/file\",\n );\n });\n });\n\n describe(\"path normalization\", () => {\n it(\"should normalize Windows paths with backslashes to forward slashes\", () => {\n expect(\n standardizePathAndFileExtension(\"C:\\\\Users\\\\project\\\\src\\\\file.ts\"),\n ).toBe(\"C:/Users/project/src/file.js\");\n });\n\n it(\"should normalize Windows paths with mixed separators\", () => {\n expect(standardizePathAndFileExtension(\"C:\\\\Users/project\\\\src/file.tsx\"))\n .toBe(\"C:/Users/project/src/file.js\");\n });\n\n it(\"should preserve paths that already use forward slashes\", () => {\n expect(standardizePathAndFileExtension(\"/Users/project/src/file.ts\"))\n .toBe(\"/Users/project/src/file.js\");\n });\n\n it(\"should handle Windows config file paths\", () => {\n expect(\n standardizePathAndFileExtension(\n \"D:\\\\workspace\\\\widgets\\\\my-widget.config\",\n ),\n ).toBe(\"D:/workspace/widgets/my-widget.config.js\");\n });\n\n it(\"should handle Windows paths without file extensions\", () => {\n expect(standardizePathAndFileExtension(\"C:\\\\Users\\\\project\\\\README\"))\n .toBe(\"C:/Users/project/README\");\n });\n });\n\n describe(\"edge cases\", () => {\n it(\"should handle empty string\", () => {\n expect(standardizePathAndFileExtension(\"\")).toBe(\"\");\n });\n\n it(\"should handle paths with multiple dots\", () => {\n expect(standardizePathAndFileExtension(\"/path/to/file.test.ts\")).toBe(\n \"/path/to/file.test.js\",\n );\n });\n\n it(\"should handle Windows paths with multiple dots\", () => {\n expect(standardizePathAndFileExtension(\"C:\\\\path\\\\to\\\\file.test.tsx\"))\n .toBe(\"C:/path/to/file.test.js\");\n });\n\n it(\"should handle virtual paths with @fs prefix\", () => {\n expect(\n standardizePathAndFileExtension(\n \"/@fs/C:\\\\Users\\\\project\\\\src\\\\file.ts\",\n ),\n ).toBe(\"/@fs/C:/Users/project/src/file.js\");\n });\n\n it(\"should handle paths with /src/ directory for Windows\", () => {\n const windowsPath = \"C:\\\\projects\\\\my-app\\\\src\\\\components\\\\Widget.tsx\";\n const result = standardizePathAndFileExtension(windowsPath);\n expect(result).toBe(\"C:/projects/my-app/src/components/Widget.js\");\n expect(result.includes(\"/src/\")).toBe(true);\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,+BAA+B,QAAQ,uCAAuC;AAEvFH,QAAQ,CAAC,iCAAiC,EAAE,MAAM;EAChDA,QAAQ,CAAC,gCAAgC,EAAE,MAAM;IAC/CE,EAAE,CAAC,uCAAuC,EAAE,MAAM;MAChDD,MAAM,CAACE,+BAA+B,CAAC,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAC9D,kBACF,CAAC;IACH,CAAC,CAAC;IAEFF,EAAE,CAAC,wCAAwC,EAAE,MAAM;MACjDD,MAAM,CAACE,+BAA+B,CAAC,wBAAwB,CAAC,CAAC,CAACC,IAAI,CACpE,uBACF,CAAC;IACH,CAAC,CAAC;IAEFF,EAAE,CAAC,wCAAwC,EAAE,MAAM;MACjDD,MAAM,CAACE,+BAA+B,CAAC,wBAAwB,CAAC,CAAC,CAACC,IAAI,CACpE,uBACF,CAAC;IACH,CAAC,CAAC;IAEFF,EAAE,CAAC,iCAAiC,EAAE,MAAM;MAC1CD,MAAM,CAACE,+BAA+B,CAAC,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAC9D,kBACF,CAAC;IACH,CAAC,CAAC;IAEFF,EAAE,CAAC,mCAAmC,EAAE,MAAM;MAC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E,CAAC,wCAAwC,EAAE,MAAM;MACjDD,MAAM,CAACE,+BAA+B,CAAC,uBAAuB,CAAC,CAAC,CAACC,IAAI,CACnE,uBACF,CAAC;IACH,CAAC,CAAC;IAEFF,EAAE,CAAC,gDAAgD,EAAE,MAAM;MACzDD,MAAM,CAACE,+BAA+B,CAAC,6BAA6B,CAAC,CAAC,CACnEC,IAAI,CAAC,yBAAyB,CAAC;IACpC,CAAC,CAAC;IAEFF,EAAE,CAAC,6CAA6C,EAAE,MAAM;MACtDD,MAAM,CACJE,+BAA+B,CAC7B,uCACF,CACF,CAAC,CAACC,IAAI,CAAC,mCAAmC,CAAC;IAC7C,CAAC,CAAC;IAEFF,EAAE,CAAC,sDAAsD,EAAE,MAAM;MAE/D,MAAMG,MAAM,GAAGF,+BAA+B,CAD1B,mDACsC,CAAC;MAC3DF,MAAM,CAACI,MAAM,CAAC,CAACD,IAAI,CAAC,6CAA6C,CAAC;MAClEH,MAAM,CAACI,MAAM,CAACC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAACF,IAAI,CAAC,IAAI,CAAC;IAC7C,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { describe, expect, test } from "vitest";
|
|
18
|
-
import { validateWidgetConfig } from "../validateWidgetConfig.js";
|
|
19
|
-
describe("validateWidgetConfig", () => {
|
|
20
|
-
test("accepts valid widget configuration", () => {
|
|
21
|
-
const validConfig = getValidConfig();
|
|
22
|
-
expect(() => validateWidgetConfig(validConfig)).not.toThrow();
|
|
23
|
-
});
|
|
24
|
-
test("throws for widget id that exceeds max length", () => {
|
|
25
|
-
const invalidConfig = getValidConfig();
|
|
26
|
-
invalidConfig.id = "a".repeat(101);
|
|
27
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow("Widget id length can be at most 100 characters");
|
|
28
|
-
});
|
|
29
|
-
test("throws for widget id that is not camelCase", () => {
|
|
30
|
-
const testCases = [{
|
|
31
|
-
id: "TestWidget",
|
|
32
|
-
message: "does not match allowed pattern"
|
|
33
|
-
}, {
|
|
34
|
-
id: "test-widget",
|
|
35
|
-
message: "does not match allowed pattern"
|
|
36
|
-
}, {
|
|
37
|
-
id: "test_widget",
|
|
38
|
-
message: "does not match allowed pattern"
|
|
39
|
-
}, {
|
|
40
|
-
id: "1testWidget",
|
|
41
|
-
message: "does not match allowed pattern"
|
|
42
|
-
}];
|
|
43
|
-
for (const {
|
|
44
|
-
id,
|
|
45
|
-
message
|
|
46
|
-
} of testCases) {
|
|
47
|
-
const invalidConfig = getValidConfig();
|
|
48
|
-
invalidConfig.id = id;
|
|
49
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow(message);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
test("throws for widget name that exceeds max length", () => {
|
|
53
|
-
const invalidConfig = getValidConfig();
|
|
54
|
-
invalidConfig.name = "A".repeat(101);
|
|
55
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow("Widget name length can be at most 100 characters");
|
|
56
|
-
});
|
|
57
|
-
test("throws for widget description that exceeds max length", () => {
|
|
58
|
-
const invalidConfig = getValidConfig();
|
|
59
|
-
invalidConfig.description = "A".repeat(251);
|
|
60
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow("Widget description length can be at most 250 characters");
|
|
61
|
-
});
|
|
62
|
-
test("accepts undefined widget description", () => {
|
|
63
|
-
const validConfig = getValidConfig();
|
|
64
|
-
delete validConfig.description;
|
|
65
|
-
expect(() => validateWidgetConfig(validConfig)).not.toThrow();
|
|
66
|
-
});
|
|
67
|
-
test("throws for parameter id that is not camelCase", () => {
|
|
68
|
-
const invalidConfig = getValidConfig();
|
|
69
|
-
invalidConfig.parameters = {
|
|
70
|
-
"Invalid-Param": {
|
|
71
|
-
displayName: "Invalid Parameter",
|
|
72
|
-
type: "string"
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow("Parameter id \"Invalid-Param\" does not match allowed pattern (must be camelCase)");
|
|
76
|
-
});
|
|
77
|
-
test("throws for parameter id that exceeds max length", () => {
|
|
78
|
-
const invalidConfig = getValidConfig();
|
|
79
|
-
const longParamId = "param" + "a".repeat(96); // 101 chars total
|
|
80
|
-
invalidConfig.parameters = {
|
|
81
|
-
[longParamId]: {
|
|
82
|
-
displayName: "Long Parameter",
|
|
83
|
-
type: "string"
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow("Parameter id length can be at most 100 characters");
|
|
87
|
-
});
|
|
88
|
-
test("accepts valid object set parameter", () => {
|
|
89
|
-
const validConfig = getValidConfig();
|
|
90
|
-
validConfig.parameters.myObjectSet = {
|
|
91
|
-
type: "objectSet",
|
|
92
|
-
displayName: "My Object Set",
|
|
93
|
-
objectType: {
|
|
94
|
-
type: "object",
|
|
95
|
-
apiName: "employee",
|
|
96
|
-
internalDoNotUseMetadata: {
|
|
97
|
-
rid: "ri.object-type.employee"
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
expect(() => validateWidgetConfig(validConfig)).not.toThrow();
|
|
102
|
-
});
|
|
103
|
-
test("throws for invalid object set parameter", () => {
|
|
104
|
-
const invalidConfig = getValidConfig();
|
|
105
|
-
invalidConfig.parameters.myObjectSet = {
|
|
106
|
-
type: "objectSet",
|
|
107
|
-
displayName: "My Object Set",
|
|
108
|
-
objectType: {
|
|
109
|
-
type: "object",
|
|
110
|
-
apiName: "employee"
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
expect(() => validateWidgetConfig(invalidConfig)).toThrow("ObjectSet parameter \"myObjectSet\" must have a valid rid in its metadata, make sure your OSDK was generated with a generator version >=2.6.2");
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
function getValidConfig() {
|
|
117
|
-
return {
|
|
118
|
-
id: "testWidget",
|
|
119
|
-
name: "Test Widget",
|
|
120
|
-
description: "A test widget",
|
|
121
|
-
type: "workshop",
|
|
122
|
-
parameters: {
|
|
123
|
-
paramOne: {
|
|
124
|
-
displayName: "Parameter One",
|
|
125
|
-
type: "string"
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
events: {
|
|
129
|
-
updateParameters: {
|
|
130
|
-
displayName: "Update Parameters",
|
|
131
|
-
parameterUpdateIds: ["paramOne"]
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=validateWidgetConfig.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateWidgetConfig.test.js","names":["describe","expect","test","validateWidgetConfig","validConfig","getValidConfig","not","toThrow","invalidConfig","id","repeat","testCases","message","name","description","parameters","displayName","type","longParamId","myObjectSet","objectType","apiName","internalDoNotUseMetadata","rid","paramOne","events","updateParameters","parameterUpdateIds"],"sources":["validateWidgetConfig.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ParameterConfig, WidgetConfig } from \"@osdk/widget.api\";\nimport { describe, expect, test } from \"vitest\";\nimport { validateWidgetConfig } from \"../validateWidgetConfig.js\";\n\ndescribe(\"validateWidgetConfig\", () => {\n test(\"accepts valid widget configuration\", () => {\n const validConfig = getValidConfig();\n expect(() => validateWidgetConfig(validConfig)).not.toThrow();\n });\n\n test(\"throws for widget id that exceeds max length\", () => {\n const invalidConfig = getValidConfig();\n invalidConfig.id = \"a\".repeat(101);\n\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(\n \"Widget id length can be at most 100 characters\",\n );\n });\n\n test(\"throws for widget id that is not camelCase\", () => {\n const testCases = [\n { id: \"TestWidget\", message: \"does not match allowed pattern\" },\n { id: \"test-widget\", message: \"does not match allowed pattern\" },\n { id: \"test_widget\", message: \"does not match allowed pattern\" },\n { id: \"1testWidget\", message: \"does not match allowed pattern\" },\n ];\n\n for (const { id, message } of testCases) {\n const invalidConfig = getValidConfig();\n invalidConfig.id = id;\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(message);\n }\n });\n\n test(\"throws for widget name that exceeds max length\", () => {\n const invalidConfig = getValidConfig();\n invalidConfig.name = \"A\".repeat(101);\n\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(\n \"Widget name length can be at most 100 characters\",\n );\n });\n\n test(\"throws for widget description that exceeds max length\", () => {\n const invalidConfig = getValidConfig();\n invalidConfig.description = \"A\".repeat(251);\n\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(\n \"Widget description length can be at most 250 characters\",\n );\n });\n\n test(\"accepts undefined widget description\", () => {\n const validConfig = getValidConfig();\n delete validConfig.description;\n\n expect(() => validateWidgetConfig(validConfig)).not.toThrow();\n });\n\n test(\"throws for parameter id that is not camelCase\", () => {\n const invalidConfig = getValidConfig();\n invalidConfig.parameters = {\n \"Invalid-Param\": {\n displayName: \"Invalid Parameter\",\n type: \"string\",\n },\n };\n\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(\n \"Parameter id \\\"Invalid-Param\\\" does not match allowed pattern (must be camelCase)\",\n );\n });\n\n test(\"throws for parameter id that exceeds max length\", () => {\n const invalidConfig = getValidConfig();\n const longParamId = \"param\" + \"a\".repeat(96); // 101 chars total\n invalidConfig.parameters = {\n [longParamId]: {\n displayName: \"Long Parameter\",\n type: \"string\",\n },\n };\n\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(\n \"Parameter id length can be at most 100 characters\",\n );\n });\n\n test(\"accepts valid object set parameter\", () => {\n const validConfig = getValidConfig();\n validConfig.parameters.myObjectSet = {\n type: \"objectSet\",\n displayName: \"My Object Set\",\n objectType: {\n type: \"object\",\n apiName: \"employee\",\n internalDoNotUseMetadata: {\n rid: \"ri.object-type.employee\",\n },\n },\n };\n expect(() => validateWidgetConfig(validConfig)).not.toThrow();\n });\n\n test(\"throws for invalid object set parameter\", () => {\n const invalidConfig = getValidConfig();\n invalidConfig.parameters.myObjectSet = {\n type: \"objectSet\",\n displayName: \"My Object Set\",\n objectType: {\n type: \"object\",\n apiName: \"employee\",\n },\n };\n expect(() => validateWidgetConfig(invalidConfig)).toThrow(\n \"ObjectSet parameter \\\"myObjectSet\\\" must have a valid rid in its metadata, make sure your OSDK was generated with a generator version >=2.6.2\",\n );\n });\n});\n\nfunction getValidConfig(): WidgetConfig<ParameterConfig> {\n return {\n id: \"testWidget\",\n name: \"Test Widget\",\n description: \"A test widget\",\n type: \"workshop\",\n parameters: {\n paramOne: {\n displayName: \"Parameter One\",\n type: \"string\",\n },\n },\n events: {\n updateParameters: {\n displayName: \"Update Parameters\",\n parameterUpdateIds: [\"paramOne\"],\n },\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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