@osdk/generator-converters 2.4.0-beta.9 → 2.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js +8 -4
- package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map +1 -1
- package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.js +72 -0
- package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.js.map +1 -0
- package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.js +3 -3
- package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.js.map +1 -1
- package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js +136 -0
- package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js.map +1 -1
- package/build/browser/wireQueryDataTypeToQueryDataTypeDefinition.js +12 -2
- package/build/browser/wireQueryDataTypeToQueryDataTypeDefinition.js.map +1 -1
- package/build/cjs/index.cjs +23 -9
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js +8 -4
- package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map +1 -1
- package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.js +72 -0
- package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.js.map +1 -0
- package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.js +3 -3
- package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.js.map +1 -1
- package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js +136 -0
- package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js.map +1 -1
- package/build/esm/wireQueryDataTypeToQueryDataTypeDefinition.js +12 -2
- package/build/esm/wireQueryDataTypeToQueryDataTypeDefinition.js.map +1 -1
- package/build/types/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.d.ts +1 -0
- package/build/types/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.d.ts.map +1 -0
- package/build/types/wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @osdk/generator-converters
|
|
2
2
|
|
|
3
|
+
## 2.4.0-beta.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @osdk/api@2.4.0-beta.17
|
|
8
|
+
|
|
9
|
+
## 2.4.0-beta.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- @osdk/api@2.4.0-beta.16
|
|
14
|
+
|
|
15
|
+
## 2.4.0-beta.15
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @osdk/api@2.4.0-beta.15
|
|
20
|
+
|
|
21
|
+
## 2.4.0-beta.14
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- @osdk/api@2.4.0-beta.14
|
|
26
|
+
|
|
27
|
+
## 2.4.0-beta.13
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- 4bc848b: Add interface link support.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [4bc848b]
|
|
36
|
+
- @osdk/api@2.4.0-beta.13
|
|
37
|
+
|
|
38
|
+
## 2.4.0-beta.12
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- @osdk/api@2.4.0-beta.12
|
|
43
|
+
|
|
44
|
+
## 2.4.0-beta.11
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- f277b30: Ensure stable ordering of arrays in code generation for object types and interface types. Sort `implements`, `implementedBy` and `linkTypes` arrays alphabetically for consistent output.
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- @osdk/api@2.4.0-beta.11
|
|
53
|
+
|
|
54
|
+
## 2.4.0-beta.10
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- @osdk/api@2.4.0-beta.10
|
|
59
|
+
|
|
3
60
|
## 2.4.0-beta.9
|
|
4
61
|
|
|
5
62
|
### Patch Changes
|
|
@@ -22,12 +22,16 @@ export function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceTyp
|
|
|
22
22
|
apiName: interfaceType.apiName,
|
|
23
23
|
displayName: interfaceType.displayName,
|
|
24
24
|
description: interfaceType.description,
|
|
25
|
-
implements: interfaceType.allExtendsInterfaces
|
|
25
|
+
implements: interfaceType.allExtendsInterfaces ? [...interfaceType.allExtendsInterfaces].sort((a, b) => a.localeCompare(b)) : interfaceType.extendsInterfaces ? [...interfaceType.extendsInterfaces].sort((a, b) => a.localeCompare(b)) : undefined,
|
|
26
26
|
properties: Object.fromEntries(Object.entries(interfaceType.allProperties ?? interfaceType.properties).map(([key, value]) => {
|
|
27
27
|
return [key, wirePropertyV2ToSdkPropertyDefinition(value, true, log)];
|
|
28
|
-
}).filter(([
|
|
29
|
-
links: {},
|
|
30
|
-
|
|
28
|
+
}).filter(([_, value]) => value != null)),
|
|
29
|
+
links: Object.fromEntries(Object.entries(interfaceType.allLinks ?? interfaceType.links ?? {}).map(([linkApiName, linkType]) => [linkApiName, {
|
|
30
|
+
multiplicity: linkType.cardinality === "MANY",
|
|
31
|
+
targetTypeApiName: linkType.linkedEntityApiName.apiName,
|
|
32
|
+
targetType: linkType.linkedEntityApiName.type === "objectTypeApiName" ? "object" : "interface"
|
|
33
|
+
}])),
|
|
34
|
+
implementedBy: interfaceType.implementedByObjectTypes ? [...interfaceType.implementedByObjectTypes].sort((a, b) => a.localeCompare(b)) : interfaceType.implementedByObjectTypes
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
//# sourceMappingURL=__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js","names":["wirePropertyV2ToSdkPropertyDefinition","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","interfaceType","v2","log","type","rid","apiName","displayName","description","implements","allExtendsInterfaces","extendsInterfaces","properties","Object","fromEntries","entries","allProperties","map","key","value","filter","links","implementedBy","implementedByObjectTypes"],"sources":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { InterfaceMetadata } from \"@osdk/api\";\nimport type { InterfaceType } from \"@osdk/foundry.ontologies\";\nimport { wirePropertyV2ToSdkPropertyDefinition } from \"./wirePropertyV2ToSdkPropertyDefinition.js\";\n\nexport function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(\n interfaceType: InterfaceType,\n v2: boolean,\n log?: { info: (msg: string) => void },\n): InterfaceMetadata {\n return {\n type: \"interface\",\n rid: interfaceType.rid,\n apiName: interfaceType.apiName,\n displayName: interfaceType.displayName,\n description: interfaceType.description,\n implements: interfaceType.allExtendsInterfaces\n
|
|
1
|
+
{"version":3,"file":"__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js","names":["wirePropertyV2ToSdkPropertyDefinition","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","interfaceType","v2","log","type","rid","apiName","displayName","description","implements","allExtendsInterfaces","sort","a","b","localeCompare","extendsInterfaces","undefined","properties","Object","fromEntries","entries","allProperties","map","key","value","filter","_","links","allLinks","linkApiName","linkType","multiplicity","cardinality","targetTypeApiName","linkedEntityApiName","targetType","implementedBy","implementedByObjectTypes"],"sources":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { InterfaceMetadata } from \"@osdk/api\";\nimport type { InterfaceType } from \"@osdk/foundry.ontologies\";\nimport { wirePropertyV2ToSdkPropertyDefinition } from \"./wirePropertyV2ToSdkPropertyDefinition.js\";\n\nexport function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(\n interfaceType: InterfaceType,\n v2: boolean,\n log?: { info: (msg: string) => void },\n): InterfaceMetadata {\n return {\n type: \"interface\",\n rid: interfaceType.rid,\n apiName: interfaceType.apiName,\n displayName: interfaceType.displayName,\n description: interfaceType.description,\n implements: interfaceType.allExtendsInterfaces\n ? [...interfaceType.allExtendsInterfaces].sort((a, b) =>\n a.localeCompare(b)\n )\n : interfaceType.extendsInterfaces\n ? [...interfaceType.extendsInterfaces].sort((a, b) => a.localeCompare(b))\n : undefined,\n properties: Object.fromEntries(\n Object.entries(interfaceType.allProperties ?? interfaceType.properties)\n .map((\n [key, value],\n ) => {\n return [\n key,\n wirePropertyV2ToSdkPropertyDefinition(\n value,\n true,\n log,\n ),\n ];\n }).filter(([_, value]) => value != null),\n ),\n links: Object.fromEntries(\n Object.entries(interfaceType.allLinks ?? interfaceType.links ?? {}).map(\n (\n [linkApiName, linkType],\n ) => [linkApiName, {\n multiplicity: linkType.cardinality === \"MANY\",\n targetTypeApiName: linkType.linkedEntityApiName.apiName,\n targetType: linkType.linkedEntityApiName.type === \"objectTypeApiName\"\n ? \"object\"\n : \"interface\",\n }],\n ),\n ),\n implementedBy: interfaceType.implementedByObjectTypes\n ? [...interfaceType.implementedByObjectTypes].sort((a, b) =>\n a.localeCompare(b)\n )\n : interfaceType.implementedByObjectTypes,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,qCAAqC,QAAQ,4CAA4C;AAElG,OAAO,SAASC,mDAAmDA,CACjEC,aAA4B,EAC5BC,EAAW,EACXC,GAAqC,EAClB;EACnB,OAAO;IACLC,IAAI,EAAE,WAAW;IACjBC,GAAG,EAAEJ,aAAa,CAACI,GAAG;IACtBC,OAAO,EAAEL,aAAa,CAACK,OAAO;IAC9BC,WAAW,EAAEN,aAAa,CAACM,WAAW;IACtCC,WAAW,EAAEP,aAAa,CAACO,WAAW;IACtCC,UAAU,EAAER,aAAa,CAACS,oBAAoB,GAC1C,CAAC,GAAGT,aAAa,CAACS,oBAAoB,CAAC,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAClDD,CAAC,CAACE,aAAa,CAACD,CAAC,CACnB,CAAC,GACCZ,aAAa,CAACc,iBAAiB,GAC/B,CAAC,GAAGd,aAAa,CAACc,iBAAiB,CAAC,CAACJ,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC,GACvEG,SAAS;IACbC,UAAU,EAAEC,MAAM,CAACC,WAAW,CAC5BD,MAAM,CAACE,OAAO,CAACnB,aAAa,CAACoB,aAAa,IAAIpB,aAAa,CAACgB,UAAU,CAAC,CACpEK,GAAG,CAAC,CACH,CAACC,GAAG,EAAEC,KAAK,CAAC,KACT;MACH,OAAO,CACLD,GAAG,EACHxB,qCAAqC,CACnCyB,KAAK,EACL,IAAI,EACJrB,GACF,CAAC,CACF;IACH,CAAC,CAAC,CAACsB,MAAM,CAAC,CAAC,CAACC,CAAC,EAAEF,KAAK,CAAC,KAAKA,KAAK,IAAI,IAAI,CAC3C,CAAC;IACDG,KAAK,EAAET,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACnB,aAAa,CAAC2B,QAAQ,IAAI3B,aAAa,CAAC0B,KAAK,IAAI,CAAC,CAAC,CAAC,CAACL,GAAG,CACrE,CACE,CAACO,WAAW,EAAEC,QAAQ,CAAC,KACpB,CAACD,WAAW,EAAE;MACjBE,YAAY,EAAED,QAAQ,CAACE,WAAW,KAAK,MAAM;MAC7CC,iBAAiB,EAAEH,QAAQ,CAACI,mBAAmB,CAAC5B,OAAO;MACvD6B,UAAU,EAAEL,QAAQ,CAACI,mBAAmB,CAAC9B,IAAI,KAAK,mBAAmB,GACjE,QAAQ,GACR;IACN,CAAC,CACH,CACF,CAAC;IACDgC,aAAa,EAAEnC,aAAa,CAACoC,wBAAwB,GACjD,CAAC,GAAGpC,aAAa,CAACoC,wBAAwB,CAAC,CAAC1B,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KACtDD,CAAC,CAACE,aAAa,CAACD,CAAC,CACnB,CAAC,GACCZ,aAAa,CAACoC;EACpB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from "./__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js";
|
|
19
|
+
describe("__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition", () => {
|
|
20
|
+
it("sorts the implements array for stable output", () => {
|
|
21
|
+
const result = __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition({
|
|
22
|
+
apiName: "TestInterface",
|
|
23
|
+
rid: "testRid",
|
|
24
|
+
displayName: "Test Interface",
|
|
25
|
+
description: "A test interface",
|
|
26
|
+
properties: {},
|
|
27
|
+
allProperties: {},
|
|
28
|
+
extendsInterfaces: ["ParentZ", "ParentA", "ParentC"],
|
|
29
|
+
allExtendsInterfaces: ["ParentZ", "ParentA", "ParentC"],
|
|
30
|
+
implementedByObjectTypes: [],
|
|
31
|
+
links: {},
|
|
32
|
+
allLinks: {}
|
|
33
|
+
}, true);
|
|
34
|
+
expect(result.implements).toEqual(["ParentA", "ParentC", "ParentZ"]);
|
|
35
|
+
});
|
|
36
|
+
it("sorts the implementedBy array for stable output", () => {
|
|
37
|
+
const result = __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition({
|
|
38
|
+
apiName: "TestInterface",
|
|
39
|
+
rid: "testRid",
|
|
40
|
+
displayName: "Test Interface",
|
|
41
|
+
description: "A test interface",
|
|
42
|
+
properties: {},
|
|
43
|
+
allProperties: {},
|
|
44
|
+
extendsInterfaces: [],
|
|
45
|
+
allExtendsInterfaces: [],
|
|
46
|
+
implementedByObjectTypes: ["ObjectZ", "ObjectA", "ObjectC"],
|
|
47
|
+
links: {},
|
|
48
|
+
allLinks: {}
|
|
49
|
+
}, true);
|
|
50
|
+
expect(result.implementedBy).toEqual(["ObjectA", "ObjectC", "ObjectZ"]);
|
|
51
|
+
});
|
|
52
|
+
it("preserves empty arrays", () => {
|
|
53
|
+
const result = __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition({
|
|
54
|
+
apiName: "TestInterface",
|
|
55
|
+
rid: "testRid",
|
|
56
|
+
displayName: "Test Interface",
|
|
57
|
+
description: "A test interface",
|
|
58
|
+
properties: {},
|
|
59
|
+
allProperties: {},
|
|
60
|
+
extendsInterfaces: [],
|
|
61
|
+
allExtendsInterfaces: [],
|
|
62
|
+
implementedByObjectTypes: [],
|
|
63
|
+
links: {},
|
|
64
|
+
allLinks: {}
|
|
65
|
+
}, true);
|
|
66
|
+
|
|
67
|
+
// Empty arrays should remain as empty arrays
|
|
68
|
+
expect(result.implements).toEqual([]);
|
|
69
|
+
expect(result.implementedBy).toEqual([]);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.test.js","names":["describe","expect","it","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","result","apiName","rid","displayName","description","properties","allProperties","extendsInterfaces","allExtendsInterfaces","implementedByObjectTypes","links","allLinks","implements","toEqual","implementedBy"],"sources":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.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 { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"./__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js\";\n\ndescribe(\"__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition\", () => {\n it(\"sorts the implements array for stable output\", () => {\n const result = __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition({\n apiName: \"TestInterface\",\n rid: \"testRid\",\n displayName: \"Test Interface\",\n description: \"A test interface\",\n properties: {},\n allProperties: {},\n extendsInterfaces: [\"ParentZ\", \"ParentA\", \"ParentC\"],\n allExtendsInterfaces: [\"ParentZ\", \"ParentA\", \"ParentC\"],\n implementedByObjectTypes: [],\n links: {},\n allLinks: {},\n }, true);\n\n expect(result.implements).toEqual([\"ParentA\", \"ParentC\", \"ParentZ\"]);\n });\n\n it(\"sorts the implementedBy array for stable output\", () => {\n const result = __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition({\n apiName: \"TestInterface\",\n rid: \"testRid\",\n displayName: \"Test Interface\",\n description: \"A test interface\",\n properties: {},\n allProperties: {},\n extendsInterfaces: [],\n allExtendsInterfaces: [],\n implementedByObjectTypes: [\"ObjectZ\", \"ObjectA\", \"ObjectC\"],\n links: {},\n allLinks: {},\n }, true);\n\n expect(result.implementedBy).toEqual([\"ObjectA\", \"ObjectC\", \"ObjectZ\"]);\n });\n\n it(\"preserves empty arrays\", () => {\n const result = __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition({\n apiName: \"TestInterface\",\n rid: \"testRid\",\n displayName: \"Test Interface\",\n description: \"A test interface\",\n properties: {},\n allProperties: {},\n extendsInterfaces: [],\n allExtendsInterfaces: [],\n implementedByObjectTypes: [],\n links: {},\n allLinks: {},\n }, true);\n\n // Empty arrays should remain as empty arrays\n expect(result.implements).toEqual([]);\n expect(result.implementedBy).toEqual([]);\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,mDAAmD,QAAQ,0DAA0D;AAE9HH,QAAQ,CAAC,qDAAqD,EAAE,MAAM;EACpEE,EAAE,CAAC,8CAA8C,EAAE,MAAM;IACvD,MAAME,MAAM,GAAGD,mDAAmD,CAAC;MACjEE,OAAO,EAAE,eAAe;MACxBC,GAAG,EAAE,SAAS;MACdC,WAAW,EAAE,gBAAgB;MAC7BC,WAAW,EAAE,kBAAkB;MAC/BC,UAAU,EAAE,CAAC,CAAC;MACdC,aAAa,EAAE,CAAC,CAAC;MACjBC,iBAAiB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;MACpDC,oBAAoB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;MACvDC,wBAAwB,EAAE,EAAE;MAC5BC,KAAK,EAAE,CAAC,CAAC;MACTC,QAAQ,EAAE,CAAC;IACb,CAAC,EAAE,IAAI,CAAC;IAERd,MAAM,CAACG,MAAM,CAACY,UAAU,CAAC,CAACC,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;EACtE,CAAC,CAAC;EAEFf,EAAE,CAAC,iDAAiD,EAAE,MAAM;IAC1D,MAAME,MAAM,GAAGD,mDAAmD,CAAC;MACjEE,OAAO,EAAE,eAAe;MACxBC,GAAG,EAAE,SAAS;MACdC,WAAW,EAAE,gBAAgB;MAC7BC,WAAW,EAAE,kBAAkB;MAC/BC,UAAU,EAAE,CAAC,CAAC;MACdC,aAAa,EAAE,CAAC,CAAC;MACjBC,iBAAiB,EAAE,EAAE;MACrBC,oBAAoB,EAAE,EAAE;MACxBC,wBAAwB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;MAC3DC,KAAK,EAAE,CAAC,CAAC;MACTC,QAAQ,EAAE,CAAC;IACb,CAAC,EAAE,IAAI,CAAC;IAERd,MAAM,CAACG,MAAM,CAACc,aAAa,CAAC,CAACD,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;EACzE,CAAC,CAAC;EAEFf,EAAE,CAAC,wBAAwB,EAAE,MAAM;IACjC,MAAME,MAAM,GAAGD,mDAAmD,CAAC;MACjEE,OAAO,EAAE,eAAe;MACxBC,GAAG,EAAE,SAAS;MACdC,WAAW,EAAE,gBAAgB;MAC7BC,WAAW,EAAE,kBAAkB;MAC/BC,UAAU,EAAE,CAAC,CAAC;MACdC,aAAa,EAAE,CAAC,CAAC;MACjBC,iBAAiB,EAAE,EAAE;MACrBC,oBAAoB,EAAE,EAAE;MACxBC,wBAAwB,EAAE,EAAE;MAC5BC,KAAK,EAAE,CAAC,CAAC;MACTC,QAAQ,EAAE,CAAC;IACb,CAAC,EAAE,IAAI,CAAC;;IAER;IACAd,MAAM,CAACG,MAAM,CAACY,UAAU,CAAC,CAACC,OAAO,CAAC,EAAE,CAAC;IACrChB,MAAM,CAACG,MAAM,CAACc,aAAa,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;EAC1C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -32,14 +32,14 @@ export function wireObjectTypeFullMetadataToSdkObjectMetadata(objectTypeWithLink
|
|
|
32
32
|
description: objectTypeWithLink.objectType.description,
|
|
33
33
|
primaryKeyApiName: objectTypeWithLink.objectType.primaryKey,
|
|
34
34
|
primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey]),
|
|
35
|
-
links: Object.fromEntries(objectTypeWithLink.linkTypes.map(linkType => {
|
|
35
|
+
links: Object.fromEntries([...objectTypeWithLink.linkTypes].sort((a, b) => a.apiName.localeCompare(b.apiName)).map(linkType => {
|
|
36
36
|
return [linkType.apiName, {
|
|
37
37
|
multiplicity: linkType.cardinality === "MANY",
|
|
38
38
|
targetType: linkType.objectTypeApiName
|
|
39
39
|
}];
|
|
40
40
|
})),
|
|
41
|
-
properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key), log)]).filter(([
|
|
42
|
-
implements: objectTypeWithLink.implementsInterfaces,
|
|
41
|
+
properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key), log)]).filter(([_, value]) => value != null)),
|
|
42
|
+
implements: objectTypeWithLink.implementsInterfaces ? [...objectTypeWithLink.implementsInterfaces].sort((a, b) => a.localeCompare(b)) : objectTypeWithLink.implementsInterfaces,
|
|
43
43
|
interfaceMap,
|
|
44
44
|
inverseInterfaceMap: Object.fromEntries(Object.entries(interfaceMap).map(([interfaceApiName, props]) => [interfaceApiName, invertProps(props)])),
|
|
45
45
|
icon: supportedIconTypes.includes(objectTypeWithLink.objectType.icon.type) ? objectTypeWithLink.objectType.icon : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.js","names":["wirePropertyV2ToSdkPrimaryKeyTypeDefinition","wirePropertyV2ToSdkPropertyDefinition","wireObjectTypeFullMetadataToSdkObjectMetadata","objectTypeWithLink","v2","log","objectType","properties","primaryKey","undefined","Error","apiName","implementsInterfaces2","implementsInterfaces","interfaceMap","Object","fromEntries","entries","map","interfaceApiName","impl","type","description","primaryKeyApiName","primaryKeyType","links","linkTypes","linkType","multiplicity","cardinality","targetType","objectTypeApiName","key","value","filter","implements","inverseInterfaceMap","props","invertProps","icon","supportedIconTypes","includes","titleProperty","displayName","pluralDisplayName","status","ensureStringEnumSupportedOrUndefined","supportedReleaseStatus","rid","visibility","supportedObjectTypeVisibility","
|
|
1
|
+
{"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.js","names":["wirePropertyV2ToSdkPrimaryKeyTypeDefinition","wirePropertyV2ToSdkPropertyDefinition","wireObjectTypeFullMetadataToSdkObjectMetadata","objectTypeWithLink","v2","log","objectType","properties","primaryKey","undefined","Error","apiName","implementsInterfaces2","implementsInterfaces","interfaceMap","Object","fromEntries","entries","map","interfaceApiName","impl","type","description","primaryKeyApiName","primaryKeyType","links","linkTypes","sort","a","b","localeCompare","linkType","multiplicity","cardinality","targetType","objectTypeApiName","key","value","filter","_","implements","inverseInterfaceMap","props","invertProps","icon","supportedIconTypes","includes","titleProperty","displayName","pluralDisplayName","status","ensureStringEnumSupportedOrUndefined","supportedReleaseStatus","rid","visibility","supportedObjectTypeVisibility","k","v","supportedValues"],"sources":["wireObjectTypeFullMetadataToSdkObjectMetadata.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 { ObjectMetadata } from \"@osdk/api\";\nimport type {\n ObjectTypeFullMetadata,\n PropertyApiName,\n PropertyV2,\n} from \"@osdk/foundry.ontologies\";\nimport { wirePropertyV2ToSdkPrimaryKeyTypeDefinition } from \"./wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js\";\nimport { wirePropertyV2ToSdkPropertyDefinition } from \"./wirePropertyV2ToSdkPropertyDefinition.js\";\n\nexport function wireObjectTypeFullMetadataToSdkObjectMetadata(\n objectTypeWithLink: ObjectTypeFullMetadata & {\n objectType: {\n properties: Record<PropertyApiName, PropertyV2 & { nullable?: boolean }>;\n };\n },\n v2: boolean,\n log?: { info: (msg: string) => void },\n): ObjectMetadata {\n if (\n objectTypeWithLink.objectType\n .properties[objectTypeWithLink.objectType.primaryKey] === undefined\n ) {\n throw new Error(\n `Primary key ${objectTypeWithLink.objectType.primaryKey} not found in ${objectTypeWithLink.objectType.apiName}`,\n );\n }\n\n // saved ontology.json files may not have this implementsInterfaces2 so we need to handle\n if (\n objectTypeWithLink.implementsInterfaces2 == null\n && objectTypeWithLink.implementsInterfaces != null\n ) {\n throw new Error(\n \"Your ontology.json file is missing the implementsInterfaces2 field. Please regenerate it.\",\n );\n }\n\n const interfaceMap = objectTypeWithLink.implementsInterfaces2\n ? Object.fromEntries(\n Object.entries(objectTypeWithLink.implementsInterfaces2).map(\n ([interfaceApiName, impl]) => [interfaceApiName, impl.properties],\n ),\n )\n : {};\n\n return {\n type: \"object\",\n apiName: objectTypeWithLink.objectType.apiName,\n description: objectTypeWithLink.objectType.description,\n primaryKeyApiName: objectTypeWithLink.objectType.primaryKey,\n primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(\n objectTypeWithLink.objectType\n .properties[objectTypeWithLink.objectType.primaryKey],\n ),\n links: Object.fromEntries(\n [...objectTypeWithLink.linkTypes].sort((a, b) =>\n a.apiName.localeCompare(b.apiName)\n ).map(linkType => {\n return [linkType.apiName, {\n multiplicity: linkType.cardinality === \"MANY\",\n targetType: linkType.objectTypeApiName,\n }];\n }),\n ),\n properties: Object.fromEntries(\n Object.entries(objectTypeWithLink.objectType.properties).map((\n [key, value],\n ) => [\n key,\n wirePropertyV2ToSdkPropertyDefinition(\n value,\n !(v2 && objectTypeWithLink.objectType.primaryKey === key),\n log,\n ),\n ]).filter(([_, value]) => value != null),\n ),\n implements: objectTypeWithLink.implementsInterfaces\n ? [...objectTypeWithLink.implementsInterfaces].sort((a, b) =>\n a.localeCompare(b)\n )\n : objectTypeWithLink.implementsInterfaces,\n interfaceMap,\n inverseInterfaceMap: Object.fromEntries(\n Object.entries(interfaceMap).map((\n [interfaceApiName, props],\n ) => [interfaceApiName, invertProps(props)]),\n ),\n icon: supportedIconTypes.includes(objectTypeWithLink.objectType.icon.type)\n ? objectTypeWithLink.objectType.icon\n : undefined,\n titleProperty: objectTypeWithLink.objectType.titleProperty,\n displayName: objectTypeWithLink.objectType.displayName,\n pluralDisplayName: objectTypeWithLink.objectType.pluralDisplayName,\n status: ensureStringEnumSupportedOrUndefined(\n objectTypeWithLink.objectType.status,\n supportedReleaseStatus,\n ),\n rid: objectTypeWithLink.objectType.rid,\n visibility: ensureStringEnumSupportedOrUndefined(\n objectTypeWithLink.objectType.visibility,\n supportedObjectTypeVisibility,\n ),\n };\n}\n\nfunction invertProps(\n a?: Record<string, string>,\n): typeof a extends undefined ? typeof a : Record<string, string> {\n return (a\n ? Object.fromEntries(Object.entries(a).map(([k, v]) => [v, k]))\n : undefined) as typeof a extends undefined ? typeof a\n : Record<string, string>;\n}\n\nexport const supportedIconTypes = [\"blueprint\"] as const;\n\nexport const supportedReleaseStatus = [\n \"ACTIVE\",\n \"EXPERIMENTAL\",\n \"DEPRECATED\",\n \"ENDORSED\",\n] as const;\n\nexport const supportedObjectTypeVisibility = [\n \"NORMAL\",\n \"PROMINENT\",\n \"HIDDEN\",\n] as const;\n\nexport function ensureStringEnumSupportedOrUndefined<T extends string>(\n value: T | undefined,\n supportedValues: readonly string[],\n): T | undefined {\n return value && supportedValues.includes(value) ? value : undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,2CAA2C,QAAQ,kDAAkD;AAC9G,SAASC,qCAAqC,QAAQ,4CAA4C;AAElG,OAAO,SAASC,6CAA6CA,CAC3DC,kB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aAAa,EAAE5C,kBAAkB,CAACG,UAAU,CAACyC,aAAa;IAC1DC,WAAW,EAAE7C,kBAAkB,CAACG,UAAU,CAAC0C,WAAW;IACtDC,iBAAiB,EAAE9C,kBAAkB,CAACG,UAAU,CAAC2C,iBAAiB;IAClEC,MAAM,EAAEC,oCAAoC,CAC1ChD,kBAAkB,CAACG,UAAU,CAAC4C,MAAM,EACpCE,sBACF,CAAC;IACDC,GAAG,EAAElD,kBAAkB,CAACG,UAAU,CAAC+C,GAAG;IACtCC,UAAU,EAAEH,oCAAoC,CAC9ChD,kBAAkB,CAACG,UAAU,CAACgD,UAAU,EACxCC,6BACF;EACF,CAAC;AACH;AAEA,SAASZ,WAAWA,CAClBf,CAA0B,EACsC;EAChE,OAAQA,CAAC,GACLb,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACW,CAAC,CAAC,CAACV,GAAG,CAAC,CAAC,CAACsC,CAAC,EAAEC,CAAC,CAAC,KAAK,CAACA,CAAC,EAAED,CAAC,CAAC,CAAC,CAAC,GAC7D/C,SAAS;AAEf;AAEA,OAAO,MAAMoC,kBAAkB,GAAG,CAAC,WAAW,CAAU;AAExD,OAAO,MAAMO,sBAAsB,GAAG,CACpC,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,CACF;AAEV,OAAO,MAAMG,6BAA6B,GAAG,CAC3C,QAAQ,EACR,WAAW,EACX,QAAQ,CACA;AAEV,OAAO,SAASJ,oCAAoCA,CAClDd,KAAoB,EACpBqB,eAAkC,EACnB;EACf,OAAOrB,KAAK,IAAIqB,eAAe,CAACZ,QAAQ,CAACT,KAAK,CAAC,GAAGA,KAAK,GAAG5B,SAAS;AACrE","ignoreList":[]}
|
|
@@ -123,5 +123,141 @@ describe(wireObjectTypeFullMetadataToSdkObjectMetadata, () => {
|
|
|
123
123
|
expect(result.visibility).toBeUndefined();
|
|
124
124
|
expect(result.icon).toBeUndefined();
|
|
125
125
|
});
|
|
126
|
+
it("sorts the implements array for stable output", () => {
|
|
127
|
+
const result = wireObjectTypeFullMetadataToSdkObjectMetadata({
|
|
128
|
+
implementsInterfaces: ["InterfaceZ", "InterfaceA", "InterfaceC"],
|
|
129
|
+
implementsInterfaces2: {
|
|
130
|
+
"InterfaceZ": {
|
|
131
|
+
properties: {}
|
|
132
|
+
},
|
|
133
|
+
"InterfaceA": {
|
|
134
|
+
properties: {}
|
|
135
|
+
},
|
|
136
|
+
"InterfaceC": {
|
|
137
|
+
properties: {}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
linkTypes: [],
|
|
141
|
+
objectType: {
|
|
142
|
+
apiName: "apiName",
|
|
143
|
+
description: "description",
|
|
144
|
+
displayName: "displayName",
|
|
145
|
+
pluralDisplayName: "displayNames",
|
|
146
|
+
icon: {
|
|
147
|
+
type: "blueprint",
|
|
148
|
+
name: "blueprint",
|
|
149
|
+
color: "blue"
|
|
150
|
+
},
|
|
151
|
+
primaryKey: "primaryKey",
|
|
152
|
+
properties: {
|
|
153
|
+
primaryKey: {
|
|
154
|
+
dataType: {
|
|
155
|
+
type: "string"
|
|
156
|
+
},
|
|
157
|
+
"rid": "rid"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
rid: "rid",
|
|
161
|
+
status: "ACTIVE",
|
|
162
|
+
titleProperty: "primaryKey"
|
|
163
|
+
},
|
|
164
|
+
sharedPropertyTypeMapping: {}
|
|
165
|
+
}, true);
|
|
166
|
+
|
|
167
|
+
// Check that the array is sorted alphabetically
|
|
168
|
+
expect(result.implements).toEqual(["InterfaceA", "InterfaceC", "InterfaceZ"]);
|
|
169
|
+
});
|
|
170
|
+
it("sorts the linkTypes array for stable output", () => {
|
|
171
|
+
const result = wireObjectTypeFullMetadataToSdkObjectMetadata({
|
|
172
|
+
implementsInterfaces: [],
|
|
173
|
+
implementsInterfaces2: {},
|
|
174
|
+
linkTypes: [{
|
|
175
|
+
apiName: "linkZ",
|
|
176
|
+
cardinality: "ONE",
|
|
177
|
+
objectTypeApiName: "TargetZ",
|
|
178
|
+
displayName: "LinkZ",
|
|
179
|
+
status: "ACTIVE",
|
|
180
|
+
linkTypeRid: "ridZ"
|
|
181
|
+
}, {
|
|
182
|
+
apiName: "linkA",
|
|
183
|
+
cardinality: "MANY",
|
|
184
|
+
objectTypeApiName: "TargetA",
|
|
185
|
+
displayName: "LinkA",
|
|
186
|
+
status: "ACTIVE",
|
|
187
|
+
linkTypeRid: "ridA"
|
|
188
|
+
}, {
|
|
189
|
+
apiName: "linkC",
|
|
190
|
+
cardinality: "ONE",
|
|
191
|
+
objectTypeApiName: "TargetC",
|
|
192
|
+
displayName: "LinkC",
|
|
193
|
+
status: "ACTIVE",
|
|
194
|
+
linkTypeRid: "ridC"
|
|
195
|
+
}],
|
|
196
|
+
objectType: {
|
|
197
|
+
apiName: "apiName",
|
|
198
|
+
description: "description",
|
|
199
|
+
displayName: "displayName",
|
|
200
|
+
pluralDisplayName: "displayNames",
|
|
201
|
+
icon: {
|
|
202
|
+
type: "blueprint",
|
|
203
|
+
name: "blueprint",
|
|
204
|
+
color: "blue"
|
|
205
|
+
},
|
|
206
|
+
primaryKey: "primaryKey",
|
|
207
|
+
properties: {
|
|
208
|
+
primaryKey: {
|
|
209
|
+
dataType: {
|
|
210
|
+
type: "string"
|
|
211
|
+
},
|
|
212
|
+
"rid": "rid"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
rid: "rid",
|
|
216
|
+
status: "ACTIVE",
|
|
217
|
+
titleProperty: "primaryKey"
|
|
218
|
+
},
|
|
219
|
+
sharedPropertyTypeMapping: {}
|
|
220
|
+
}, true);
|
|
221
|
+
|
|
222
|
+
// Get the link keys in the order they appear in the result
|
|
223
|
+
const linkKeys = Object.keys(result.links);
|
|
224
|
+
|
|
225
|
+
// Check that the links are sorted alphabetically by apiName
|
|
226
|
+
expect(linkKeys).toEqual(["linkA", "linkC", "linkZ"]);
|
|
227
|
+
});
|
|
228
|
+
it("preserves empty arrays", () => {
|
|
229
|
+
const result = wireObjectTypeFullMetadataToSdkObjectMetadata({
|
|
230
|
+
implementsInterfaces: [],
|
|
231
|
+
implementsInterfaces2: {},
|
|
232
|
+
linkTypes: [],
|
|
233
|
+
objectType: {
|
|
234
|
+
apiName: "apiName",
|
|
235
|
+
description: "description",
|
|
236
|
+
displayName: "displayName",
|
|
237
|
+
pluralDisplayName: "displayNames",
|
|
238
|
+
icon: {
|
|
239
|
+
type: "blueprint",
|
|
240
|
+
name: "blueprint",
|
|
241
|
+
color: "blue"
|
|
242
|
+
},
|
|
243
|
+
primaryKey: "primaryKey",
|
|
244
|
+
properties: {
|
|
245
|
+
primaryKey: {
|
|
246
|
+
dataType: {
|
|
247
|
+
type: "string"
|
|
248
|
+
},
|
|
249
|
+
"rid": "rid"
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
rid: "rid",
|
|
253
|
+
status: "ACTIVE",
|
|
254
|
+
titleProperty: "primaryKey"
|
|
255
|
+
},
|
|
256
|
+
sharedPropertyTypeMapping: {}
|
|
257
|
+
}, true);
|
|
258
|
+
|
|
259
|
+
// Check that empty array is preserved
|
|
260
|
+
expect(result.implements).toEqual([]);
|
|
261
|
+
});
|
|
126
262
|
});
|
|
127
263
|
//# sourceMappingURL=wireObjectTypeFullMetadataToSdkObjectMetadata.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.test.js","names":["describe","expect","expectTypeOf","it","wireObjectTypeFullMetadataToSdkObjectMetadata","result","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","apiName","description","displayName","pluralDisplayName","icon","type","name","color","primaryKey","properties","dataType","otherKey","nullable","rid","defaulted","status","titleProperty","sharedPropertyTypeMapping","toBe","toEqualTypeOf","visibility","toBeUndefined"],"sources":["wireObjectTypeFullMetadataToSdkObjectMetadata.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectMetadata } from \"@osdk/api\";\nimport { describe, expect, expectTypeOf, it } from \"vitest\";\nimport type {\n supportedIconTypes,\n supportedObjectTypeVisibility,\n supportedReleaseStatus,\n} from \"./wireObjectTypeFullMetadataToSdkObjectMetadata.js\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"./wireObjectTypeFullMetadataToSdkObjectMetadata.js\";\n\ndescribe(wireObjectTypeFullMetadataToSdkObjectMetadata, () => {\n it(\"handles magic nullable properties\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: { type: \"blueprint\", name: \"blueprint\", color: \"blue\" },\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n otherKey: {\n nullable: false,\n dataType: { type: \"string\" },\n rid: \"rid\",\n },\n defaulted: { dataType: { type: \"string\" }, rid: \"rid\" },\n },\n rid: \"rid\",\n status: \"ACTIVE\",\n titleProperty: \"otherKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n // PK is never nullable\n expect(result.properties[\"primaryKey\"].nullable).toBe(false);\n\n // was specified above\n expect(result.properties[\"otherKey\"].nullable).toBe(false);\n\n // was unspecified, so should be nullable\n expect(result.properties[\"defaulted\"].nullable).toBe(true);\n });\n\n it(\"Is up to date with the enums from API\", () => {\n type excludedStatuses = \"\";\n expectTypeOf<\n Exclude<\n typeof supportedReleaseStatus[number],\n excludedStatuses\n >\n >()\n .toEqualTypeOf<\n NonNullable<ObjectMetadata[\"status\"]>\n >();\n\n type excludedVisibility = \"\";\n expectTypeOf<\n Exclude<typeof supportedObjectTypeVisibility[number], excludedVisibility>\n >().toEqualTypeOf<\n NonNullable<ObjectMetadata[\"visibility\"]>\n >();\n\n type excludedIconTypes = \"\";\n expectTypeOf<\n Exclude<typeof supportedIconTypes[number], excludedIconTypes>\n >()\n .toEqualTypeOf<\n NonNullable<NonNullable<ObjectMetadata[\"icon\"]>[\"type\"]>\n >();\n });\n\n it(\"does not throw when enums don't match\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: {\n type: \"INVALID_NOT_IN_API\",\n name: \"blueprint\",\n color: \"blue\",\n } as any,\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n otherKey: {\n nullable: false,\n dataType: { type: \"string\" },\n rid: \"rid\",\n },\n defaulted: { dataType: { type: \"string\" }, rid: \"rid\" },\n },\n rid: \"rid\",\n status: \"INVALID_NOT_IN_API\" as any,\n visibility: \"INVALID_NOT_IN_API\" as any,\n titleProperty: \"otherKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n expect(result.status).toBeUndefined();\n expect(result.visibility).toBeUndefined();\n expect(result.icon).toBeUndefined();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AAM3D,SAASC,6CAA6C,QAAQ,oDAAoD;AAElHJ,QAAQ,CAACI,6CAA6C,EAAE,MAAM;EAC5DD,EAAE,CAAC,mCAAmC,EAAE,M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AC;IACrC9B,MAAM,CAACI,MAAM,CAACyB,UAAU,CAAC,CAACC,aAAa,CAAC,CAAC;IACzC9B,MAAM,CAACI,MAAM,CAACS,IAAI,CAAC,CAACiB,aAAa,CAAC,CAAC;EACrC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.test.js","names":["describe","expect","expectTypeOf","it","wireObjectTypeFullMetadataToSdkObjectMetadata","result","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","apiName","description","displayName","pluralDisplayName","icon","type","name","color","primaryKey","properties","dataType","otherKey","nullable","rid","defaulted","status","titleProperty","sharedPropertyTypeMapping","toBe","toEqualTypeOf","visibility","toBeUndefined","implements","toEqual","cardinality","objectTypeApiName","linkTypeRid","linkKeys","Object","keys","links"],"sources":["wireObjectTypeFullMetadataToSdkObjectMetadata.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectMetadata } from \"@osdk/api\";\nimport { describe, expect, expectTypeOf, it } from \"vitest\";\nimport type {\n supportedIconTypes,\n supportedObjectTypeVisibility,\n supportedReleaseStatus,\n} from \"./wireObjectTypeFullMetadataToSdkObjectMetadata.js\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"./wireObjectTypeFullMetadataToSdkObjectMetadata.js\";\n\ndescribe(wireObjectTypeFullMetadataToSdkObjectMetadata, () => {\n it(\"handles magic nullable properties\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: { type: \"blueprint\", name: \"blueprint\", color: \"blue\" },\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n otherKey: {\n nullable: false,\n dataType: { type: \"string\" },\n rid: \"rid\",\n },\n defaulted: { dataType: { type: \"string\" }, rid: \"rid\" },\n },\n rid: \"rid\",\n status: \"ACTIVE\",\n titleProperty: \"otherKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n // PK is never nullable\n expect(result.properties[\"primaryKey\"].nullable).toBe(false);\n\n // was specified above\n expect(result.properties[\"otherKey\"].nullable).toBe(false);\n\n // was unspecified, so should be nullable\n expect(result.properties[\"defaulted\"].nullable).toBe(true);\n });\n\n it(\"Is up to date with the enums from API\", () => {\n type excludedStatuses = \"\";\n expectTypeOf<\n Exclude<\n typeof supportedReleaseStatus[number],\n excludedStatuses\n >\n >()\n .toEqualTypeOf<\n NonNullable<ObjectMetadata[\"status\"]>\n >();\n\n type excludedVisibility = \"\";\n expectTypeOf<\n Exclude<typeof supportedObjectTypeVisibility[number], excludedVisibility>\n >().toEqualTypeOf<\n NonNullable<ObjectMetadata[\"visibility\"]>\n >();\n\n type excludedIconTypes = \"\";\n expectTypeOf<\n Exclude<typeof supportedIconTypes[number], excludedIconTypes>\n >()\n .toEqualTypeOf<\n NonNullable<NonNullable<ObjectMetadata[\"icon\"]>[\"type\"]>\n >();\n });\n\n it(\"does not throw when enums don't match\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: {\n type: \"INVALID_NOT_IN_API\",\n name: \"blueprint\",\n color: \"blue\",\n } as any,\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n otherKey: {\n nullable: false,\n dataType: { type: \"string\" },\n rid: \"rid\",\n },\n defaulted: { dataType: { type: \"string\" }, rid: \"rid\" },\n },\n rid: \"rid\",\n status: \"INVALID_NOT_IN_API\" as any,\n visibility: \"INVALID_NOT_IN_API\" as any,\n titleProperty: \"otherKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n expect(result.status).toBeUndefined();\n expect(result.visibility).toBeUndefined();\n expect(result.icon).toBeUndefined();\n });\n\n it(\"sorts the implements array for stable output\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [\"InterfaceZ\", \"InterfaceA\", \"InterfaceC\"],\n implementsInterfaces2: {\n \"InterfaceZ\": { properties: {} },\n \"InterfaceA\": { properties: {} },\n \"InterfaceC\": { properties: {} },\n },\n linkTypes: [],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: { type: \"blueprint\", name: \"blueprint\", color: \"blue\" },\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n },\n rid: \"rid\",\n status: \"ACTIVE\",\n titleProperty: \"primaryKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n // Check that the array is sorted alphabetically\n expect(result.implements).toEqual([\n \"InterfaceA\",\n \"InterfaceC\",\n \"InterfaceZ\",\n ]);\n });\n\n it(\"sorts the linkTypes array for stable output\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [\n {\n apiName: \"linkZ\",\n cardinality: \"ONE\",\n objectTypeApiName: \"TargetZ\",\n displayName: \"LinkZ\",\n status: \"ACTIVE\",\n linkTypeRid: \"ridZ\",\n },\n {\n apiName: \"linkA\",\n cardinality: \"MANY\",\n objectTypeApiName: \"TargetA\",\n displayName: \"LinkA\",\n status: \"ACTIVE\",\n linkTypeRid: \"ridA\",\n },\n {\n apiName: \"linkC\",\n cardinality: \"ONE\",\n objectTypeApiName: \"TargetC\",\n displayName: \"LinkC\",\n status: \"ACTIVE\",\n linkTypeRid: \"ridC\",\n },\n ],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: { type: \"blueprint\", name: \"blueprint\", color: \"blue\" },\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n },\n rid: \"rid\",\n status: \"ACTIVE\",\n titleProperty: \"primaryKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n // Get the link keys in the order they appear in the result\n const linkKeys = Object.keys(result.links);\n\n // Check that the links are sorted alphabetically by apiName\n expect(linkKeys).toEqual([\"linkA\", \"linkC\", \"linkZ\"]);\n });\n\n it(\"preserves empty arrays\", () => {\n const result = wireObjectTypeFullMetadataToSdkObjectMetadata({\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName: \"apiName\",\n description: \"description\",\n displayName: \"displayName\",\n pluralDisplayName: \"displayNames\",\n icon: { type: \"blueprint\", name: \"blueprint\", color: \"blue\" },\n primaryKey: \"primaryKey\",\n properties: {\n primaryKey: { dataType: { type: \"string\" }, \"rid\": \"rid\" },\n },\n rid: \"rid\",\n status: \"ACTIVE\",\n titleProperty: \"primaryKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n\n // Check that empty array is preserved\n expect(result.implements).toEqual([]);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AAM3D,SAASC,6CAA6C,QAAQ,oDAAoD;AAElHJ,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C,MAAM,CAACC,IAAI,CAAClC,MAAM,CAACmC,KAAK,CAAC;;IAE1C;IACAvC,MAAM,CAACoC,QAAQ,CAAC,CAACJ,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;EACvD,CAAC,CAAC;EAEF9B,EAAE,CAAC,wBAAwB,EAAE,MAAM;IACjC,MAAME,MAAM,GAAGD,6CAA6C,CAAC;MAC3DE,oBAAoB,EAAE,EAAE;MACxBC,qBAAqB,EAAE,CAAC,CAAC;MACzBC,SAAS,EAAE,EAAE;MACbC,UAAU,EAAE;QACVC,OAAO,EAAE,SAAS;QAClBC,WAAW,EAAE,aAAa;QAC1BC,WAAW,EAAE,aAAa;QAC1BC,iBAAiB,EAAE,cAAc;QACjCC,IAAI,EAAE;UAAEC,IAAI,EAAE,WAAW;UAAEC,IAAI,EAAE,WAAW;UAAEC,KAAK,EAAE;QAAO,CAAC;QAC7DC,UAAU,EAAE,YAAY;QACxBC,UAAU,EAAE;UACVD,UAAU,EAAE;YAAEE,QAAQ,EAAE;cAAEL,IAAI,EAAE;YAAS,CAAC;YAAE,KAAK,EAAE;UAAM;QAC3D,CAAC;QACDQ,GAAG,EAAE,KAAK;QACVE,MAAM,EAAE,QAAQ;QAChBC,aAAa,EAAE;MACjB,CAAC;MACDC,yBAAyB,EAAE,CAAC;IAC9B,CAAC,EAAE,IAAI,CAAC;;IAER;IACA1B,MAAM,CAACI,MAAM,CAAC2B,UAAU,CAAC,CAACC,OAAO,CAAC,EAAE,CAAC;EACvC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -42,6 +42,18 @@ export function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
42
42
|
objectSet: input.objectTypeApiName,
|
|
43
43
|
nullable: false
|
|
44
44
|
};
|
|
45
|
+
case "interfaceObject":
|
|
46
|
+
return {
|
|
47
|
+
type: "interface",
|
|
48
|
+
interface: input.interfaceTypeApiName,
|
|
49
|
+
nullable: false
|
|
50
|
+
};
|
|
51
|
+
case "interfaceObjectSet":
|
|
52
|
+
return {
|
|
53
|
+
type: "interfaceObjectSet",
|
|
54
|
+
objectSet: input.interfaceTypeApiName,
|
|
55
|
+
nullable: false
|
|
56
|
+
};
|
|
45
57
|
case "array":
|
|
46
58
|
return {
|
|
47
59
|
...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
@@ -111,8 +123,6 @@ export function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
111
123
|
};
|
|
112
124
|
case "null":
|
|
113
125
|
case "unsupported":
|
|
114
|
-
case "interfaceObject":
|
|
115
|
-
case "interfaceObjectSet":
|
|
116
126
|
throw new Error(`Unable to process query because the server indicated an unsupported QueryDataType.type: ${input.type}. Please check that your query is using supported types.`);
|
|
117
127
|
default:
|
|
118
128
|
throw new Error(`Unsupported QueryDataType.type ${input.type}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireQueryDataTypeToQueryDataTypeDefinition.js","names":["isNullableQueryDataType","wireQueryDataTypeToQueryDataTypeDefinition","input","type","nullable","object","objectTypeApiName","objectSet","subType","multiplicity","set","allowNulls","unionTypes","length","nonNull","find","t","union","reduce","acc","push","struct","Object","fromEntries","fields","map","f","name","fieldType","twoDimensionalAggregation","get2DQueryAggregationProps","threeDimensionalAggregation","get3DQueryAggregationProps","keyType","validMapKeyTypes","includes","Error","toString","valueType","keySubtype","guardInvalidKeyTypes","key"],"sources":["wireQueryDataTypeToQueryDataTypeDefinition.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 {\n QueryDataTypeDefinition,\n ThreeDimensionalQueryAggregationDefinition,\n TwoDimensionalQueryAggregationDefinition,\n} from \"@osdk/api\";\nimport type {\n QueryAggregationKeyType,\n QueryDataType,\n ThreeDimensionalAggregation,\n TwoDimensionalAggregation,\n} from \"@osdk/foundry.ontologies\";\nimport { isNullableQueryDataType } from \"./isNullableQueryDataType.js\";\n\nexport function wireQueryDataTypeToQueryDataTypeDefinition<\n K extends string,\n>(\n input: QueryDataType,\n): QueryDataTypeDefinition {\n switch (input.type) {\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"attachment\":\n case \"boolean\":\n case \"date\":\n case \"string\":\n case \"timestamp\":\n return {\n type: input.type,\n nullable: false,\n };\n\n case \"object\":\n return {\n type: \"object\",\n object: input.objectTypeApiName as K,\n nullable: false,\n };\n\n case \"objectSet\":\n return {\n type: \"objectSet\",\n objectSet: input.objectTypeApiName as K,\n nullable: false,\n };\n\n case \"array\":\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n multiplicity: true,\n };\n\n case \"set\":\n return {\n type: \"set\",\n set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n nullable: false,\n };\n\n case \"union\":\n const allowNulls = isNullableQueryDataType(input);\n\n // special case for a union where one half is nullable to skip the union step and just allow nulls directly\n if (allowNulls && input.unionTypes.length === 2) {\n const nonNull = input.unionTypes.find(t => t.type != null);\n if (nonNull) {\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),\n nullable: true,\n };\n }\n }\n\n return {\n type: \"union\",\n union: input.unionTypes.reduce<QueryDataTypeDefinition[]>((acc, t) => {\n if (t.type === \"null\") {\n return acc;\n }\n acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));\n return acc;\n }, []),\n nullable: allowNulls,\n };\n\n case \"struct\":\n return {\n type: \"struct\",\n struct: Object.fromEntries(input.fields.map(f => [\n f.name,\n wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType),\n ])),\n nullable: false,\n };\n\n case \"twoDimensionalAggregation\":\n return {\n type: \"twoDimensionalAggregation\",\n twoDimensionalAggregation: get2DQueryAggregationProps(input),\n nullable: false,\n };\n\n case \"threeDimensionalAggregation\":\n return {\n type: \"threeDimensionalAggregation\",\n threeDimensionalAggregation: get3DQueryAggregationProps(input),\n nullable: false,\n };\n\n case \"entrySet\":\n const keyType = wireQueryDataTypeToQueryDataTypeDefinition(input.keyType);\n\n if (!validMapKeyTypes.includes(keyType.type)) {\n throw new Error(\n \"Map types with a key type of \" + keyType.type + \" are not supported\"\n + validMapKeyTypes.toString(),\n );\n }\n\n if (keyType.multiplicity === true) {\n throw new Error(\n \"Map types cannot have keys as arrays\",\n );\n }\n\n return {\n type: \"map\",\n nullable: false,\n keyType,\n valueType: wireQueryDataTypeToQueryDataTypeDefinition(input.valueType),\n };\n\n case \"null\":\n case \"unsupported\":\n case \"interfaceObject\":\n case \"interfaceObjectSet\":\n throw new Error(\n `Unable to process query because the server indicated an unsupported QueryDataType.type: ${input.type}. Please check that your query is using supported types.`,\n );\n\n default:\n const _: never = input;\n throw new Error(`Unsupported QueryDataType.type ${(input as any).type}`);\n }\n}\n\nfunction get2DQueryAggregationProps(\n input: TwoDimensionalAggregation,\n): TwoDimensionalQueryAggregationDefinition {\n if (input.keyType.type === \"range\") {\n return {\n keyType: input.keyType.type,\n keySubtype: input.keyType.subType.type,\n valueType: input.valueType.type,\n };\n } else {\n if (guardInvalidKeyTypes(input.keyType)) {\n return {\n keyType: input.keyType.type,\n valueType: input.valueType.type,\n };\n }\n throw new Error(\n `Cannot create 2D aggregation with ${input.keyType.type} as its type`,\n );\n }\n}\n\nfunction get3DQueryAggregationProps(\n input: ThreeDimensionalAggregation,\n): ThreeDimensionalQueryAggregationDefinition {\n if (input.keyType.type === \"range\") {\n return {\n keyType: input.keyType.type,\n keySubtype: input.keyType.subType.type,\n valueType: get2DQueryAggregationProps(input.valueType),\n };\n } else {\n if (guardInvalidKeyTypes(input.keyType)) {\n return {\n keyType: input.keyType.type,\n valueType: get2DQueryAggregationProps(input.valueType),\n };\n }\n throw new Error(\n `Cannot create 3D aggregation with ${input.keyType.type} as its type`,\n );\n }\n}\n\n/**\n * Guard against aggregation key types that are allowed by the backend types but are illegal to actually use\n */\nfunction guardInvalidKeyTypes(\n key: QueryAggregationKeyType,\n): key is QueryAggregationKeyType & ({ type: \"string\" | \"boolean\" }) {\n return key.type === \"string\" || key.type === \"boolean\";\n}\n\n/**\n * The set of all valid key types for maps. This includes all types that are represented by strings or numbers in the OSDK, and Ontology Objects.\n */\nconst validMapKeyTypes = [\n \"string\",\n \"object\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"date\",\n \"timestamp\",\n \"byte\",\n \"datetime\",\n \"decimal\",\n \"marking\",\n \"short\",\n \"objectType\",\n];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,SAASC,0CAA0CA,CAGxDC,KAAoB,EACK;EACzB,QAAQA,KAAK,CAACC,IAAI;IAChB,KAAK,QAAQ;IACb,KAAK,OAAO;IACZ,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,YAAY;IACjB,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,QAAQ;IACb,KAAK,WAAW;MACd,OAAO;QACLA,IAAI,EAAED,KAAK,CAACC,IAAI;QAChBC,QAAQ,EAAE;MACZ,CAAC;IAEH,KAAK,QAAQ;MACX,OAAO;QACLD,IAAI,EAAE,QAAQ;QACdE,MAAM,EAAEH,KAAK,CAACI,iBAAsB;QACpCF,QAAQ,EAAE;MACZ,CAAC;IAEH,KAAK,WAAW;MACd,OAAO;QACLD,IAAI,EAAE,WAAW;QACjBI,SAAS,EAAEL,KAAK,CAACI,iBAAsB;QACvCF,QAAQ,EAAE;MACZ,CAAC;IAEH,K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AG,CAACtC,IAAI,KAAK,SAAS;AACxD;;AAEA;AACA;AACA;AACA,MAAM+B,gBAAgB,GAAG,CACvB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,MAAM,EACN,WAAW,EACX,MAAM,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,YAAY,CACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"wireQueryDataTypeToQueryDataTypeDefinition.js","names":["isNullableQueryDataType","wireQueryDataTypeToQueryDataTypeDefinition","input","type","nullable","object","objectTypeApiName","objectSet","interface","interfaceTypeApiName","subType","multiplicity","set","allowNulls","unionTypes","length","nonNull","find","t","union","reduce","acc","push","struct","Object","fromEntries","fields","map","f","name","fieldType","twoDimensionalAggregation","get2DQueryAggregationProps","threeDimensionalAggregation","get3DQueryAggregationProps","keyType","validMapKeyTypes","includes","Error","toString","valueType","keySubtype","guardInvalidKeyTypes","key"],"sources":["wireQueryDataTypeToQueryDataTypeDefinition.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 {\n QueryDataTypeDefinition,\n ThreeDimensionalQueryAggregationDefinition,\n TwoDimensionalQueryAggregationDefinition,\n} from \"@osdk/api\";\nimport type {\n QueryAggregationKeyType,\n QueryDataType,\n ThreeDimensionalAggregation,\n TwoDimensionalAggregation,\n} from \"@osdk/foundry.ontologies\";\nimport { isNullableQueryDataType } from \"./isNullableQueryDataType.js\";\n\nexport function wireQueryDataTypeToQueryDataTypeDefinition<\n K extends string,\n>(\n input: QueryDataType,\n): QueryDataTypeDefinition {\n switch (input.type) {\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"attachment\":\n case \"boolean\":\n case \"date\":\n case \"string\":\n case \"timestamp\":\n return {\n type: input.type,\n nullable: false,\n };\n\n case \"object\":\n return {\n type: \"object\",\n object: input.objectTypeApiName as K,\n nullable: false,\n };\n\n case \"objectSet\":\n return {\n type: \"objectSet\",\n objectSet: input.objectTypeApiName as K,\n nullable: false,\n };\n case \"interfaceObject\":\n return {\n type: \"interface\",\n interface: input.interfaceTypeApiName as K,\n nullable: false,\n };\n case \"interfaceObjectSet\":\n return {\n type: \"interfaceObjectSet\",\n objectSet: input.interfaceTypeApiName as K,\n nullable: false,\n };\n case \"array\":\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n multiplicity: true,\n };\n\n case \"set\":\n return {\n type: \"set\",\n set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n nullable: false,\n };\n\n case \"union\":\n const allowNulls = isNullableQueryDataType(input);\n\n // special case for a union where one half is nullable to skip the union step and just allow nulls directly\n if (allowNulls && input.unionTypes.length === 2) {\n const nonNull = input.unionTypes.find(t => t.type != null);\n if (nonNull) {\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),\n nullable: true,\n };\n }\n }\n\n return {\n type: \"union\",\n union: input.unionTypes.reduce<QueryDataTypeDefinition[]>((acc, t) => {\n if (t.type === \"null\") {\n return acc;\n }\n acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));\n return acc;\n }, []),\n nullable: allowNulls,\n };\n\n case \"struct\":\n return {\n type: \"struct\",\n struct: Object.fromEntries(input.fields.map(f => [\n f.name,\n wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType),\n ])),\n nullable: false,\n };\n\n case \"twoDimensionalAggregation\":\n return {\n type: \"twoDimensionalAggregation\",\n twoDimensionalAggregation: get2DQueryAggregationProps(input),\n nullable: false,\n };\n\n case \"threeDimensionalAggregation\":\n return {\n type: \"threeDimensionalAggregation\",\n threeDimensionalAggregation: get3DQueryAggregationProps(input),\n nullable: false,\n };\n\n case \"entrySet\":\n const keyType = wireQueryDataTypeToQueryDataTypeDefinition(input.keyType);\n\n if (!validMapKeyTypes.includes(keyType.type)) {\n throw new Error(\n \"Map types with a key type of \" + keyType.type + \" are not supported\"\n + validMapKeyTypes.toString(),\n );\n }\n\n if (keyType.multiplicity === true) {\n throw new Error(\n \"Map types cannot have keys as arrays\",\n );\n }\n\n return {\n type: \"map\",\n nullable: false,\n keyType,\n valueType: wireQueryDataTypeToQueryDataTypeDefinition(input.valueType),\n };\n\n case \"null\":\n case \"unsupported\":\n throw new Error(\n `Unable to process query because the server indicated an unsupported QueryDataType.type: ${input.type}. Please check that your query is using supported types.`,\n );\n\n default:\n const _: never = input;\n throw new Error(`Unsupported QueryDataType.type ${(input as any).type}`);\n }\n}\n\nfunction get2DQueryAggregationProps(\n input: TwoDimensionalAggregation,\n): TwoDimensionalQueryAggregationDefinition {\n if (input.keyType.type === \"range\") {\n return {\n keyType: input.keyType.type,\n keySubtype: input.keyType.subType.type,\n valueType: input.valueType.type,\n };\n } else {\n if (guardInvalidKeyTypes(input.keyType)) {\n return {\n keyType: input.keyType.type,\n valueType: input.valueType.type,\n };\n }\n throw new Error(\n `Cannot create 2D aggregation with ${input.keyType.type} as its type`,\n );\n }\n}\n\nfunction get3DQueryAggregationProps(\n input: ThreeDimensionalAggregation,\n): ThreeDimensionalQueryAggregationDefinition {\n if (input.keyType.type === \"range\") {\n return {\n keyType: input.keyType.type,\n keySubtype: input.keyType.subType.type,\n valueType: get2DQueryAggregationProps(input.valueType),\n };\n } else {\n if (guardInvalidKeyTypes(input.keyType)) {\n return {\n keyType: input.keyType.type,\n valueType: get2DQueryAggregationProps(input.valueType),\n };\n }\n throw new Error(\n `Cannot create 3D aggregation with ${input.keyType.type} as its type`,\n );\n }\n}\n\n/**\n * Guard against aggregation key types that are allowed by the backend types but are illegal to actually use\n */\nfunction guardInvalidKeyTypes(\n key: QueryAggregationKeyType,\n): key is QueryAggregationKeyType & ({ type: \"string\" | \"boolean\" }) {\n return key.type === \"string\" || key.type === \"boolean\";\n}\n\n/**\n * The set of all valid key types for maps. This includes all types that are represented by strings or numbers in the OSDK, and Ontology Objects.\n */\nconst validMapKeyTypes = [\n \"string\",\n \"object\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"date\",\n \"timestamp\",\n \"byte\",\n \"datetime\",\n \"decimal\",\n \"marking\",\n \"short\",\n \"objectType\",\n];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,SAASC,0CAA0CA,CAGxDC,KAAoB,EACK;EACzB,QAAQA,KAAK,CAACC,IAAI;IAChB,KAAK,QAAQ;IACb,KAAK,OAAO;IACZ,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,YAAY;IACjB,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,QAAQ;IACb,KAAK,WAAW;MACd,OAAO;QACLA,IAAI,EAAED,KAAK,CAACC,IAAI;QAChBC,QAAQ,EAAE;MACZ,CAAC;IAEH,KAAK,QAAQ;MACX,OAAO;QACLD,IAAI,EAAE,QAAQ;QACdE,MAAM,EAAEH,KAAK,CAACI,iBAAsB;QACpCF,QAAQ,EAAE;MACZ,CAAC;IAEH,KAAK,WAAW;MACd,OAAO;QACLD,IAAI,EAAE,WAAW;QACjBI,SAAS,EAAEL,KAAK,CAACI,iBAAsB;QACvCF,QAAQ,EAAE;MACZ,CAAC;IACH,KAAK,iBAAiB;MACpB,OAAO;QACLD,IAAI,EAAE,WAAW;QACjBK,SAAS,EAAEN,KAAK,CAACO,oBAAyB;QAC1CL,QAAQ,EAAE;MACZ,CAAC;IACH,KAAK,oBAAoB;MACvB,OAAO;QACLD,IAAI,EAAE,oBAAoB;QAC1B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AQ,IAAIwC,GAAG,CAACxC,IAAI,KAAK,SAAS;AACxD;;AAEA;AACA;AACA;AACA,MAAMiC,gBAAgB,GAAG,CACvB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,MAAM,EACN,WAAW,EACX,MAAM,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,YAAY,CACb","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -108,12 +108,16 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceType, v2,
|
|
|
108
108
|
apiName: interfaceType.apiName,
|
|
109
109
|
displayName: interfaceType.displayName,
|
|
110
110
|
description: interfaceType.description,
|
|
111
|
-
implements: interfaceType.allExtendsInterfaces
|
|
111
|
+
implements: interfaceType.allExtendsInterfaces ? [...interfaceType.allExtendsInterfaces].sort((a, b) => a.localeCompare(b)) : interfaceType.extendsInterfaces ? [...interfaceType.extendsInterfaces].sort((a, b) => a.localeCompare(b)) : void 0,
|
|
112
112
|
properties: Object.fromEntries(Object.entries(interfaceType.allProperties ?? interfaceType.properties).map(([key, value]) => {
|
|
113
113
|
return [key, wirePropertyV2ToSdkPropertyDefinition(value, true, log)];
|
|
114
|
-
}).filter(([
|
|
115
|
-
links: {},
|
|
116
|
-
|
|
114
|
+
}).filter(([_, value]) => value != null)),
|
|
115
|
+
links: Object.fromEntries(Object.entries(interfaceType.allLinks ?? interfaceType.links ?? {}).map(([linkApiName, linkType]) => [linkApiName, {
|
|
116
|
+
multiplicity: linkType.cardinality === "MANY",
|
|
117
|
+
targetTypeApiName: linkType.linkedEntityApiName.apiName,
|
|
118
|
+
targetType: linkType.linkedEntityApiName.type === "objectTypeApiName" ? "object" : "interface"
|
|
119
|
+
}])),
|
|
120
|
+
implementedBy: interfaceType.implementedByObjectTypes ? [...interfaceType.implementedByObjectTypes].sort((a, b) => a.localeCompare(b)) : interfaceType.implementedByObjectTypes
|
|
117
121
|
};
|
|
118
122
|
}
|
|
119
123
|
|
|
@@ -188,14 +192,14 @@ function wireObjectTypeFullMetadataToSdkObjectMetadata(objectTypeWithLink, v2, l
|
|
|
188
192
|
description: objectTypeWithLink.objectType.description,
|
|
189
193
|
primaryKeyApiName: objectTypeWithLink.objectType.primaryKey,
|
|
190
194
|
primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey]),
|
|
191
|
-
links: Object.fromEntries(objectTypeWithLink.linkTypes.map((linkType) => {
|
|
195
|
+
links: Object.fromEntries([...objectTypeWithLink.linkTypes].sort((a, b) => a.apiName.localeCompare(b.apiName)).map((linkType) => {
|
|
192
196
|
return [linkType.apiName, {
|
|
193
197
|
multiplicity: linkType.cardinality === "MANY",
|
|
194
198
|
targetType: linkType.objectTypeApiName
|
|
195
199
|
}];
|
|
196
200
|
})),
|
|
197
|
-
properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key), log)]).filter(([
|
|
198
|
-
implements: objectTypeWithLink.implementsInterfaces,
|
|
201
|
+
properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key), log)]).filter(([_, value]) => value != null)),
|
|
202
|
+
implements: objectTypeWithLink.implementsInterfaces ? [...objectTypeWithLink.implementsInterfaces].sort((a, b) => a.localeCompare(b)) : objectTypeWithLink.implementsInterfaces,
|
|
199
203
|
interfaceMap,
|
|
200
204
|
inverseInterfaceMap: Object.fromEntries(Object.entries(interfaceMap).map(([interfaceApiName, props]) => [interfaceApiName, invertProps(props)])),
|
|
201
205
|
icon: supportedIconTypes.includes(objectTypeWithLink.objectType.icon.type) ? objectTypeWithLink.objectType.icon : void 0,
|
|
@@ -345,6 +349,18 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
345
349
|
objectSet: input.objectTypeApiName,
|
|
346
350
|
nullable: false
|
|
347
351
|
};
|
|
352
|
+
case "interfaceObject":
|
|
353
|
+
return {
|
|
354
|
+
type: "interface",
|
|
355
|
+
interface: input.interfaceTypeApiName,
|
|
356
|
+
nullable: false
|
|
357
|
+
};
|
|
358
|
+
case "interfaceObjectSet":
|
|
359
|
+
return {
|
|
360
|
+
type: "interfaceObjectSet",
|
|
361
|
+
objectSet: input.interfaceTypeApiName,
|
|
362
|
+
nullable: false
|
|
363
|
+
};
|
|
348
364
|
case "array":
|
|
349
365
|
return {
|
|
350
366
|
...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
@@ -412,8 +428,6 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
412
428
|
};
|
|
413
429
|
case "null":
|
|
414
430
|
case "unsupported":
|
|
415
|
-
case "interfaceObject":
|
|
416
|
-
case "interfaceObjectSet":
|
|
417
431
|
throw new Error(`Unable to process query because the server indicated an unsupported QueryDataType.type: ${input.type}. Please check that your query is using supported types.`);
|
|
418
432
|
default:
|
|
419
433
|
throw new Error(`Unsupported QueryDataType.type ${input.type}`);
|