@osdk/generator 2.8.0-beta.3 → 2.8.0-beta.30

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.
Files changed (115) hide show
  1. package/CHANGELOG.md +234 -0
  2. package/build/browser/GenerateContext/EnhancedAction.js +13 -0
  3. package/build/browser/GenerateContext/EnhancedAction.js.map +1 -1
  4. package/build/browser/GenerateContext/GenerateContext.js.map +1 -1
  5. package/build/browser/generateClientSdkPackage.js +1 -1
  6. package/build/browser/generateClientSdkPackage.js.map +1 -1
  7. package/build/browser/index.js +1 -1
  8. package/build/browser/index.js.map +1 -1
  9. package/build/browser/shared/getInterfaceTypesFromQueryDataType.js +3 -0
  10. package/build/browser/shared/getInterfaceTypesFromQueryDataType.js.map +1 -1
  11. package/build/browser/shared/getObjectTypesFromQueryDataType.js +3 -0
  12. package/build/browser/shared/getObjectTypesFromQueryDataType.js.map +1 -1
  13. package/build/browser/util/test/TodoWireOntology.js +20 -10
  14. package/build/browser/util/test/TodoWireOntology.js.map +1 -1
  15. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +3 -2
  16. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  17. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +1 -4
  18. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
  19. package/build/browser/v2.0/generatePerActionDataFiles.js +2 -6
  20. package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
  21. package/build/browser/v2.0/generatePerQueryDataFiles.js +10 -3
  22. package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
  23. package/build/browser/v2.0/getDescriptionIfPresent.js +4 -1
  24. package/build/browser/v2.0/getDescriptionIfPresent.js.map +1 -1
  25. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +5 -1
  26. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  27. package/build/cjs/index.cjs +44 -80
  28. package/build/cjs/index.cjs.map +1 -1
  29. package/build/cjs/index.d.cts +12 -1
  30. package/build/esm/GenerateContext/EnhancedAction.js +13 -0
  31. package/build/esm/GenerateContext/EnhancedAction.js.map +1 -1
  32. package/build/esm/GenerateContext/GenerateContext.js.map +1 -1
  33. package/build/esm/generateClientSdkPackage.js +1 -1
  34. package/build/esm/generateClientSdkPackage.js.map +1 -1
  35. package/build/esm/index.js +1 -1
  36. package/build/esm/index.js.map +1 -1
  37. package/build/esm/shared/getInterfaceTypesFromQueryDataType.js +3 -0
  38. package/build/esm/shared/getInterfaceTypesFromQueryDataType.js.map +1 -1
  39. package/build/esm/shared/getObjectTypesFromQueryDataType.js +3 -0
  40. package/build/esm/shared/getObjectTypesFromQueryDataType.js.map +1 -1
  41. package/build/esm/util/test/TodoWireOntology.js +20 -10
  42. package/build/esm/util/test/TodoWireOntology.js.map +1 -1
  43. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +3 -2
  44. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  45. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +1 -4
  46. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
  47. package/build/esm/v2.0/generatePerActionDataFiles.js +2 -6
  48. package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
  49. package/build/esm/v2.0/generatePerQueryDataFiles.js +10 -3
  50. package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
  51. package/build/esm/v2.0/getDescriptionIfPresent.js +4 -1
  52. package/build/esm/v2.0/getDescriptionIfPresent.js.map +1 -1
  53. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +5 -1
  54. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  55. package/build/types/GenerateContext/EnhancedAction.d.ts +2 -0
  56. package/build/types/GenerateContext/EnhancedAction.d.ts.map +1 -1
  57. package/build/types/GenerateContext/GenerateContext.d.ts +0 -2
  58. package/build/types/GenerateContext/GenerateContext.d.ts.map +1 -1
  59. package/build/types/generateClientSdkPackage.d.ts +11 -0
  60. package/build/types/generateClientSdkPackage.d.ts.map +1 -1
  61. package/build/types/index.d.ts +1 -1
  62. package/build/types/index.d.ts.map +1 -1
  63. package/build/types/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  64. package/build/types/v2.0/generatePerActionDataFiles.d.ts +1 -1
  65. package/build/types/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
  66. package/build/types/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
  67. package/package.json +6 -6
  68. package/build/browser/generateClientSdkPackage.test.js +0 -68
  69. package/build/browser/generateClientSdkPackage.test.js.map +0 -1
  70. package/build/browser/shared/apiNamespaces/startsWithApiNamespace.test.js +0 -47
  71. package/build/browser/shared/apiNamespaces/startsWithApiNamespace.test.js.map +0 -1
  72. package/build/browser/shared/sanitizeMetadata.js +0 -42
  73. package/build/browser/shared/sanitizeMetadata.js.map +0 -1
  74. package/build/browser/shared/sanitizeMetadata.test.js +0 -46
  75. package/build/browser/shared/sanitizeMetadata.test.js.map +0 -1
  76. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +0 -472
  77. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +0 -1
  78. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +0 -2603
  79. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +0 -1
  80. package/build/browser/v2.0/generatePerActionDataFiles.test.js +0 -64
  81. package/build/browser/v2.0/generatePerActionDataFiles.test.js.map +0 -1
  82. package/build/browser/v2.0/generatePerQueryDataFiles.test.js +0 -519
  83. package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +0 -1
  84. package/build/esm/generateClientSdkPackage.test.js +0 -68
  85. package/build/esm/generateClientSdkPackage.test.js.map +0 -1
  86. package/build/esm/shared/apiNamespaces/startsWithApiNamespace.test.js +0 -47
  87. package/build/esm/shared/apiNamespaces/startsWithApiNamespace.test.js.map +0 -1
  88. package/build/esm/shared/sanitizeMetadata.js +0 -42
  89. package/build/esm/shared/sanitizeMetadata.js.map +0 -1
  90. package/build/esm/shared/sanitizeMetadata.test.js +0 -46
  91. package/build/esm/shared/sanitizeMetadata.test.js.map +0 -1
  92. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +0 -472
  93. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +0 -1
  94. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +0 -2603
  95. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +0 -1
  96. package/build/esm/v2.0/generatePerActionDataFiles.test.js +0 -64
  97. package/build/esm/v2.0/generatePerActionDataFiles.test.js.map +0 -1
  98. package/build/esm/v2.0/generatePerQueryDataFiles.test.js +0 -519
  99. package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +0 -1
  100. package/build/types/generateClientSdkPackage.test.d.ts +0 -1
  101. package/build/types/generateClientSdkPackage.test.d.ts.map +0 -1
  102. package/build/types/shared/apiNamespaces/startsWithApiNamespace.test.d.ts +0 -1
  103. package/build/types/shared/apiNamespaces/startsWithApiNamespace.test.d.ts.map +0 -1
  104. package/build/types/shared/sanitizeMetadata.d.ts +0 -1
  105. package/build/types/shared/sanitizeMetadata.d.ts.map +0 -1
  106. package/build/types/shared/sanitizeMetadata.test.d.ts +0 -1
  107. package/build/types/shared/sanitizeMetadata.test.d.ts.map +0 -1
  108. package/build/types/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +0 -1
  109. package/build/types/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +0 -1
  110. package/build/types/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts +0 -1
  111. package/build/types/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts.map +0 -1
  112. package/build/types/v2.0/generatePerActionDataFiles.test.d.ts +0 -1
  113. package/build/types/v2.0/generatePerActionDataFiles.test.d.ts.map +0 -1
  114. package/build/types/v2.0/generatePerQueryDataFiles.test.d.ts +0 -1
  115. package/build/types/v2.0/generatePerQueryDataFiles.test.d.ts.map +0 -1
@@ -1,47 +0,0 @@
1
- /*
2
- * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import { describe, expect, it } from "vitest";
18
- import { startsWithApiNamespace } from "./startsWithApiNamespace.js";
19
- describe(startsWithApiNamespace, () => {
20
- describe("a name with periods", () => {
21
- const partialNamespace = "a.b";
22
- const fullNamespace = `${partialNamespace}.c`;
23
- const fullApiName = `${fullNamespace}.${"Foo"}`;
24
- it("returns false if only partial namespace is provided", () => {
25
- expect(startsWithApiNamespace(fullApiName, partialNamespace)).toBe(false);
26
- });
27
- it("returns true if full namespace is provided", () => {
28
- expect(startsWithApiNamespace(fullApiName, fullNamespace)).toBe(true);
29
- });
30
- it("returns false if a wrong namespace is provided", () => {
31
- expect(startsWithApiNamespace(fullApiName, "incorrect.namespace")).toBe(false);
32
- });
33
- it("return false if no namespace is provided", () => {
34
- expect(startsWithApiNamespace(fullApiName, undefined)).toBe(false);
35
- });
36
- });
37
- describe("a name without periods", () => {
38
- const apiNameOnly = "Foo";
39
- it("returns false if any namespace is provided", () => {
40
- expect(startsWithApiNamespace(apiNameOnly, "incorrect.namespace")).toBe(false);
41
- });
42
- it("returns true if no namespace is provided", () => {
43
- expect(startsWithApiNamespace(apiNameOnly, undefined)).toBe(true);
44
- });
45
- });
46
- });
47
- //# sourceMappingURL=startsWithApiNamespace.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startsWithApiNamespace.test.js","names":["describe","expect","it","startsWithApiNamespace","partialNamespace","fullNamespace","fullApiName","toBe","undefined","apiNameOnly"],"sources":["startsWithApiNamespace.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\nimport { startsWithApiNamespace } from \"./startsWithApiNamespace.js\";\n\ndescribe(startsWithApiNamespace, () => {\n describe(\"a name with periods\", () => {\n const wrongNamespace = \"incorrect.namespace\";\n const partialNamespace = \"a.b\";\n const fullNamespace = `${partialNamespace}.c`;\n const apiNameOnly = \"Foo\";\n const fullApiName = `${fullNamespace}.${apiNameOnly}`;\n\n it(\"returns false if only partial namespace is provided\", () => {\n expect(startsWithApiNamespace(fullApiName, partialNamespace)).toBe(\n false,\n );\n });\n\n it(\"returns true if full namespace is provided\", () => {\n expect(startsWithApiNamespace(fullApiName, fullNamespace)).toBe(true);\n });\n\n it(\"returns false if a wrong namespace is provided\", () => {\n expect(startsWithApiNamespace(fullApiName, wrongNamespace)).toBe(false);\n });\n\n it(\"return false if no namespace is provided\", () => {\n expect(startsWithApiNamespace(fullApiName, undefined)).toBe(false);\n });\n });\n\n describe(\"a name without periods\", () => {\n const wrongNamespace = \"incorrect.namespace\";\n const apiNameOnly = \"Foo\";\n\n it(\"returns false if any namespace is provided\", () => {\n expect(startsWithApiNamespace(apiNameOnly, wrongNamespace)).toBe(\n false,\n );\n });\n\n it(\"returns true if no namespace is provided\", () => {\n expect(startsWithApiNamespace(apiNameOnly, undefined)).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,sBAAsB,QAAQ,6BAA6B;AAEpEH,QAAQ,CAACG,sBAAsB,EAAE,MAAM;EACrCH,QAAQ,CAAC,qBAAqB,EAAE,MAAM;IAEpC,MAAMI,gBAAgB,GAAG,KAAK;IAC9B,MAAMC,aAAa,GAAG,GAAGD,gBAAgB,IAAI;IAE7C,MAAME,WAAW,GAAG,GAAGD,aAAa,IADhB,KAAK,EAC4B;IAErDH,EAAE,CAAC,qDAAqD,EAAE,MAAM;MAC9DD,MAAM,CAACE,sBAAsB,CAACG,WAAW,EAAEF,gBAAgB,CAAC,CAAC,CAACG,IAAI,CAChE,KACF,CAAC;IACH,CAAC,CAAC;IAEFL,EAAE,CAAC,4CAA4C,EAAE,MAAM;MACrDD,MAAM,CAACE,sBAAsB,CAACG,WAAW,EAAED,aAAa,CAAC,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;IACvE,CAAC,CAAC;IAEFL,EAAE,CAAC,gDAAgD,EAAE,MAAM;MACzDD,MAAM,CAACE,sBAAsB,CAACG,WAAW,EAjBpB,qBAiBoC,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,CAAC;IACzE,CAAC,CAAC;IAEFL,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACnDD,MAAM,CAACE,sBAAsB,CAACG,WAAW,EAAEE,SAAS,CAAC,CAAC,CAACD,IAAI,CAAC,KAAK,CAAC;IACpE,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFP,QAAQ,CAAC,wBAAwB,EAAE,MAAM;IAEvC,MAAMS,WAAW,GAAG,KAAK;IAEzBP,EAAE,CAAC,4CAA4C,EAAE,MAAM;MACrDD,MAAM,CAACE,sBAAsB,CAACM,WAAW,EAJpB,qBAIoC,CAAC,CAAC,CAACF,IAAI,CAC9D,KACF,CAAC;IACH,CAAC,CAAC;IAEFL,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACnDD,MAAM,CAACE,sBAAsB,CAACM,WAAW,EAAED,SAAS,CAAC,CAAC,CAACD,IAAI,CAAC,IAAI,CAAC;IACnE,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,42 +0,0 @@
1
- /*
2
- * Copyright 2023 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
- /**
18
- * @internal
19
- */
20
-
21
- /**
22
- * @internal
23
- */
24
-
25
- /**
26
- * @internal
27
- */
28
- export function sanitizeMetadata(ontology) {
29
- return {
30
- ...ontology,
31
- actionTypes: Object.fromEntries(Object.values(ontology.actionTypes).map(actionType => {
32
- return [camelize(actionType.apiName), {
33
- ...actionType,
34
- apiName: camelize(actionType.apiName)
35
- }];
36
- }))
37
- };
38
- }
39
- function camelize(name) {
40
- return name.replace(/-./g, segment => segment[1].toUpperCase());
41
- }
42
- //# sourceMappingURL=sanitizeMetadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizeMetadata.js","names":["sanitizeMetadata","ontology","actionTypes","Object","fromEntries","values","map","actionType","camelize","apiName","name","replace","segment","toUpperCase"],"sources":["sanitizeMetadata.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { WireOntologyDefinition } from \"../WireOntologyDefinition.js\";\n\n/**\n * @internal\n */\nexport function sanitizeMetadata(\n ontology: WireOntologyDefinition,\n): WireOntologyDefinition;\n/**\n * @internal\n */\nexport function sanitizeMetadata(\n ontology: WireOntologyDefinition,\n): WireOntologyDefinition;\n/**\n * @internal\n */\nexport function sanitizeMetadata<\n T extends WireOntologyDefinition | WireOntologyDefinition,\n>(\n ontology: T,\n): T {\n return {\n ...ontology,\n actionTypes: Object.fromEntries(\n Object.values(ontology.actionTypes).map(actionType => {\n return [camelize(actionType.apiName), {\n ...actionType,\n apiName: camelize(actionType.apiName),\n }];\n }),\n ),\n };\n}\nfunction camelize(name: string) {\n return name.replace(/-./g, segment => segment[1]!.toUpperCase());\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAG9BC,QAAW,EACR;EACH,OAAO;IACL,GAAGA,QAAQ;IACXC,WAAW,EAAEC,MAAM,CAACC,WAAW,CAC7BD,MAAM,CAACE,MAAM,CAACJ,QAAQ,CAACC,WAAW,CAAC,CAACI,GAAG,CAACC,UAAU,IAAI;MACpD,OAAO,CAACC,QAAQ,CAACD,UAAU,CAACE,OAAO,CAAC,EAAE;QACpC,GAAGF,UAAU;QACbE,OAAO,EAAED,QAAQ,CAACD,UAAU,CAACE,OAAO;MACtC,CAAC,CAAC;IACJ,CAAC,CACH;EACF,CAAC;AACH;AACA,SAASD,QAAQA,CAACE,IAAY,EAAE;EAC9B,OAAOA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAEC,OAAO,IAAIA,OAAO,CAAC,CAAC,CAAC,CAAEC,WAAW,CAAC,CAAC,CAAC;AAClE","ignoreList":[]}
@@ -1,46 +0,0 @@
1
- /*
2
- * Copyright 2023 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 { sanitizeMetadata } from "./sanitizeMetadata.js";
19
- describe(sanitizeMetadata, () => {
20
- it("sanitized action apiNames", () => {
21
- const sanitizedOntology = sanitizeMetadata({
22
- objectTypes: {},
23
- actionTypes: {
24
- "kebab-case": {
25
- apiName: "kebab-case",
26
- operations: [],
27
- parameters: {},
28
- status: "ACTIVE",
29
- rid: "ri.a.b.c.d"
30
- }
31
- },
32
- ontology: {
33
- rid: "ri.a.b.c.d",
34
- apiName: "ontology",
35
- displayName: "",
36
- description: ""
37
- },
38
- queryTypes: {},
39
- interfaceTypes: {},
40
- sharedPropertyTypes: {},
41
- valueTypes: {}
42
- });
43
- expect(sanitizedOntology.actionTypes["kebabCase"].apiName).toEqual("kebabCase");
44
- });
45
- });
46
- //# sourceMappingURL=sanitizeMetadata.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizeMetadata.test.js","names":["describe","expect","it","sanitizeMetadata","sanitizedOntology","objectTypes","actionTypes","apiName","operations","parameters","status","rid","ontology","displayName","description","queryTypes","interfaceTypes","sharedPropertyTypes","valueTypes","toEqual"],"sources":["sanitizeMetadata.test.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { sanitizeMetadata } from \"./sanitizeMetadata.js\";\n\ndescribe(sanitizeMetadata, () => {\n it(\"sanitized action apiNames\", () => {\n const sanitizedOntology = sanitizeMetadata({\n objectTypes: {},\n actionTypes: {\n \"kebab-case\": {\n apiName: \"kebab-case\",\n operations: [],\n parameters: {},\n status: \"ACTIVE\",\n rid: \"ri.a.b.c.d\",\n },\n },\n ontology: {\n rid: \"ri.a.b.c.d\",\n apiName: \"ontology\",\n displayName: \"\",\n description: \"\",\n },\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {},\n valueTypes: {},\n });\n expect(sanitizedOntology.actionTypes[\"kebabCase\"].apiName).toEqual(\n \"kebabCase\",\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,gBAAgB,QAAQ,uBAAuB;AAExDH,QAAQ,CAACG,gBAAgB,EAAE,MAAM;EAC/BD,EAAE,CAAC,2BAA2B,EAAE,MAAM;IACpC,MAAME,iBAAiB,GAAGD,gBAAgB,CAAC;MACzCE,WAAW,EAAE,CAAC,CAAC;MACfC,WAAW,EAAE;QACX,YAAY,EAAE;UACZC,OAAO,EAAE,YAAY;UACrBC,UAAU,EAAE,EAAE;UACdC,UAAU,EAAE,CAAC,CAAC;UACdC,MAAM,EAAE,QAAQ;UAChBC,GAAG,EAAE;QACP;MACF,CAAC;MACDC,QAAQ,EAAE;QACRD,GAAG,EAAE,YAAY;QACjBJ,OAAO,EAAE,UAAU;QACnBM,WAAW,EAAE,EAAE;QACfC,WAAW,EAAE;MACf,CAAC;MACDC,UAAU,EAAE,CAAC,CAAC;MACdC,cAAc,EAAE,CAAC,CAAC;MAClBC,mBAAmB,EAAE,CAAC,CAAC;MACvBC,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;IACFjB,MAAM,CAACG,iBAAiB,CAACE,WAAW,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,CAACY,OAAO,CAChE,WACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,472 +0,0 @@
1
- /*
2
- * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from "@osdk/generator-converters";
18
- import { format } from "prettier";
19
- import { describe, expect, it } from "vitest";
20
- import { EnhancedInterfaceType } from "../GenerateContext/EnhancedInterfaceType.js";
21
- import { enhanceOntology } from "../GenerateContext/enhanceOntology.js";
22
- import { ForeignType } from "../GenerateContext/ForeignType.js";
23
- import { deleteUndefineds } from "../util/deleteUndefineds.js";
24
- import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, getInvalidInterfaceProperties } from "./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js";
25
- function simpleSpt(apiName, metadataLevel = 2) {
26
- return {
27
- apiName,
28
- dataType: {
29
- type: "integer"
30
- },
31
- rid: `${apiName}Rid`,
32
- displayName: metadataLevel >= 1 ? `${apiName} property dn` : apiName,
33
- description: metadataLevel >= 2 ? `${apiName} property desc` : undefined
34
- };
35
- }
36
- function simpleInterface(apiName, spts, parents, metadataLevel = 2, implementedByObjectTypes = []) {
37
- const properties = Object.fromEntries(spts.map(spt => [spt.apiName, {
38
- ...spt,
39
- required: true
40
- }]));
41
- return {
42
- apiName,
43
- rid: `${apiName}Rid`,
44
- displayName: metadataLevel >= 1 ? `${apiName} interface dn` : apiName,
45
- description: metadataLevel >= 2 ? `${apiName} interface desc` : undefined,
46
- extendsInterfaces: parents,
47
- links: {},
48
- properties,
49
- propertiesV2: {},
50
- implementedByObjectTypes,
51
- allExtendsInterfaces: parents,
52
- allLinks: {},
53
- allProperties: properties,
54
- allPropertiesV2: {}
55
- };
56
- }
57
- function simpleOntology(apiName, interfaces) {
58
- const interfaceTypes = Object.fromEntries(interfaces.map(i => [i.apiName, i]));
59
- const sharedPropertyTypes = Object.fromEntries(interfaces.flatMap(i => Object.entries(i.properties)));
60
- return {
61
- actionTypes: {},
62
- interfaceTypes,
63
- objectTypes: {},
64
- ontology: {
65
- apiName,
66
- description: `${apiName} ontology desc`,
67
- displayName: `${apiName} ontology dn`,
68
- rid: `${apiName} ontology rid`
69
- },
70
- queryTypes: {},
71
- sharedPropertyTypes,
72
- valueTypes: {}
73
- };
74
- }
75
- describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
76
- it("Does not say (inherited) on properties locally defined", async () => {
77
- const ontology = enhanceOntology({
78
- sanitized: simpleOntology("ontology", [simpleInterface("Bar", [simpleSpt("bar", 0)], [], 0)]),
79
- importExt: ""
80
- });
81
- expect(ontology.interfaceTypes.Bar instanceof EnhancedInterfaceType).toBe(true);
82
-
83
- // type guard for below
84
- if (ontology.interfaceTypes.Bar instanceof ForeignType) {
85
- throw new Error("Expected Bar to be an EnhancedInterfaceType");
86
- }
87
- const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Bar, ontology, true, true), {
88
- parser: "typescript",
89
- printWidth: 100
90
- });
91
- expect(formattedCode).toMatchInlineSnapshot(`
92
- "import type {
93
- InterfaceDefinition as $InterfaceDefinition,
94
- InterfaceMetadata as $InterfaceMetadata,
95
- ObjectSet as $ObjectSet,
96
- Osdk as $Osdk,
97
- PropertyValueWireToClient as $PropType,
98
- } from "@osdk/api";
99
-
100
- export type OsdkObjectLinks$Bar = {};
101
-
102
- export namespace Bar {
103
- export type PropertyKeys = "bar";
104
-
105
- export interface Props {
106
- /**
107
- * (no ontology metadata)
108
- */
109
- readonly bar: $PropType["integer"] | undefined;
110
- }
111
- export type StrictProps = Props;
112
-
113
- export interface ObjectSet extends $ObjectSet<Bar, Bar.ObjectSet> {}
114
-
115
- export type OsdkInstance<
116
- OPTIONS extends never | "$rid" = never,
117
- K extends keyof Bar.Props = keyof Bar.Props,
118
- > = $Osdk.Instance<Bar, OPTIONS, K>;
119
-
120
- /** @deprecated use OsdkInstance */
121
- export type OsdkObject<
122
- OPTIONS extends never | "$rid" = never,
123
- K extends keyof Bar.Props = keyof Bar.Props,
124
- > = OsdkInstance<OPTIONS, K>;
125
- }
126
-
127
- export interface Bar extends $InterfaceDefinition {
128
- osdkMetadata: typeof $osdkMetadata;
129
- type: "interface";
130
- apiName: "Bar";
131
- __DefinitionMetadata?: {
132
- objectSet: Bar.ObjectSet;
133
- props: Bar.Props;
134
- linksType: OsdkObjectLinks$Bar;
135
- strictProps: Bar.StrictProps;
136
- apiName: "Bar";
137
- description: undefined;
138
- displayName: "Bar";
139
- implementedBy: [];
140
- implements: [];
141
- links: {};
142
- properties: {
143
- /**
144
- * (no ontology metadata)
145
- */
146
- bar: $PropertyDef<"integer", "nullable", "single">;
147
- };
148
- rid: "BarRid";
149
- type: "interface";
150
- };
151
- }
152
-
153
- export const Bar = {
154
- type: "interface",
155
- apiName: "Bar",
156
- osdkMetadata: $osdkMetadata,
157
- internalDoNotUseMetadata: {
158
- rid: "BarRid",
159
- },
160
- } satisfies Bar & { internalDoNotUseMetadata: { rid: string } } as Bar;
161
- "
162
- `);
163
- });
164
- it("Generates properties for inherited SPTs", async () => {
165
- const fooSpt = simpleSpt("foo");
166
- const barSpt = simpleSpt("bar");
167
- const ontology = enhanceOntology({
168
- sanitized: simpleOntology("ontology", [simpleInterface("Foo", [fooSpt], ["Parent"]), simpleInterface("Parent", [barSpt], [])]),
169
- importExt: ""
170
- });
171
- const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true, true), {
172
- parser: "typescript"
173
- });
174
- expect(formattedCode).toMatchInlineSnapshot(`
175
- "import type {
176
- InterfaceDefinition as $InterfaceDefinition,
177
- InterfaceMetadata as $InterfaceMetadata,
178
- ObjectSet as $ObjectSet,
179
- Osdk as $Osdk,
180
- PropertyValueWireToClient as $PropType,
181
- } from "@osdk/api";
182
-
183
- export type OsdkObjectLinks$Foo = {};
184
-
185
- export namespace Foo {
186
- export type PropertyKeys = "foo";
187
-
188
- export interface Props {
189
- /**
190
- * display name: 'foo property dn',
191
- *
192
- * description: foo property desc
193
- */
194
- readonly foo: $PropType["integer"] | undefined;
195
- }
196
- export type StrictProps = Props;
197
-
198
- export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}
199
-
200
- export type OsdkInstance<
201
- OPTIONS extends never | "$rid" = never,
202
- K extends keyof Foo.Props = keyof Foo.Props,
203
- > = $Osdk.Instance<Foo, OPTIONS, K>;
204
-
205
- /** @deprecated use OsdkInstance */
206
- export type OsdkObject<
207
- OPTIONS extends never | "$rid" = never,
208
- K extends keyof Foo.Props = keyof Foo.Props,
209
- > = OsdkInstance<OPTIONS, K>;
210
- }
211
-
212
- export interface Foo extends $InterfaceDefinition {
213
- osdkMetadata: typeof $osdkMetadata;
214
- type: "interface";
215
- apiName: "Foo";
216
- __DefinitionMetadata?: {
217
- objectSet: Foo.ObjectSet;
218
- props: Foo.Props;
219
- linksType: OsdkObjectLinks$Foo;
220
- strictProps: Foo.StrictProps;
221
- apiName: "Foo";
222
- description: "Foo interface desc";
223
- displayName: "Foo interface dn";
224
- implementedBy: [];
225
- implements: ["Parent"];
226
- links: {};
227
- properties: {
228
- /**
229
- * display name: 'foo property dn',
230
- *
231
- * description: foo property desc
232
- */
233
- foo: $PropertyDef<"integer", "nullable", "single">;
234
- };
235
- rid: "FooRid";
236
- type: "interface";
237
- };
238
- }
239
-
240
- export const Foo = {
241
- type: "interface",
242
- apiName: "Foo",
243
- osdkMetadata: $osdkMetadata,
244
- internalDoNotUseMetadata: {
245
- rid: "FooRid",
246
- },
247
- } satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;
248
- "
249
- `);
250
- });
251
- it("allows for SPT reuse if the same", async () => {
252
- const fooSpt = simpleSpt("foo");
253
- const barSpt = simpleSpt("bar");
254
- const ontology = enhanceOntology({
255
- sanitized: simpleOntology("ontology", [simpleInterface("Foo", [fooSpt, barSpt], ["Parent"]), simpleInterface("Parent", [barSpt], [])]),
256
- importExt: ""
257
- });
258
- const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true, true), {
259
- parser: "typescript"
260
- });
261
- expect(formattedCode).toMatchInlineSnapshot(`
262
- "import type {
263
- InterfaceDefinition as $InterfaceDefinition,
264
- InterfaceMetadata as $InterfaceMetadata,
265
- ObjectSet as $ObjectSet,
266
- Osdk as $Osdk,
267
- PropertyValueWireToClient as $PropType,
268
- } from "@osdk/api";
269
-
270
- export type OsdkObjectLinks$Foo = {};
271
-
272
- export namespace Foo {
273
- export type PropertyKeys = "foo" | "bar";
274
-
275
- export interface Props {
276
- /**
277
- * display name: 'bar property dn',
278
- *
279
- * description: bar property desc
280
- */
281
- readonly bar: $PropType["integer"] | undefined;
282
- /**
283
- * display name: 'foo property dn',
284
- *
285
- * description: foo property desc
286
- */
287
- readonly foo: $PropType["integer"] | undefined;
288
- }
289
- export type StrictProps = Props;
290
-
291
- export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}
292
-
293
- export type OsdkInstance<
294
- OPTIONS extends never | "$rid" = never,
295
- K extends keyof Foo.Props = keyof Foo.Props,
296
- > = $Osdk.Instance<Foo, OPTIONS, K>;
297
-
298
- /** @deprecated use OsdkInstance */
299
- export type OsdkObject<
300
- OPTIONS extends never | "$rid" = never,
301
- K extends keyof Foo.Props = keyof Foo.Props,
302
- > = OsdkInstance<OPTIONS, K>;
303
- }
304
-
305
- export interface Foo extends $InterfaceDefinition {
306
- osdkMetadata: typeof $osdkMetadata;
307
- type: "interface";
308
- apiName: "Foo";
309
- __DefinitionMetadata?: {
310
- objectSet: Foo.ObjectSet;
311
- props: Foo.Props;
312
- linksType: OsdkObjectLinks$Foo;
313
- strictProps: Foo.StrictProps;
314
- apiName: "Foo";
315
- description: "Foo interface desc";
316
- displayName: "Foo interface dn";
317
- implementedBy: [];
318
- implements: ["Parent"];
319
- links: {};
320
- properties: {
321
- /**
322
- * display name: 'bar property dn',
323
- *
324
- * description: bar property desc
325
- */
326
- bar: $PropertyDef<"integer", "nullable", "single">;
327
- /**
328
- * display name: 'foo property dn',
329
- *
330
- * description: foo property desc
331
- */
332
- foo: $PropertyDef<"integer", "nullable", "single">;
333
- };
334
- rid: "FooRid";
335
- type: "interface";
336
- };
337
- }
338
-
339
- export const Foo = {
340
- type: "interface",
341
- apiName: "Foo",
342
- osdkMetadata: $osdkMetadata,
343
- internalDoNotUseMetadata: {
344
- rid: "FooRid",
345
- },
346
- } satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;
347
- "
348
- `);
349
- });
350
- it("Generates map for implementedBy", async () => {
351
- const fooSpt = simpleSpt("foo");
352
- const barSpt = simpleSpt("bar");
353
- const ontology = enhanceOntology({
354
- sanitized: simpleOntology("ontology", [simpleInterface("Foo", [fooSpt], ["Parent"], 2, ["childrenObject"]), simpleInterface("Parent", [barSpt], [])]),
355
- importExt: ""
356
- });
357
- const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true, true), {
358
- parser: "typescript"
359
- });
360
- expect(formattedCode).toMatchInlineSnapshot(`
361
- "import type {
362
- InterfaceDefinition as $InterfaceDefinition,
363
- InterfaceMetadata as $InterfaceMetadata,
364
- ObjectSet as $ObjectSet,
365
- Osdk as $Osdk,
366
- PropertyValueWireToClient as $PropType,
367
- } from "@osdk/api";
368
-
369
- export type OsdkObjectLinks$Foo = {};
370
-
371
- export namespace Foo {
372
- export type PropertyKeys = "foo";
373
-
374
- export interface Props {
375
- /**
376
- * display name: 'foo property dn',
377
- *
378
- * description: foo property desc
379
- */
380
- readonly foo: $PropType["integer"] | undefined;
381
- }
382
- export type StrictProps = Props;
383
-
384
- export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}
385
-
386
- export type OsdkInstance<
387
- OPTIONS extends never | "$rid" = never,
388
- K extends keyof Foo.Props = keyof Foo.Props,
389
- > = $Osdk.Instance<Foo, OPTIONS, K>;
390
-
391
- /** @deprecated use OsdkInstance */
392
- export type OsdkObject<
393
- OPTIONS extends never | "$rid" = never,
394
- K extends keyof Foo.Props = keyof Foo.Props,
395
- > = OsdkInstance<OPTIONS, K>;
396
- }
397
-
398
- export interface Foo extends $InterfaceDefinition {
399
- osdkMetadata: typeof $osdkMetadata;
400
- type: "interface";
401
- apiName: "Foo";
402
- __DefinitionMetadata?: {
403
- objectSet: Foo.ObjectSet;
404
- props: Foo.Props;
405
- linksType: OsdkObjectLinks$Foo;
406
- strictProps: Foo.StrictProps;
407
- apiName: "Foo";
408
- description: "Foo interface desc";
409
- displayName: "Foo interface dn";
410
- implementedBy: ["childrenObject"];
411
- implements: ["Parent"];
412
- links: {};
413
- properties: {
414
- /**
415
- * display name: 'foo property dn',
416
- *
417
- * description: foo property desc
418
- */
419
- foo: $PropertyDef<"integer", "nullable", "single">;
420
- };
421
- rid: "FooRid";
422
- type: "interface";
423
- };
424
- }
425
-
426
- export const Foo = {
427
- type: "interface",
428
- apiName: "Foo",
429
- osdkMetadata: $osdkMetadata,
430
- internalDoNotUseMetadata: {
431
- rid: "FooRid",
432
- },
433
- } satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;
434
- "
435
- `);
436
- });
437
- it("sorts the implements array for stable output", async () => {
438
- // Test with multiple parent interfaces in non-alphabetical order
439
- const ontology = enhanceOntology({
440
- sanitized: simpleOntology("ontology", [simpleInterface("Child", [simpleSpt("child")], ["ParentZ", "ParentA", "ParentC"]), simpleInterface("ParentZ", [simpleSpt("z")], []), simpleInterface("ParentA", [simpleSpt("a")], []), simpleInterface("ParentC", [simpleSpt("c")], [])]),
441
- importExt: ""
442
- });
443
- const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Child, ontology, true, true), {
444
- parser: "typescript"
445
- });
446
-
447
- // Extract the implements array from the generated code
448
- const implementsMatch = formattedCode.match(/implements:\s*\[([^\]]+)\]/s);
449
- expect(implementsMatch).not.toBeNull();
450
- if (implementsMatch) {
451
- const implementsStr = implementsMatch[1];
452
- // Check that the array is sorted alphabetically
453
- expect(implementsStr).toContain("\"ParentA\", \"ParentC\", \"ParentZ\"");
454
- }
455
- });
456
- it("correctly identifies invalid properties", async () => {
457
- const ontology = enhanceOntology({
458
- sanitized: simpleOntology("ontology", [simpleInterface("Child", [simpleSpt("child")], []), simpleInterface("com.A.myChild", [simpleSpt("son"), simpleSpt("com.B.son"), simpleSpt("com.A.daughter")], []), simpleInterface("com.A.myChildNo", [simpleSpt("son"), simpleSpt("com.A.son"), simpleSpt("com.B.daughter")], [])]),
459
- importExt: ""
460
- });
461
- const interfaceDefNoNamespace = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes.Child.raw, false));
462
- const interfaceDefWithNamespaceOk = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes["com.A.myChild"].raw, false));
463
- const interfaceDefWithNamespaceNotOk = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes["com.A.myChildNo"].raw, false));
464
- const noBadProperties = getInvalidInterfaceProperties(ontology.interfaceTypes.Child, interfaceDefNoNamespace);
465
- expect(noBadProperties.length).toBe(0);
466
- const noBadProperties2 = getInvalidInterfaceProperties(ontology.interfaceTypes["com.A.myChild"], interfaceDefWithNamespaceOk);
467
- expect(noBadProperties2.length).toBe(0);
468
- const badProperties = getInvalidInterfaceProperties(ontology.interfaceTypes["com.A.myChildNo"], interfaceDefWithNamespaceNotOk);
469
- expect(badProperties.length).toBe(1);
470
- });
471
- });
472
- //# sourceMappingURL=UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map