@osdk/generator-converters 2.0.0-beta.9 → 2.0.0

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 (108) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/build/{cjs/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.d.cts → browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.d.ts} +2 -2
  3. package/build/{cjs → browser}/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.d.ts.map +1 -1
  4. package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js +31 -0
  5. package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map +1 -0
  6. package/build/browser/empty.test.js +22 -0
  7. package/build/browser/empty.test.js.map +1 -0
  8. package/build/browser/getEditedEntities.d.ts +7 -0
  9. package/build/browser/getEditedEntities.d.ts.map +1 -0
  10. package/build/browser/getEditedEntities.js +41 -0
  11. package/build/browser/getEditedEntities.js.map +1 -0
  12. package/build/browser/index.d.ts +9 -0
  13. package/build/browser/index.d.ts.map +1 -0
  14. package/build/browser/index.js +23 -154
  15. package/build/browser/index.js.map +1 -1
  16. package/build/browser/isNullableQueryDataType.d.ts +3 -0
  17. package/build/browser/isNullableQueryDataType.d.ts.map +1 -0
  18. package/build/browser/isNullableQueryDataType.js +25 -0
  19. package/build/browser/isNullableQueryDataType.js.map +1 -0
  20. package/build/browser/wireActionTypeV2ToSdkActionMetadata.d.ts +4 -0
  21. package/build/browser/wireActionTypeV2ToSdkActionMetadata.d.ts.map +1 -0
  22. package/build/browser/wireActionTypeV2ToSdkActionMetadata.js +85 -0
  23. package/build/browser/wireActionTypeV2ToSdkActionMetadata.js.map +1 -0
  24. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts +10 -0
  25. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts.map +1 -0
  26. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.js +56 -0
  27. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.js.map +1 -0
  28. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.test.d.ts +2 -0
  29. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.test.d.ts.map +1 -0
  30. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js +67 -0
  31. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js.map +1 -0
  32. package/build/{cjs → browser}/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts.map +1 -1
  33. package/build/browser/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js +51 -0
  34. package/build/browser/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js.map +1 -0
  35. package/build/{cjs/wirePropertyV2ToSdkPropertyDefinition.d.cts → browser/wirePropertyV2ToSdkPropertyDefinition.d.ts} +2 -2
  36. package/build/browser/wirePropertyV2ToSdkPropertyDefinition.d.ts.map +1 -0
  37. package/build/browser/wirePropertyV2ToSdkPropertyDefinition.js +90 -0
  38. package/build/browser/wirePropertyV2ToSdkPropertyDefinition.js.map +1 -0
  39. package/build/browser/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +4 -0
  40. package/build/browser/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -0
  41. package/build/browser/wireQueryDataTypeToQueryDataTypeDefinition.js +143 -0
  42. package/build/browser/wireQueryDataTypeToQueryDataTypeDefinition.js.map +1 -0
  43. package/build/browser/wireQueryTypeV2ToSdkQueryMetadata.d.ts +13 -0
  44. package/build/browser/wireQueryTypeV2ToSdkQueryMetadata.d.ts.map +1 -0
  45. package/build/browser/wireQueryTypeV2ToSdkQueryMetadata.js +45 -0
  46. package/build/browser/wireQueryTypeV2ToSdkQueryMetadata.js.map +1 -0
  47. package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.d.ts +2 -2
  48. package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.d.ts.map +1 -1
  49. package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js +31 -0
  50. package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map +1 -0
  51. package/build/esm/empty.test.js +22 -0
  52. package/build/esm/empty.test.js.map +1 -0
  53. package/build/esm/getEditedEntities.d.ts +7 -0
  54. package/build/esm/getEditedEntities.d.ts.map +1 -0
  55. package/build/esm/getEditedEntities.js +41 -0
  56. package/build/esm/getEditedEntities.js.map +1 -0
  57. package/build/esm/index.d.ts +6 -1
  58. package/build/esm/index.d.ts.map +1 -1
  59. package/build/esm/index.js +23 -154
  60. package/build/esm/index.js.map +1 -1
  61. package/build/esm/isNullableQueryDataType.d.ts +3 -0
  62. package/build/esm/isNullableQueryDataType.d.ts.map +1 -0
  63. package/build/esm/isNullableQueryDataType.js +25 -0
  64. package/build/esm/isNullableQueryDataType.js.map +1 -0
  65. package/build/esm/wireActionTypeV2ToSdkActionMetadata.d.ts +4 -0
  66. package/build/esm/wireActionTypeV2ToSdkActionMetadata.d.ts.map +1 -0
  67. package/build/esm/wireActionTypeV2ToSdkActionMetadata.js +85 -0
  68. package/build/esm/wireActionTypeV2ToSdkActionMetadata.js.map +1 -0
  69. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts +10 -0
  70. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts.map +1 -0
  71. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.js +56 -0
  72. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.js.map +1 -0
  73. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.test.d.ts +2 -0
  74. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.test.d.ts.map +1 -0
  75. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js +67 -0
  76. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.test.js.map +1 -0
  77. package/build/esm/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts.map +1 -1
  78. package/build/esm/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js +51 -0
  79. package/build/esm/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js.map +1 -0
  80. package/build/esm/wirePropertyV2ToSdkPropertyDefinition.d.ts +2 -2
  81. package/build/esm/wirePropertyV2ToSdkPropertyDefinition.d.ts.map +1 -1
  82. package/build/esm/wirePropertyV2ToSdkPropertyDefinition.js +90 -0
  83. package/build/esm/wirePropertyV2ToSdkPropertyDefinition.js.map +1 -0
  84. package/build/esm/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +4 -0
  85. package/build/esm/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -0
  86. package/build/esm/wireQueryDataTypeToQueryDataTypeDefinition.js +143 -0
  87. package/build/esm/wireQueryDataTypeToQueryDataTypeDefinition.js.map +1 -0
  88. package/build/esm/wireQueryTypeV2ToSdkQueryMetadata.d.ts +13 -0
  89. package/build/esm/wireQueryTypeV2ToSdkQueryMetadata.d.ts.map +1 -0
  90. package/build/esm/wireQueryTypeV2ToSdkQueryMetadata.js +45 -0
  91. package/build/esm/wireQueryTypeV2ToSdkQueryMetadata.js.map +1 -0
  92. package/package.json +7 -12
  93. package/build/cjs/index.cjs +0 -159
  94. package/build/cjs/index.cjs.map +0 -1
  95. package/build/cjs/index.d.cts +0 -4
  96. package/build/cjs/index.d.ts.map +0 -1
  97. package/build/cjs/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.d.cts +0 -10
  98. package/build/cjs/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.d.ts.map +0 -1
  99. package/build/cjs/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.test.d.cts +0 -2
  100. package/build/cjs/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.test.d.ts.map +0 -1
  101. package/build/cjs/wirePropertyV2ToSdkPropertyDefinition.d.ts.map +0 -1
  102. package/build/esm/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.d.ts +0 -10
  103. package/build/esm/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.d.ts.map +0 -1
  104. package/build/esm/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.test.d.ts +0 -2
  105. package/build/esm/wireObjectTypeFullMetadataToSdkObjectTypeDefinition.test.d.ts.map +0 -1
  106. /package/build/{cjs/empty.test.d.cts → browser/empty.test.d.ts} +0 -0
  107. /package/build/{cjs → browser}/empty.test.d.ts.map +0 -0
  108. /package/build/{cjs/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.cts → browser/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts} +0 -0
@@ -0,0 +1,85 @@
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
+ import { getModifiedEntityTypes } from "./getEditedEntities.js";
17
+ export function wireActionTypeV2ToSdkActionMetadata(input) {
18
+ const modifiedEntityTypes = getModifiedEntityTypes(input);
19
+ return {
20
+ type: "action",
21
+ apiName: input.apiName,
22
+ parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),
23
+ displayName: input.displayName,
24
+ description: input.description,
25
+ modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects),
26
+ rid: input.rid,
27
+ status: input.status
28
+ };
29
+ }
30
+ function wireActionParameterV2ToSdkParameterDefinition(value) {
31
+ return {
32
+ multiplicity: value.dataType.type === "array",
33
+ type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
34
+ nullable: !value.required,
35
+ description: value.description
36
+ };
37
+ }
38
+ function actionPropertyToSdkPropertyDefinition(parameterType) {
39
+ switch (parameterType.type) {
40
+ case "string":
41
+ case "boolean":
42
+ case "attachment":
43
+ case "double":
44
+ case "integer":
45
+ case "long":
46
+ case "timestamp":
47
+ case "marking":
48
+ return parameterType.type;
49
+ case "date":
50
+ return "datetime";
51
+ case "objectSet":
52
+ return {
53
+ type: "objectSet",
54
+ objectSet: parameterType.objectTypeApiName
55
+ };
56
+ case "object":
57
+ return {
58
+ type: "object",
59
+ object: parameterType.objectTypeApiName
60
+ };
61
+ case "array":
62
+ return actionPropertyToSdkPropertyDefinition(parameterType.subType);
63
+ }
64
+ }
65
+ function createModifiedEntities(addedObjects, modifiedObjects) {
66
+ let entities = {};
67
+ for (const key of addedObjects) {
68
+ entities[key] = {
69
+ created: true,
70
+ modified: false
71
+ };
72
+ }
73
+ for (const key of modifiedObjects) {
74
+ if (entities[key]) {
75
+ entities[key].modified = true;
76
+ } else {
77
+ entities[key] = {
78
+ created: false,
79
+ modified: true
80
+ };
81
+ }
82
+ }
83
+ return entities;
84
+ }
85
+ //# sourceMappingURL=wireActionTypeV2ToSdkActionMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireActionTypeV2ToSdkActionMetadata.js","names":["getModifiedEntityTypes","wireActionTypeV2ToSdkActionMetadata","input","modifiedEntityTypes","type","apiName","parameters","Object","fromEntries","entries","map","key","value","wireActionParameterV2ToSdkParameterDefinition","displayName","description","modifiedEntities","createModifiedEntities","addedObjects","modifiedObjects","rid","status","multiplicity","dataType","actionPropertyToSdkPropertyDefinition","subType","nullable","required","parameterType","objectSet","objectTypeApiName","object","entities","created","modified"],"sources":["wireActionTypeV2ToSdkActionMetadata.js"],"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 */\nimport { getModifiedEntityTypes } from \"./getEditedEntities.js\";\nexport function wireActionTypeV2ToSdkActionMetadata(input) {\n const modifiedEntityTypes = getModifiedEntityTypes(input);\n return {\n type: \"action\",\n apiName: input.apiName,\n parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),\n displayName: input.displayName,\n description: input.description,\n modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects),\n rid: input.rid,\n status: input.status,\n };\n}\nfunction wireActionParameterV2ToSdkParameterDefinition(value) {\n return {\n multiplicity: value.dataType.type === \"array\",\n type: actionPropertyToSdkPropertyDefinition(value.dataType.type === \"array\" ? value.dataType.subType : value.dataType),\n nullable: !value.required,\n description: value.description,\n };\n}\nfunction actionPropertyToSdkPropertyDefinition(parameterType) {\n switch (parameterType.type) {\n case \"string\":\n case \"boolean\":\n case \"attachment\":\n case \"double\":\n case \"integer\":\n case \"long\":\n case \"timestamp\":\n case \"marking\":\n return parameterType.type;\n case \"date\":\n return \"datetime\";\n case \"objectSet\":\n return { type: \"objectSet\", objectSet: parameterType.objectTypeApiName };\n case \"object\":\n return { type: \"object\", object: parameterType.objectTypeApiName };\n case \"array\":\n return actionPropertyToSdkPropertyDefinition(parameterType.subType);\n }\n}\nfunction createModifiedEntities(addedObjects, modifiedObjects) {\n let entities = {};\n for (const key of addedObjects) {\n entities[key] = { created: true, modified: false };\n }\n for (const key of modifiedObjects) {\n if (entities[key]) {\n entities[key].modified = true;\n }\n else {\n entities[key] = { created: false, modified: true };\n }\n }\n return entities;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAsB,QAAQ,wBAAwB;AAC/D,OAAO,SAASC,mCAAmCA,CAACC,KAAK,EAAE;EACvD,MAAMC,mBAAmB,GAAGH,sBAAsB,CAACE,KAAK,CAAC;EACzD,OAAO;IACHE,IAAI,EAAE,QAAQ;IACdC,OAAO,EAAEH,KAAK,CAACG,OAAO;IACtBC,UAAU,EAAEC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACP,KAAK,CAACI,UAAU,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,CAACD,GAAG,EAAEE,6CAA6C,CAACD,KAAK,CAAC,CAAC,CAAC,CAAC;IACnJE,WAAW,EAAEZ,KAAK,CAACY,WAAW;IAC9BC,WAAW,EAAEb,KAAK,CAACa,WAAW;IAC9BC,gBAAgB,EAAEC,sBAAsB,CAACd,mBAAmB,CAACe,YAAY,EAAEf,mBAAmB,CAACgB,eAAe,CAAC;IAC/GC,GAAG,EAAElB,KAAK,CAACkB,GAAG;IACdC,MAAM,EAAEnB,KAAK,CAACmB;EAClB,CAAC;AACL;AACA,SAASR,6CAA6CA,CAACD,KAAK,EAAE;EAC1D,OAAO;IACHU,YAAY,EAAEV,KAAK,CAACW,QAAQ,CAACnB,IAAI,KAAK,OAAO;IAC7CA,IAAI,EAAEoB,qCAAqC,CAACZ,KAAK,CAACW,QAAQ,CAACnB,IAAI,KAAK,OAAO,GAAGQ,KAAK,CAACW,QAAQ,CAACE,OAAO,GAAGb,KAAK,CAACW,QAAQ,CAAC;IACtHG,QAAQ,EAAE,CAACd,KAAK,CAACe,QAAQ;IACzBZ,WAAW,EAAEH,KAAK,CAACG;EACvB,CAAC;AACL;AACA,SAASS,qCAAqCA,CAACI,aAAa,EAAE;EAC1D,QAAQA,aAAa,CAACxB,IAAI;IACtB,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,YAAY;IACjB,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,WAAW;IAChB,KAAK,SAAS;MACV,OAAOwB,aAAa,CAACxB,IAAI;IAC7B,KAAK,MAAM;MACP,OAAO,UAAU;IACrB,KAAK,WAAW;MACZ,OAAO;QAAEA,IAAI,EAAE,WAAW;QAAEyB,SAAS,EAAED,aAAa,CAACE;MAAkB,CAAC;IAC5E,KAAK,QAAQ;MACT,OAAO;QAAE1B,IAAI,EAAE,QAAQ;QAAE2B,MAAM,EAAEH,aAAa,CAACE;MAAkB,CAAC;IACtE,KAAK,OAAO;MACR,OAAON,qCAAqC,CAACI,aAAa,CAACH,OAAO,CAAC;EAC3E;AACJ;AACA,SAASR,sBAAsBA,CAACC,YAAY,EAAEC,eAAe,EAAE;EAC3D,IAAIa,QAAQ,GAAG,CAAC,CAAC;EACjB,KAAK,MAAMrB,GAAG,IAAIO,YAAY,EAAE;IAC5Bc,QAAQ,CAACrB,GAAG,CAAC,GAAG;MAAEsB,OAAO,EAAE,IAAI;MAAEC,QAAQ,EAAE;IAAM,CAAC;EACtD;EACA,KAAK,MAAMvB,GAAG,IAAIQ,eAAe,EAAE;IAC/B,IAAIa,QAAQ,CAACrB,GAAG,CAAC,EAAE;MACfqB,QAAQ,CAACrB,GAAG,CAAC,CAACuB,QAAQ,GAAG,IAAI;IACjC,CAAC,MACI;MACDF,QAAQ,CAACrB,GAAG,CAAC,GAAG;QAAEsB,OAAO,EAAE,KAAK;QAAEC,QAAQ,EAAE;MAAK,CAAC;IACtD;EACJ;EACA,OAAOF,QAAQ;AACnB","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { ObjectMetadata } from "@osdk/api";
2
+ import type { ObjectTypeFullMetadata, PropertyApiName, PropertyV2 } from "@osdk/internal.foundry.core";
3
+ export declare function wireObjectTypeFullMetadataToSdkObjectMetadata(objectTypeWithLink: ObjectTypeFullMetadata & {
4
+ objectType: {
5
+ properties: Record<PropertyApiName, PropertyV2 & {
6
+ nullable?: boolean;
7
+ }>;
8
+ };
9
+ }, v2: boolean): ObjectMetadata;
10
+ //# sourceMappingURL=wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts","sourceRoot":"","sources":["../../src/wireObjectTypeFullMetadataToSdkObjectMetadata.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAEV,sBAAsB,EACtB,eAAe,EACf,UAAU,EACX,MAAM,6BAA6B,CAAC;AAIrC,wBAAgB,6CAA6C,CAC3D,kBAAkB,EAAE,sBAAsB,GAAG;IAC3C,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC,eAAe,EAAE,UAAU,GAAG;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;KAC1E,CAAC;CACH,EACD,EAAE,EAAE,OAAO,GACV,cAAc,CAuEhB"}
@@ -0,0 +1,56 @@
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
+ import { wirePropertyV2ToSdkPrimaryKeyTypeDefinition } from "./wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js";
17
+ import { wirePropertyV2ToSdkPropertyDefinition } from "./wirePropertyV2ToSdkPropertyDefinition.js";
18
+ export function wireObjectTypeFullMetadataToSdkObjectMetadata(objectTypeWithLink, v2) {
19
+ if (objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey] === undefined) {
20
+ throw new Error(`Primary key ${objectTypeWithLink.objectType.primaryKey} not found in ${objectTypeWithLink.objectType.apiName}`);
21
+ }
22
+ // saved ontology.json files may not have this implementsInterfaces2 so we need to handle
23
+ if (objectTypeWithLink.implementsInterfaces2 == null && objectTypeWithLink.implementsInterfaces != null) {
24
+ throw new Error("Your ontology.json file is missing the implementsInterfaces2 field. Please regenerate it.");
25
+ }
26
+ const interfaceMap = objectTypeWithLink.implementsInterfaces2 ? Object.fromEntries(Object.entries(objectTypeWithLink.implementsInterfaces2).map(([interfaceApiName, impl]) => [interfaceApiName, impl.properties])) : {};
27
+ return {
28
+ type: "object",
29
+ apiName: objectTypeWithLink.objectType.apiName,
30
+ description: objectTypeWithLink.objectType.description,
31
+ primaryKeyApiName: objectTypeWithLink.objectType.primaryKey,
32
+ primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey]),
33
+ links: Object.fromEntries(objectTypeWithLink.linkTypes.map(linkType => {
34
+ return [linkType.apiName, {
35
+ multiplicity: linkType.cardinality === "MANY",
36
+ targetType: linkType.objectTypeApiName
37
+ }];
38
+ })),
39
+ properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key))])),
40
+ implements: objectTypeWithLink.implementsInterfaces,
41
+ interfaceMap,
42
+ inverseInterfaceMap: Object.fromEntries(Object.entries(interfaceMap).map(([interfaceApiName, props]) => [interfaceApiName, invertProps(props)])),
43
+ icon: supportedIconTypes.includes(objectTypeWithLink.objectType.icon.type) ? objectTypeWithLink.objectType.icon : undefined,
44
+ titleProperty: objectTypeWithLink.objectType.titleProperty,
45
+ displayName: objectTypeWithLink.objectType.displayName,
46
+ pluralDisplayName: objectTypeWithLink.objectType.pluralDisplayName,
47
+ status: objectTypeWithLink.objectType.status,
48
+ rid: objectTypeWithLink.objectType.rid,
49
+ visibility: objectTypeWithLink.objectType.visibility
50
+ };
51
+ }
52
+ function invertProps(a) {
53
+ return a ? Object.fromEntries(Object.entries(a).map(([k, v]) => [v, k])) : undefined;
54
+ }
55
+ const supportedIconTypes = ["blueprint"];
56
+ //# sourceMappingURL=wireObjectTypeFullMetadataToSdkObjectMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.js","names":["wirePropertyV2ToSdkPrimaryKeyTypeDefinition","wirePropertyV2ToSdkPropertyDefinition","wireObjectTypeFullMetadataToSdkObjectMetadata","objectTypeWithLink","v2","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","implements","inverseInterfaceMap","props","invertProps","icon","supportedIconTypes","includes","titleProperty","displayName","pluralDisplayName","status","rid","visibility","a","k","v"],"sources":["wireObjectTypeFullMetadataToSdkObjectMetadata.js"],"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 */\nimport { wirePropertyV2ToSdkPrimaryKeyTypeDefinition } from \"./wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js\";\nimport { wirePropertyV2ToSdkPropertyDefinition } from \"./wirePropertyV2ToSdkPropertyDefinition.js\";\nexport function wireObjectTypeFullMetadataToSdkObjectMetadata(objectTypeWithLink, v2) {\n if (objectTypeWithLink.objectType\n .properties[objectTypeWithLink.objectType.primaryKey] === undefined) {\n throw new Error(`Primary key ${objectTypeWithLink.objectType.primaryKey} not found in ${objectTypeWithLink.objectType.apiName}`);\n }\n // saved ontology.json files may not have this implementsInterfaces2 so we need to handle\n if (objectTypeWithLink.implementsInterfaces2 == null\n && objectTypeWithLink.implementsInterfaces != null) {\n throw new Error(\"Your ontology.json file is missing the implementsInterfaces2 field. Please regenerate it.\");\n }\n const interfaceMap = objectTypeWithLink.implementsInterfaces2\n ? Object.fromEntries(Object.entries(objectTypeWithLink.implementsInterfaces2).map(([interfaceApiName, impl]) => [interfaceApiName, impl.properties]))\n : {};\n return {\n type: \"object\",\n apiName: objectTypeWithLink.objectType.apiName,\n description: objectTypeWithLink.objectType.description,\n primaryKeyApiName: objectTypeWithLink.objectType.primaryKey,\n primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(objectTypeWithLink.objectType\n .properties[objectTypeWithLink.objectType.primaryKey]),\n links: Object.fromEntries(objectTypeWithLink.linkTypes.map(linkType => {\n return [linkType.apiName, {\n multiplicity: linkType.cardinality === \"MANY\",\n targetType: linkType.objectTypeApiName,\n }];\n })),\n properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [\n key,\n wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key)),\n ])),\n implements: objectTypeWithLink.implementsInterfaces,\n interfaceMap,\n inverseInterfaceMap: Object.fromEntries(Object.entries(interfaceMap).map(([interfaceApiName, props]) => [interfaceApiName, invertProps(props)])),\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: objectTypeWithLink.objectType.status,\n rid: objectTypeWithLink.objectType.rid,\n visibility: objectTypeWithLink.objectType.visibility,\n };\n}\nfunction invertProps(a) {\n return (a\n ? Object.fromEntries(Object.entries(a).map(([k, v]) => [v, k]))\n : undefined);\n}\nconst supportedIconTypes = [\"blueprint\"];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,2CAA2C,QAAQ,kDAAkD;AAC9G,SAASC,qCAAqC,QAAQ,4CAA4C;AAClG,OAAO,SAASC,6CAA6CA,CAACC,kBAAkB,EAAEC,EAAE,EAAE;EAClF,IAAID,kBAAkB,CAACE,UAAU,CAC5BC,UAAU,CAACH,kBAAkB,CAACE,UAAU,CAACE,UAAU,CAAC,KAAKC,SAAS,EAAE;IACrE,MAAM,IAAIC,KAAK,CAAC,eAAeN,kBAAkB,CAACE,UAAU,CAACE,UAAU,iBAAiBJ,kBAAkB,CAACE,UAAU,CAACK,OAAO,EAAE,CAAC;EACpI;EACA;EACA,IAAIP,kBAAkB,CAACQ,qBAAqB,IAAI,IAAI,IAC7CR,kBAAkB,CAACS,oBAAoB,IAAI,IAAI,EAAE;IACpD,MAAM,IAAIH,KAAK,CAAC,2FAA2F,CAAC;EAChH;EACA,MAAMI,YAAY,GAAGV,kBAAkB,CAACQ,qBAAqB,GACvDG,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACb,kBAAkB,CAACQ,qBAAqB,CAAC,CAACM,GAAG,CAAC,CAAC,CAACC,gBAAgB,EAAEC,IAAI,CAAC,KAAK,CAACD,gBAAgB,EAAEC,IAAI,CAACb,UAAU,CAAC,CAAC,CAAC,GACnJ,CAAC,CAAC;EACR,OAAO;IACHc,IAAI,EAAE,QAAQ;IACdV,OAAO,EAAEP,kBAAkB,CAACE,UAAU,CAACK,OAAO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AACgC,IAAI,GAClC7B,SAAS;IACfgC,aAAa,EAAErC,kBAAkB,CAACE,UAAU,CAACmC,aAAa;IAC1DC,WAAW,EAAEtC,kBAAkB,CAACE,UAAU,CAACoC,WAAW;IACtDC,iBAAiB,EAAEvC,kBAAkB,CAACE,UAAU,CAACqC,iBAAiB;IAClEC,MAAM,EAAExC,kBAAkB,CAACE,UAAU,CAACsC,MAAM;IAC5CC,GAAG,EAAEzC,kBAAkB,CAACE,UAAU,CAACuC,GAAG;IACtCC,UAAU,EAAE1C,kBAAkB,CAACE,UAAU,CAACwC;EAC9C,CAAC;AACL;AACA,SAAST,WAAWA,CAACU,CAAC,EAAE;EACpB,OAAQA,CAAC,GACHhC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAAC8B,CAAC,CAAC,CAAC7B,GAAG,CAAC,CAAC,CAAC8B,CAAC,EAAEC,CAAC,CAAC,KAAK,CAACA,CAAC,EAAED,CAAC,CAAC,CAAC,CAAC,GAC7DvC,SAAS;AACnB;AACA,MAAM8B,kBAAkB,GAAG,CAAC,WAAW,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wireObjectTypeFullMetadataToSdkObjectMetadata.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.test.d.ts","sourceRoot":"","sources":["../../src/wireObjectTypeFullMetadataToSdkObjectMetadata.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
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
+ import { describe, expect, it } from "vitest";
17
+ import { wireObjectTypeFullMetadataToSdkObjectMetadata } from "./wireObjectTypeFullMetadataToSdkObjectMetadata.js";
18
+ describe(wireObjectTypeFullMetadataToSdkObjectMetadata, () => {
19
+ it("handles magic nullable properties", () => {
20
+ const result = wireObjectTypeFullMetadataToSdkObjectMetadata({
21
+ implementsInterfaces: [],
22
+ implementsInterfaces2: {},
23
+ linkTypes: [],
24
+ objectType: {
25
+ apiName: "apiName",
26
+ description: "description",
27
+ displayName: "displayName",
28
+ pluralDisplayName: "displayNames",
29
+ icon: {
30
+ type: "blueprint",
31
+ name: "blueprint",
32
+ color: "blue"
33
+ },
34
+ primaryKey: "primaryKey",
35
+ properties: {
36
+ primaryKey: {
37
+ dataType: {
38
+ type: "string"
39
+ }
40
+ },
41
+ otherKey: {
42
+ nullable: false,
43
+ dataType: {
44
+ type: "string"
45
+ }
46
+ },
47
+ defaulted: {
48
+ dataType: {
49
+ type: "string"
50
+ }
51
+ }
52
+ },
53
+ rid: "rid",
54
+ status: "ACTIVE",
55
+ titleProperty: "otherKey"
56
+ },
57
+ sharedPropertyTypeMapping: {}
58
+ }, true);
59
+ // PK is never nullable
60
+ expect(result.properties["primaryKey"].nullable).toBe(false);
61
+ // was specified above
62
+ expect(result.properties["otherKey"].nullable).toBe(false);
63
+ // was unspecified, so should be nullable
64
+ expect(result.properties["defaulted"].nullable).toBe(true);
65
+ });
66
+ });
67
+ //# sourceMappingURL=wireObjectTypeFullMetadataToSdkObjectMetadata.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireObjectTypeFullMetadataToSdkObjectMetadata.test.js","names":["describe","expect","it","wireObjectTypeFullMetadataToSdkObjectMetadata","result","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","apiName","description","displayName","pluralDisplayName","icon","type","name","color","primaryKey","properties","dataType","otherKey","nullable","defaulted","rid","status","titleProperty","sharedPropertyTypeMapping","toBe"],"sources":["wireObjectTypeFullMetadataToSdkObjectMetadata.test.js"],"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 */\nimport { describe, expect, it } from \"vitest\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"./wireObjectTypeFullMetadataToSdkObjectMetadata.js\";\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\" } },\n otherKey: { nullable: false, dataType: { type: \"string\" } },\n defaulted: { dataType: { type: \"string\" } },\n },\n rid: \"rid\",\n status: \"ACTIVE\",\n titleProperty: \"otherKey\",\n },\n sharedPropertyTypeMapping: {},\n }, true);\n // PK is never nullable\n expect(result.properties[\"primaryKey\"].nullable).toBe(false);\n // was specified above\n expect(result.properties[\"otherKey\"].nullable).toBe(false);\n // was unspecified, so should be nullable\n expect(result.properties[\"defaulted\"].nullable).toBe(true);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QA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AAC,CAACM,IAAI,CAAC,IAAI,CAAC;EAC9D,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts","sourceRoot":"","sources":["../../src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,wBAAgB,2CAA2C,CACzD,KAAK,EAAE,UAAU,GAChB,eAAe,CAkCjB"}
1
+ {"version":3,"file":"wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts","sourceRoot":"","sources":["../../src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,wBAAgB,2CAA2C,CACzD,KAAK,EAAE,UAAU,GAChB,eAAe,CAmCjB"}
@@ -0,0 +1,51 @@
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
+ export function wirePropertyV2ToSdkPrimaryKeyTypeDefinition(input) {
17
+ switch (input.dataType.type) {
18
+ case "integer":
19
+ case "double":
20
+ case "string":
21
+ case "boolean":
22
+ case "byte":
23
+ case "long":
24
+ case "short":
25
+ {
26
+ return input.dataType.type;
27
+ }
28
+ case "date":
29
+ {
30
+ return "datetime";
31
+ }
32
+ case "timestamp":
33
+ {
34
+ return "timestamp";
35
+ }
36
+ case "geopoint":
37
+ case "geoshape":
38
+ case "decimal":
39
+ case "attachment":
40
+ case "timeseries":
41
+ case "array":
42
+ case "marking":
43
+ case "float":
44
+ case "geotimeSeriesReference":
45
+ throw new Error(`Type not supported for primaryKey: ${input.dataType.type}`);
46
+ default:
47
+ input.dataType;
48
+ throw new Error(`Unknown type encountered for primaryKey: ${input.dataType}`);
49
+ }
50
+ }
51
+ //# sourceMappingURL=wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js","names":["wirePropertyV2ToSdkPrimaryKeyTypeDefinition","input","dataType","type","Error"],"sources":["wirePropertyV2ToSdkPrimaryKeyTypeDefinition.js"],"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 */\nexport function wirePropertyV2ToSdkPrimaryKeyTypeDefinition(input) {\n switch (input.dataType.type) {\n case \"integer\":\n case \"double\":\n case \"string\":\n case \"boolean\":\n case \"byte\":\n case \"long\":\n case \"short\": {\n return input.dataType.type;\n }\n case \"date\": {\n return \"datetime\";\n }\n case \"timestamp\": {\n return \"timestamp\";\n }\n case \"geopoint\":\n case \"geoshape\":\n case \"decimal\":\n case \"attachment\":\n case \"timeseries\":\n case \"array\":\n case \"marking\":\n case \"float\":\n case \"geotimeSeriesReference\":\n throw new Error(`Type not supported for primaryKey: ${input.dataType.type}`);\n default:\n const _ = input.dataType;\n throw new Error(`Unknown type encountered for primaryKey: ${input.dataType}`);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,2CAA2CA,CAACC,KAAK,EAAE;EAC/D,QAAQA,KAAK,CAACC,QAAQ,CAACC,IAAI;IACvB,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,OAAO;MAAE;QACV,OAAOF,KAAK,CAACC,QAAQ,CAACC,IAAI;MAC9B;IACA,KAAK,MAAM;MAAE;QACT,OAAO,UAAU;MACrB;IACA,KAAK,WAAW;MAAE;QACd,OAAO,WAAW;MACtB;IACA,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,SAAS;IACd,KAAK,YAAY;IACjB,KAAK,YAAY;IACjB,KAAK,OAAO;IACZ,KAAK,SAAS;IACd,KAAK,OAAO;IACZ,KAAK,wBAAwB;MACzB,MAAM,IAAIC,KAAK,CAAC,sCAAsCH,KAAK,CAACC,QAAQ,CAACC,IAAI,EAAE,CAAC;IAChF;MACcF,KAAK,CAACC,QAAQ;MACxB,MAAM,IAAIE,KAAK,CAAC,4CAA4CH,KAAK,CAACC,QAAQ,EAAE,CAAC;EACrF;AACJ","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import type { ObjectTypePropertyDefinition } from "@osdk/api";
1
+ import type { ObjectMetadata } from "@osdk/api";
2
2
  import type { PropertyV2, SharedPropertyType } from "@osdk/internal.foundry.core";
3
3
  export declare function wirePropertyV2ToSdkPropertyDefinition(input: (PropertyV2 | SharedPropertyType) & {
4
4
  nullable?: boolean;
5
- }, isNullable?: boolean): ObjectTypePropertyDefinition;
5
+ }, isNullable?: boolean): ObjectMetadata.Property;
6
6
  //# sourceMappingURL=wirePropertyV2ToSdkPropertyDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirePropertyV2ToSdkPropertyDefinition.d.ts","sourceRoot":"","sources":["../../src/wirePropertyV2ToSdkPropertyDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAEV,UAAU,EACV,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAErC,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,CAAC,UAAU,GAAG,kBAAkB,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,EACjE,UAAU,GAAE,OAAc,GACzB,cAAc,CAAC,QAAQ,CA6CzB"}
@@ -0,0 +1,90 @@
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
+ export function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true) {
17
+ switch (input.dataType.type) {
18
+ case "integer":
19
+ case "string":
20
+ case "byte":
21
+ case "decimal":
22
+ case "double":
23
+ case "float":
24
+ case "long":
25
+ case "short":
26
+ case "boolean":
27
+ case "date":
28
+ case "attachment":
29
+ case "geopoint":
30
+ case "geoshape":
31
+ case "timestamp":
32
+ case "timeseries":
33
+ case "marking":
34
+ return {
35
+ displayName: input.displayName,
36
+ multiplicity: false,
37
+ description: input.description,
38
+ type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),
39
+ nullable: input.nullable == null ? isNullable : input.nullable
40
+ };
41
+ case "array":
42
+ {
43
+ return {
44
+ displayName: input.displayName,
45
+ multiplicity: true,
46
+ description: input.description,
47
+ type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),
48
+ nullable: true
49
+ };
50
+ }
51
+ case "geotimeSeriesReference":
52
+ throw new Error(`Unsupported data type ${JSON.stringify(input.dataType)}`);
53
+ default:
54
+ input.dataType;
55
+ throw new Error(`Unexpected data type ${JSON.stringify(input.dataType)}`);
56
+ }
57
+ }
58
+ function objectPropertyTypeToSdkPropertyDefinition(propertyType) {
59
+ switch (propertyType.type) {
60
+ case "integer":
61
+ case "string":
62
+ case "byte":
63
+ case "decimal":
64
+ case "double":
65
+ case "float":
66
+ case "long":
67
+ case "short":
68
+ case "boolean":
69
+ case "attachment":
70
+ case "geopoint":
71
+ case "geoshape":
72
+ case "timestamp":
73
+ case "marking":
74
+ return propertyType.type;
75
+ case "date":
76
+ return "datetime";
77
+ case "array":
78
+ return objectPropertyTypeToSdkPropertyDefinition(propertyType.subType);
79
+ case "timeseries":
80
+ if (propertyType.itemType.type === "string") {
81
+ return "stringTimeseries";
82
+ }
83
+ return "numericTimeseries";
84
+ case "geotimeSeriesReference":
85
+ throw new Error(`Unsupported data type ${JSON.stringify(propertyType)}`);
86
+ default:
87
+ throw new Error(`Unexpected data type ${JSON.stringify(propertyType)}`);
88
+ }
89
+ }
90
+ //# sourceMappingURL=wirePropertyV2ToSdkPropertyDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirePropertyV2ToSdkPropertyDefinition.js","names":["wirePropertyV2ToSdkPropertyDefinition","input","isNullable","dataType","type","displayName","multiplicity","description","objectPropertyTypeToSdkPropertyDefinition","nullable","Error","JSON","stringify","propertyType","subType","itemType"],"sources":["wirePropertyV2ToSdkPropertyDefinition.js"],"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 */\nexport function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true) {\n switch (input.dataType.type) {\n case \"integer\":\n case \"string\":\n case \"byte\":\n case \"decimal\":\n case \"double\":\n case \"float\":\n case \"long\":\n case \"short\":\n case \"boolean\":\n case \"date\":\n case \"attachment\":\n case \"geopoint\":\n case \"geoshape\":\n case \"timestamp\":\n case \"timeseries\":\n case \"marking\":\n return {\n displayName: input.displayName,\n multiplicity: false,\n description: input.description,\n type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),\n nullable: input.nullable == null ? isNullable : input.nullable,\n };\n case \"array\": {\n return {\n displayName: input.displayName,\n multiplicity: true,\n description: input.description,\n type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),\n nullable: true,\n };\n }\n case \"geotimeSeriesReference\":\n throw new Error(`Unsupported data type ${JSON.stringify(input.dataType)}`);\n default:\n const _ = input.dataType;\n throw new Error(`Unexpected data type ${JSON.stringify(input.dataType)}`);\n }\n}\nfunction objectPropertyTypeToSdkPropertyDefinition(propertyType) {\n switch (propertyType.type) {\n case \"integer\":\n case \"string\":\n case \"byte\":\n case \"decimal\":\n case \"double\":\n case \"float\":\n case \"long\":\n case \"short\":\n case \"boolean\":\n case \"attachment\":\n case \"geopoint\":\n case \"geoshape\":\n case \"timestamp\":\n case \"marking\":\n return propertyType.type;\n case \"date\":\n return \"datetime\";\n case \"array\":\n return objectPropertyTypeToSdkPropertyDefinition(propertyType.subType);\n case \"timeseries\":\n if (propertyType.itemType.type === \"string\") {\n return \"stringTimeseries\";\n }\n return \"numericTimeseries\";\n case \"geotimeSeriesReference\":\n throw new Error(`Unsupported data type ${JSON.stringify(propertyType)}`);\n default:\n const _ = propertyType;\n throw new Error(`Unexpected data type ${JSON.stringify(propertyType)}`);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qCAAqCA,CAACC,KAAK,EAAEC,UAAU,GAAG,IAAI,EAAE;EAC5E,QAAQD,KAAK,CAACE,QAAQ,CAACC,IAAI;IACvB,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,MAAM;IACX,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,OAAO;IACZ,KAAK,MAAM;IACX,KAAK,OAAO;IACZ,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,YAAY;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,WAAW;IAChB,KAAK,YAAY;IACjB,KAAK,SAAS;MACV,OAAO;QACHC,WAAW,EAAEJ,KAAK,CAACI,WAAW;QAC9BC,YAAY,EAAE,KAAK;QACnBC,WAAW,EAAEN,KAAK,CAACM,WAAW;QAC9BH,IAAI,EAAEI,yCAAyC,CAACP,KAAK,CAACE,QAAQ,CAAC;QAC/DM,QAAQ,EAAER,KAAK,CAACQ,QAAQ,IAAI,IAAI,GAAGP,UAAU,GAAGD,KAAK,CAACQ;MAC1D,CAAC;IACL,KAAK,OAAO;MAAE;QACV,OAAO;UACHJ,WAAW,EAAEJ,KAAK,CAACI,WAAW;UAC9BC,YAAY,EAAE,IAAI;UAClBC,WAAW,EAAEN,KAAK,CAACM,WAAW;UAC9BH,IAAI,EAAEI,yCAAyC,CAACP,KAAK,CAACE,QAAQ,CAAC;UAC/DM,QAAQ,EAAE;QACd,CAAC;MACL;IACA,KAAK,wBAAwB;MACzB,MAAM,IAAIC,KAAK,CAAC,yBAAyBC,IAAI,CAACC,SAAS,CAACX,KAAK,CAACE,QAAQ,CAAC,EAAE,CAAC;IAC9E;MACcF,KAAK,CAACE,QAAQ;MACxB,MAAM,IAAIO,KAAK,CAAC,wBAAwBC,IAAI,CAACC,SAAS,CAACX,KAAK,CAACE,QAAQ,CAAC,EAAE,CAAC;EACjF;AACJ;AACA,SAASK,yCAAyCA,CAACK,YAAY,EAAE;EAC7D,QAAQA,YAAY,CAACT,IAAI;IACrB,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,MAAM;IACX,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,OAAO;IACZ,KAAK,MAAM;IACX,KAAK,OAAO;IACZ,KAAK,SAAS;IACd,KAAK,YAAY;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,WAAW;IAChB,KAAK,SAAS;MACV,OAAOS,YAAY,CAACT,IAAI;IAC5B,KAAK,MAAM;MACP,OAAO,UAAU;IACrB,KAAK,OAAO;MACR,OAAOI,yCAAyC,CAACK,YAAY,CAACC,OAAO,CAAC;IAC1E,KAAK,YAAY;MACb,IAAID,YAAY,CAACE,QAAQ,CAACX,IAAI,KAAK,QAAQ,EAAE;QACzC,OAAO,kBAAkB;MAC7B;MACA,OAAO,mBAAmB;IAC9B,KAAK,wBAAwB;MACzB,MAAM,IAAIM,KAAK,CAAC,yBAAyBC,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,EAAE,CAAC;IAC5E;MAEI,MAAM,IAAIH,KAAK,CAAC,wBAAwBC,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,EAAE,CAAC;EAC/E;AACJ","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { QueryDataTypeDefinition } from "@osdk/api";
2
+ import type { QueryDataType } from "@osdk/internal.foundry.core";
3
+ export declare function wireQueryDataTypeToQueryDataTypeDefinition<K extends string>(input: QueryDataType): QueryDataTypeDefinition;
4
+ //# sourceMappingURL=wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireQueryDataTypeToQueryDataTypeDefinition.d.ts","sourceRoot":"","sources":["../../src/wireQueryDataTypeToQueryDataTypeDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,6BAA6B,CAAC;AAGrC,wBAAgB,0CAA0C,CACxD,CAAC,SAAS,MAAM,EAEhB,KAAK,EAAE,aAAa,GACnB,uBAAuB,CAuGzB"}
@@ -0,0 +1,143 @@
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
+ import { isNullableQueryDataType } from "./isNullableQueryDataType.js";
17
+ export function wireQueryDataTypeToQueryDataTypeDefinition(input) {
18
+ switch (input.type) {
19
+ case "double":
20
+ case "float":
21
+ case "integer":
22
+ case "long":
23
+ case "attachment":
24
+ case "boolean":
25
+ case "date":
26
+ case "string":
27
+ case "timestamp":
28
+ return {
29
+ type: input.type,
30
+ nullable: false
31
+ };
32
+ case "object":
33
+ return {
34
+ type: "object",
35
+ object: input.objectTypeApiName,
36
+ nullable: false
37
+ };
38
+ case "objectSet":
39
+ return {
40
+ type: "objectSet",
41
+ objectSet: input.objectTypeApiName,
42
+ nullable: false
43
+ };
44
+ case "array":
45
+ return {
46
+ ...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
47
+ multiplicity: true
48
+ };
49
+ case "set":
50
+ return {
51
+ type: "set",
52
+ set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
53
+ nullable: false
54
+ };
55
+ case "union":
56
+ const allowNulls = isNullableQueryDataType(input);
57
+ // special case for a union where one half is nullable to skip the union step and just allow nulls directly
58
+ if (allowNulls && input.unionTypes.length === 2) {
59
+ const nonNull = input.unionTypes.find(t => t.type != null);
60
+ if (nonNull) {
61
+ return {
62
+ ...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
63
+ nullable: true
64
+ };
65
+ }
66
+ }
67
+ return {
68
+ type: "union",
69
+ union: input.unionTypes.reduce((acc, t) => {
70
+ if (t.type === "null") {
71
+ return acc;
72
+ }
73
+ acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));
74
+ return acc;
75
+ }, []),
76
+ nullable: allowNulls
77
+ };
78
+ case "struct":
79
+ return {
80
+ type: "struct",
81
+ struct: Object.fromEntries(input.fields.map(f => [f.name, wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType)])),
82
+ nullable: false
83
+ };
84
+ case "twoDimensionalAggregation":
85
+ return {
86
+ type: "twoDimensionalAggregation",
87
+ twoDimensionalAggregation: get2DQueryAggregationProps(input),
88
+ nullable: false
89
+ };
90
+ case "threeDimensionalAggregation":
91
+ return {
92
+ type: "threeDimensionalAggregation",
93
+ threeDimensionalAggregation: get3DQueryAggregationProps(input),
94
+ nullable: false
95
+ };
96
+ case "null":
97
+ case "unsupported":
98
+ throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);
99
+ default:
100
+ throw new Error(`Unsupported QueryDataType.type ${input.type}`);
101
+ }
102
+ }
103
+ function get2DQueryAggregationProps(input) {
104
+ if (input.keyType.type === "range") {
105
+ return {
106
+ keyType: input.keyType.type,
107
+ keySubtype: input.keyType.subType.type,
108
+ valueType: input.valueType.type
109
+ };
110
+ } else {
111
+ if (guardInvalidKeyTypes(input.keyType)) {
112
+ return {
113
+ keyType: input.keyType.type,
114
+ valueType: input.valueType.type
115
+ };
116
+ }
117
+ throw new Error(`Cannot create 2D aggregation with ${input.keyType.type} as its type`);
118
+ }
119
+ }
120
+ function get3DQueryAggregationProps(input) {
121
+ if (input.keyType.type === "range") {
122
+ return {
123
+ keyType: input.keyType.type,
124
+ keySubtype: input.keyType.subType.type,
125
+ valueType: get2DQueryAggregationProps(input.valueType)
126
+ };
127
+ } else {
128
+ if (guardInvalidKeyTypes(input.keyType)) {
129
+ return {
130
+ keyType: input.keyType.type,
131
+ valueType: get2DQueryAggregationProps(input.valueType)
132
+ };
133
+ }
134
+ throw new Error(`Cannot create 3D aggregation with ${input.keyType.type} as its type`);
135
+ }
136
+ }
137
+ /**
138
+ * Guard against aggregation key types that are allowed by the backend types but are illegal to actually use
139
+ */
140
+ function guardInvalidKeyTypes(key) {
141
+ return key.type === "string" || key.type === "boolean";
142
+ }
143
+ //# sourceMappingURL=wireQueryDataTypeToQueryDataTypeDefinition.js.map
@@ -0,0 +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","Error","keyType","keySubtype","valueType","guardInvalidKeyTypes","key"],"sources":["wireQueryDataTypeToQueryDataTypeDefinition.js"],"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 */\nimport { isNullableQueryDataType } from \"./isNullableQueryDataType.js\";\nexport function wireQueryDataTypeToQueryDataTypeDefinition(input) {\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 case \"object\":\n return {\n type: \"object\",\n object: input.objectTypeApiName,\n nullable: false,\n };\n case \"objectSet\":\n return {\n type: \"objectSet\",\n objectSet: input.objectTypeApiName,\n nullable: false,\n };\n case \"array\":\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n multiplicity: true,\n };\n case \"set\":\n return {\n type: \"set\",\n set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n nullable: false,\n };\n case \"union\":\n const allowNulls = isNullableQueryDataType(input);\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 return {\n type: \"union\",\n union: input.unionTypes.reduce((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 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 case \"twoDimensionalAggregation\":\n return {\n type: \"twoDimensionalAggregation\",\n twoDimensionalAggregation: get2DQueryAggregationProps(input),\n nullable: false,\n };\n case \"threeDimensionalAggregation\":\n return {\n type: \"threeDimensionalAggregation\",\n threeDimensionalAggregation: get3DQueryAggregationProps(input),\n nullable: false,\n };\n case \"null\":\n case \"unsupported\":\n throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);\n default:\n const _ = input;\n throw new Error(`Unsupported QueryDataType.type ${input.type}`);\n }\n}\nfunction get2DQueryAggregationProps(input) {\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 }\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(`Cannot create 2D aggregation with ${input.keyType.type} as its type`);\n }\n}\nfunction get3DQueryAggregationProps(input) {\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 }\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(`Cannot create 3D aggregation with ${input.keyType.type} as its type`);\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(key) {\n return key.type === \"string\" || key.type === \"boolean\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAuB,QAAQ,8BAA8B;AACtE,OAAO,SAASC,0CAA0CA,CAACC,KAAK,EAAE;EAC9D,QAAQA,KAAK,CAACC,IAAI;IACd,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;MACZ,OAAO;QACHA,IAAI,EAAED,KAAK,CAACC,IAAI;QAChBC,QAAQ,EAAE;MACd,CAAC;IACL,KAAK,QAAQ;MACT,OAAO;QACHD,IAAI,EAAE,QAAQ;QACdE,MAAM,EAAEH,KAAK,CAACI,iBAAiB;QAC/BF,QAAQ,EAAE;MACd,CAAC;IACL,KAAK,WAAW;MACZ,OAAO;QACHD,IAAI,EAAE,WAAW;QACjBI,SAAS,EAAEL,KAAK,CAACI,iBAAiB;QAClCF,QAAQ,EAAE;MACd,C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