@osdk/api 2.2.0-beta.8 → 2.3.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/build/browser/Logger.js +17 -0
  3. package/build/browser/Logger.js.map +1 -0
  4. package/build/browser/OsdkBase.js.map +1 -1
  5. package/build/browser/OsdkObjectFrom.js +2 -4
  6. package/build/browser/OsdkObjectFrom.js.map +1 -1
  7. package/build/browser/OsdkObjectFrom.test.js +3 -3
  8. package/build/browser/OsdkObjectFrom.test.js.map +1 -1
  9. package/build/browser/actions/Actions.js.map +1 -1
  10. package/build/browser/aggregate/AggregatableKeys.js.map +1 -1
  11. package/build/browser/derivedProperties/DerivedProperty.js.map +1 -1
  12. package/build/browser/derivedProperties/Expressions.js +2 -0
  13. package/build/browser/derivedProperties/Expressions.js.map +1 -0
  14. package/build/browser/derivedProperties/WithPropertiesAggregationOptions.js.map +1 -1
  15. package/build/browser/experimental/createMediaReference.js.map +1 -1
  16. package/build/browser/experimental/fetchPageByRid.js.map +1 -1
  17. package/build/browser/index.js.map +1 -1
  18. package/build/browser/mapping/DataValueMapping.js.map +1 -1
  19. package/build/browser/object/FetchPageArgs.js +1 -0
  20. package/build/browser/object/FetchPageArgs.js.map +1 -1
  21. package/build/browser/object/FetchPageResult.js.map +1 -1
  22. package/build/browser/objectSet/BulkLinkResult.js.map +1 -1
  23. package/build/browser/objectSet/ObjectSet.js.map +1 -1
  24. package/build/browser/objectSet/ObjectSet.test.js +399 -5
  25. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  26. package/build/browser/ontology/ActionDefinition.js.map +1 -1
  27. package/build/browser/ontology/ObjectOrInterface.js +1 -0
  28. package/build/browser/ontology/ObjectOrInterface.js.map +1 -1
  29. package/build/browser/ontology/ObjectSpecifier.js.map +1 -1
  30. package/build/browser/ontology/PrimaryKeyTypes.js.map +1 -1
  31. package/build/browser/ontology/QueryDefinition.js.map +1 -1
  32. package/build/browser/ontology/SimplePropertyDef.js.map +1 -1
  33. package/build/browser/queries/Queries.js.map +1 -1
  34. package/build/browser/test/EmployeeApiTest.js.map +1 -1
  35. package/build/browser/util/IncludeValuesExtending.js +2 -0
  36. package/build/browser/util/IncludeValuesExtending.js.map +1 -0
  37. package/build/cjs/{FilteredPropertyKeys-D4ZQUqjG.d.cts → ObjectSet-6WzPM-IC.d.cts} +209 -68
  38. package/build/cjs/index.d.cts +33 -7
  39. package/build/cjs/public/unstable.d.cts +5 -5
  40. package/build/esm/Logger.js +17 -0
  41. package/build/esm/Logger.js.map +1 -0
  42. package/build/esm/OsdkBase.js.map +1 -1
  43. package/build/esm/OsdkObjectFrom.js +2 -4
  44. package/build/esm/OsdkObjectFrom.js.map +1 -1
  45. package/build/esm/OsdkObjectFrom.test.js +3 -3
  46. package/build/esm/OsdkObjectFrom.test.js.map +1 -1
  47. package/build/esm/actions/Actions.js.map +1 -1
  48. package/build/esm/aggregate/AggregatableKeys.js.map +1 -1
  49. package/build/esm/derivedProperties/DerivedProperty.js.map +1 -1
  50. package/build/esm/derivedProperties/Expressions.js +2 -0
  51. package/build/esm/derivedProperties/Expressions.js.map +1 -0
  52. package/build/esm/derivedProperties/WithPropertiesAggregationOptions.js.map +1 -1
  53. package/build/esm/experimental/createMediaReference.js.map +1 -1
  54. package/build/esm/experimental/fetchPageByRid.js.map +1 -1
  55. package/build/esm/index.js.map +1 -1
  56. package/build/esm/mapping/DataValueMapping.js.map +1 -1
  57. package/build/esm/object/FetchPageArgs.js +1 -0
  58. package/build/esm/object/FetchPageArgs.js.map +1 -1
  59. package/build/esm/object/FetchPageResult.js.map +1 -1
  60. package/build/esm/objectSet/BulkLinkResult.js.map +1 -1
  61. package/build/esm/objectSet/ObjectSet.js.map +1 -1
  62. package/build/esm/objectSet/ObjectSet.test.js +399 -5
  63. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  64. package/build/esm/ontology/ActionDefinition.js.map +1 -1
  65. package/build/esm/ontology/ObjectOrInterface.js +1 -0
  66. package/build/esm/ontology/ObjectOrInterface.js.map +1 -1
  67. package/build/esm/ontology/ObjectSpecifier.js.map +1 -1
  68. package/build/esm/ontology/PrimaryKeyTypes.js.map +1 -1
  69. package/build/esm/ontology/QueryDefinition.js.map +1 -1
  70. package/build/esm/ontology/SimplePropertyDef.js.map +1 -1
  71. package/build/esm/queries/Queries.js.map +1 -1
  72. package/build/esm/test/EmployeeApiTest.js.map +1 -1
  73. package/build/esm/util/IncludeValuesExtending.js +2 -0
  74. package/build/esm/util/IncludeValuesExtending.js.map +1 -0
  75. package/build/types/Logger.d.ts +19 -0
  76. package/build/types/Logger.d.ts.map +1 -0
  77. package/build/types/OsdkBase.d.ts +9 -7
  78. package/build/types/OsdkBase.d.ts.map +1 -1
  79. package/build/types/OsdkObjectFrom.d.ts +14 -8
  80. package/build/types/OsdkObjectFrom.d.ts.map +1 -1
  81. package/build/types/actions/Actions.d.ts +4 -4
  82. package/build/types/actions/Actions.d.ts.map +1 -1
  83. package/build/types/aggregate/AggregatableKeys.d.ts +10 -8
  84. package/build/types/aggregate/AggregatableKeys.d.ts.map +1 -1
  85. package/build/types/derivedProperties/DerivedProperty.d.ts +44 -16
  86. package/build/types/derivedProperties/DerivedProperty.d.ts.map +1 -1
  87. package/build/types/derivedProperties/Expressions.d.ts +53 -0
  88. package/build/types/derivedProperties/Expressions.d.ts.map +1 -0
  89. package/build/types/derivedProperties/WithPropertiesAggregationOptions.d.ts +6 -3
  90. package/build/types/derivedProperties/WithPropertiesAggregationOptions.d.ts.map +1 -1
  91. package/build/types/experimental/createMediaReference.d.ts +2 -3
  92. package/build/types/experimental/createMediaReference.d.ts.map +1 -1
  93. package/build/types/experimental/fetchPageByRid.d.ts +3 -2
  94. package/build/types/experimental/fetchPageByRid.d.ts.map +1 -1
  95. package/build/types/index.d.ts +43 -43
  96. package/build/types/index.d.ts.map +1 -1
  97. package/build/types/mapping/DataValueMapping.d.ts +4 -0
  98. package/build/types/mapping/DataValueMapping.d.ts.map +1 -1
  99. package/build/types/object/FetchPageArgs.d.ts +39 -6
  100. package/build/types/object/FetchPageArgs.d.ts.map +1 -1
  101. package/build/types/object/FetchPageResult.d.ts +6 -4
  102. package/build/types/object/FetchPageResult.d.ts.map +1 -1
  103. package/build/types/objectSet/BulkLinkResult.d.ts +1 -1
  104. package/build/types/objectSet/ObjectSet.d.ts +144 -35
  105. package/build/types/objectSet/ObjectSet.d.ts.map +1 -1
  106. package/build/types/objectSet/ObjectSet.test.d.ts +2 -1
  107. package/build/types/objectSet/ObjectSet.test.d.ts.map +1 -1
  108. package/build/types/ontology/ActionDefinition.d.ts +1 -1
  109. package/build/types/ontology/ActionDefinition.d.ts.map +1 -1
  110. package/build/types/ontology/ObjectOrInterface.d.ts +12 -5
  111. package/build/types/ontology/ObjectOrInterface.d.ts.map +1 -1
  112. package/build/types/ontology/ObjectSpecifier.d.ts +2 -1
  113. package/build/types/ontology/ObjectSpecifier.d.ts.map +1 -1
  114. package/build/types/ontology/PrimaryKeyTypes.d.ts +1 -1
  115. package/build/types/ontology/PrimaryKeyTypes.d.ts.map +1 -1
  116. package/build/types/ontology/QueryDefinition.d.ts +2 -0
  117. package/build/types/ontology/QueryDefinition.d.ts.map +1 -1
  118. package/build/types/ontology/SimplePropertyDef.d.ts +4 -4
  119. package/build/types/ontology/SimplePropertyDef.d.ts.map +1 -1
  120. package/build/types/public/unstable.d.ts +3 -3
  121. package/build/types/public/unstable.d.ts.map +1 -1
  122. package/build/types/queries/Queries.d.ts +2 -2
  123. package/build/types/queries/Queries.d.ts.map +1 -1
  124. package/build/types/test/EmployeeApiTest.d.ts +25 -1
  125. package/build/types/test/EmployeeApiTest.d.ts.map +1 -1
  126. package/build/types/util/IncludeValuesExtending.d.ts +4 -0
  127. package/build/types/util/IncludeValuesExtending.d.ts.map +1 -0
  128. package/package.json +4 -4
  129. package/build/browser/ontology/FilteredPropertyKeys.js +0 -2
  130. package/build/browser/ontology/FilteredPropertyKeys.js.map +0 -1
  131. package/build/esm/ontology/FilteredPropertyKeys.js +0 -2
  132. package/build/esm/ontology/FilteredPropertyKeys.js.map +0 -1
  133. package/build/types/ontology/FilteredPropertyKeys.d.ts +0 -6
  134. package/build/types/ontology/FilteredPropertyKeys.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FetchPageResult.js","names":[],"sources":["FetchPageResult.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 {\n ObjectOrInterfaceDefinition,\n PropertyKeys,\n} from \"../ontology/ObjectOrInterface.js\";\nimport type { SimplePropertyDef } from \"../ontology/SimplePropertyDef.js\";\nimport type { ExtractOptions, IsNever, Osdk } from \"../OsdkObjectFrom.js\";\nimport type { PageResult } from \"../PageResult.js\";\nimport type { NullabilityAdherence } from \"./FetchPageArgs.js\";\n\n/** exposed for a test */\nexport type RespectNullability<S extends NullabilityAdherence> = S extends false\n ? false\n : true;\n\n/** exposed for a test */\nexport type UnionIfFalse<S extends string, JUST_S_IF_TRUE extends boolean, E> =\n IsNever<S> extends true ? never\n : JUST_S_IF_TRUE extends true ? S\n : S | E;\n\n/** exposed for a test */\nexport type UnionIfTrue<\n S extends string,\n UNION_IF_TRUE extends boolean,\n E extends string,\n> = IsNever<S> extends true ? never\n : UNION_IF_TRUE extends true ? S | E\n : S;\n\n/**\n * Helper type for converting fetch options into an Osdk object\n */\nexport type FetchPageResult<\n Q extends ObjectOrInterfaceDefinition,\n L extends PropertyKeys<Q>,\n R extends boolean,\n S extends NullabilityAdherence,\n> = PageResult<\n PropertyKeys<Q> extends L ? Osdk.Instance<Q, ExtractOptions<R, S>>\n : Osdk.Instance<Q, ExtractOptions<R, S>, L>\n>;\n\n/**\n * Helper type for converting fetch options into an Osdk object\n */\nexport type SingleOsdkResult<\n Q extends ObjectOrInterfaceDefinition,\n L extends PropertyKeys<Q> | (keyof RDPs & string),\n R extends boolean,\n S extends NullabilityAdherence,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> = Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n>;\n\nexport type IsAny<T> = unknown extends T\n ? [keyof T] extends [never] ? false : true\n : false;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"FetchPageResult.js","names":[],"sources":["FetchPageResult.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 {\n ObjectOrInterfaceDefinition,\n PropertyKeys,\n} from \"../ontology/ObjectOrInterface.js\";\nimport type { SimplePropertyDef } from \"../ontology/SimplePropertyDef.js\";\nimport type { ExtractOptions, IsNever, Osdk } from \"../OsdkObjectFrom.js\";\nimport type { PageResult } from \"../PageResult.js\";\nimport type { NullabilityAdherence } from \"./FetchPageArgs.js\";\n\n/** exposed for a test */\nexport type RespectNullability<S extends NullabilityAdherence> = S extends false\n ? false\n : true;\n\n/** exposed for a test */\nexport type UnionIfFalse<S extends string, JUST_S_IF_TRUE extends boolean, E> =\n IsNever<S> extends true ? never\n : JUST_S_IF_TRUE extends true ? S\n : S | E;\n\n/** exposed for a test */\nexport type UnionIfTrue<\n S extends string,\n UNION_IF_TRUE extends boolean,\n E extends string,\n> = IsNever<S> extends true ? never\n : UNION_IF_TRUE extends true ? S | E\n : S;\n\n/**\n * Helper type for converting fetch options into an Osdk object\n */\nexport type FetchPageResult<\n Q extends ObjectOrInterfaceDefinition,\n L extends PropertyKeys<Q>,\n R extends boolean,\n S extends NullabilityAdherence,\n T extends boolean = false,\n> = PageResult<\n PropertyKeys<Q> extends L ? Osdk.Instance<Q, ExtractOptions<R, S, T>>\n : Osdk.Instance<Q, ExtractOptions<R, S, T>, L>\n>;\n\n/**\n * Helper type for converting fetch options into an Osdk object\n */\nexport type SingleOsdkResult<\n Q extends ObjectOrInterfaceDefinition,\n L extends PropertyKeys<Q> | (keyof RDPs & string),\n R extends boolean,\n S extends NullabilityAdherence,\n RDPs extends Record<string, SimplePropertyDef> = {},\n T extends boolean = false,\n> = Osdk.Instance<\n Q,\n ExtractOptions<R, S, T>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n>;\n\nexport type IsAny<T> = unknown extends T\n ? [keyof T] extends [never] ? false : true\n : false;\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"BulkLinkResult.js","names":[],"sources":["BulkLinkResult.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 { OsdkBase } from \"../OsdkBase.js\";\n\nexport interface EXPERIMENTAL_BulkLinkResult {\n object: OsdkBase<any>;\n linkApiName: string;\n otherObjectApiName: string | undefined;\n otherObjectPk: unknown;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"BulkLinkResult.js","names":[],"sources":["BulkLinkResult.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 { OsdkBase } from \"../OsdkBase.js\";\n\nexport interface EXPERIMENTAL_BulkLinkResult {\n object: OsdkBase<any>;\n linkApiName: string;\n otherObjectApiName: string | null | undefined;\n otherObjectPk: unknown;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectSet.js","names":[],"sources":["ObjectSet.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 { AggregateOpts } from \"../aggregate/AggregateOpts.js\";\nimport type { AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy } from \"../aggregate/AggregateOptsThatErrors.js\";\nimport type { AggregationsResults } from \"../aggregate/AggregationsResults.js\";\nimport type { WhereClause } from \"../aggregate/WhereClause.js\";\nimport type { DerivedProperty } from \"../derivedProperties/DerivedProperty.js\";\nimport type {\n AsyncIterArgs,\n Augments,\n FetchPageArgs,\n NullabilityAdherence,\n SelectArg,\n} from \"../object/FetchPageArgs.js\";\nimport type { Result } from \"../object/Result.js\";\nimport type { InterfaceDefinition } from \"../ontology/InterfaceDefinition.js\";\nimport type {\n DerivedObjectOrInterfaceDefinition,\n ObjectOrInterfaceDefinition,\n PropertyKeys,\n} from \"../ontology/ObjectOrInterface.js\";\nimport type {\n CompileTimeMetadata,\n ObjectTypeDefinition,\n} from \"../ontology/ObjectTypeDefinition.js\";\nimport type { SimplePropertyDef } from \"../ontology/SimplePropertyDef.js\";\nimport type { PrimaryKeyType } from \"../OsdkBase.js\";\nimport type { ExtractOptions, Osdk } from \"../OsdkObjectFrom.js\";\nimport type { PageResult } from \"../PageResult.js\";\nimport type { LinkedType, LinkNames } from \"../util/LinkUtils.js\";\nimport type { BaseObjectSet } from \"./BaseObjectSet.js\";\nimport type { ObjectSetSubscription } from \"./ObjectSetListener.js\";\n\ntype MergeObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n D extends ObjectSet<Q> | Record<string, SimplePropertyDef> = {},\n> = D extends Record<string, SimplePropertyDef>\n ? DerivedObjectOrInterfaceDefinition.WithDerivedProperties<Q, D>\n : Q;\n\ntype ExtractRdp<\n D extends ObjectSet<any, any> | Record<string, SimplePropertyDef>,\n> = D extends Record<string, SimplePropertyDef> ? D : {};\n\nexport interface MinimalObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends\n BaseObjectSet<Q>,\n FetchPage<Q, RDPs>,\n AsyncIter<Q, RDPs>,\n Where<Q, RDPs>\n{\n}\n\n// TODO MOVE THIS\ninterface FetchPage<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Gets a page of objects of this type, with a result wrapper\n * @param args - Args to specify next page token and page size, if applicable\n * @example\n * const myObjs = await objectSet.fetchPage({\n $pageSize: 10,\n $nextPageToken: \"nextPage\"\n });\n const myObjsResult = myObjs.data;\n\n * @returns a page of objects\n */\n readonly fetchPage: <\n L extends PropertyKeys<Q, RDPs>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n >(\n args?: FetchPageArgs<Q, L, R, A, S>,\n ) => Promise<\n PageResult<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n >\n >\n >;\n\n /**\n * Gets a page of objects of this type, with a result wrapper\n * @param args - Args to specify next page token and page size, if applicable\n * @example\n * const myObjs = await objectSet.fetchPage({\n $pageSize: 10,\n $nextPageToken: \"nextPage\"\n });\n\n if(isOk(myObjs)){\n const myObjsResult = myObjs.value.data;\n }\n * @returns a page of objects, wrapped in a result wrapper\n */\n readonly fetchPageWithErrors: <\n L extends PropertyKeys<Q, RDPs>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n >(\n args?: FetchPageArgs<Q, L, R, A, S>,\n ) => Promise<\n Result<\n PageResult<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n >\n >\n >\n >;\n}\n\n// TODO MOVE THIS\ninterface Where<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Allows you to filter an object set with a given clause\n * @param clause - Takes a filter clause\n * @example\n * await client(Office).where({\n meetingRooms: { $contains: \"Grand Central\" },\n meetingRoomCapacities: { $contains: 30 },\n});\n* @returns an objectSet\n */\n readonly where: (\n clause: WhereClause<MergeObjectSet<Q, RDPs>>,\n ) => this;\n}\n\ninterface AsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Returns an async iterator to load all objects of this type\n * @example\n * for await (const obj of myObjectSet.asyncIter()){\n * // Handle obj\n * }\n * @returns an async iterator to load all objects\n */\n readonly asyncIter: <\n L extends PropertyKeys<Q, RDPs>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n >(\n args?: AsyncIterArgs<Q, L, R, A, S>,\n ) => AsyncIterableIterator<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n >\n >;\n}\n\ninterface InterfaceObjectSet<\n Q extends InterfaceDefinition,\n> extends MinimalObjectSet<Q> {\n}\n\ninterface WithProperties<\n Q extends ObjectOrInterfaceDefinition = any,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n readonly withProperties: <\n NEW extends Record<string, SimplePropertyDef>,\n >(\n clause: { [K in keyof NEW]: DerivedProperty.Selector<Q, NEW[K]> },\n ) => ObjectSet<\n Q,\n {\n [NN in keyof NEW | keyof RDPs]: NN extends keyof NEW ? NEW[NN]\n : NN extends keyof RDPs ? RDPs[NN]\n : never;\n }\n >;\n}\n\nexport interface ObjectSet<\n Q extends ObjectOrInterfaceDefinition = any,\n // Generated code has what is basically ObjectSet<Q> set in here\n // but we never used it so I am repurposing it for RDP\n UNUSED_OR_RDP extends ObjectSet<Q, any> | Record<string, SimplePropertyDef> =\n ObjectSet<Q, any>,\n> extends\n ObjectSetCleanedTypes<\n Q,\n ExtractRdp<UNUSED_OR_RDP>,\n MergeObjectSet<Q, UNUSED_OR_RDP>\n >\n{\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface Aggregate<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Aggregate on a field in an object type\n * @param req - an aggregation request where you can select fields and choose how to aggregate, e.g., max, min, avg, and also choose\n * whether or not you order your results. You can also specify a groupBy field to group your aggregations\n * @example\n * const testAggregateCountWithGroups = await client(BoundariesUsState)\n .aggregate({\n $select: {\n $count: \"unordered\",\n \"latitude:max\": \"unordered\",\n \"latitude:min\": \"unordered\",\n \"latitude:avg\": \"unordered\",\n },\n $groupBy: {\n usState: \"exact\",\n longitude: {\n $fixedWidth: 10,\n },\n },\n });\n\n * @returns aggregation results, sorted in the groups based on the groupBy clause (if applicable)\n */\n readonly aggregate: <AO extends AggregateOpts<Q>>(\n req: AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy<Q, AO>,\n ) => Promise<AggregationsResults<Q, AO>>;\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface SetArithmetic<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Unions object sets together\n * @param objectSets - objectSets you want to union with\n * @example\n * const unionObjectSet = complexFilteredEmployeeObjectSet.union(\n simpleFilteredEmployeeObjectSet,\n );\n * @returns the unioned object set\n */\n readonly union: (\n ...objectSets: ReadonlyArray<CompileTimeMetadata<Q>[\"objectSet\"]>\n ) => this;\n\n /**\n * Computes the intersection of object sets\n * @param objectSets - objectSets you want to intersect with\n * @example\n * const intersectedObjectSet = complexFilteredEmployeeObjectSet.intersect(\n simpleFilteredEmployeeObjectSet,\n );\n * @returns the intersected object set\n */\n readonly intersect: (\n ...objectSets: ReadonlyArray<CompileTimeMetadata<Q>[\"objectSet\"]>\n ) => this;\n\n /**\n * Computes the subtraction of object sets\n * @param objectSets - objectSets you want to subtract from\n * @example\n * const subtractObjectSet = complexFilteredEmployeeObjectSet.subtract(\n simpleFilteredEmployeeObjectSet,\n );\n * @returns the subtract object set\n */\n readonly subtract: (\n ...objectSets: ReadonlyArray<CompileTimeMetadata<Q>[\"objectSet\"]>\n ) => this;\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface PivotTo<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Pivots the object set over to all its linked objects of the specified type\n * @param type - The linked object type you want to pivot to\n * @returns an object set of the specified linked type\n */\n readonly pivotTo: <L extends LinkNames<Q>>(\n type: L,\n ) => CompileTimeMetadata<LinkedType<Q, L>>[\"objectSet\"]; // ObjectSet<LinkedType<Q, L>>;\n}\n\ninterface FetchOne<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n> {\n /**\n * Fetches one object with the specified primary key, without a result wrapper\n */\n readonly fetchOne: Q extends ObjectTypeDefinition ? <\n const L extends PropertyKeys<Q, RDPs>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n primaryKey: PrimaryKeyType<Q>,\n options?: SelectArg<Q, L, R, S>,\n ) => Promise<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n >\n >\n : never;\n\n /**\n * Fetches one object with the specified primary key, with a result wrapper\n */\n readonly fetchOneWithErrors: Q extends ObjectTypeDefinition ? <\n L extends PropertyKeys<Q, RDPs>,\n R extends boolean,\n S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n primaryKey: PrimaryKeyType<Q>,\n options?: SelectArg<Q, L, R, S>,\n ) => Promise<\n Result<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n PropertyKeys<Q> extends L ? PropertyKeys<Q> : PropertyKeys<Q> & L,\n { [K in Extract<keyof RDPs, L>]: RDPs[K] }\n >\n >\n >\n : never;\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface Subscribe<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Request updates when the objects in an object set are added, updated, or removed.\n * @param listener - The handlers to be executed during the lifecycle of the subscription.\n * @param opts - Options to modify what properties are returned on subscription updates.\n * @returns an object containing a function to unsubscribe.\n */\n readonly subscribe: <\n const P extends PropertyKeys<Q>,\n >(\n listener: ObjectSetSubscription.Listener<Q, P>,\n opts?: ObjectSetSubscription.Options<Q, P>,\n ) => { unsubscribe: () => void };\n}\n\ninterface ObjectSetCleanedTypes<\n Q extends ObjectOrInterfaceDefinition,\n D extends Record<string, SimplePropertyDef>,\n MERGED extends ObjectOrInterfaceDefinition,\n> extends\n MinimalObjectSet<Q, D>,\n WithProperties<Q, D>,\n Aggregate<MERGED>,\n SetArithmetic<MERGED>,\n PivotTo<MERGED>,\n FetchOne<Q, D>,\n Subscribe<MERGED>\n{\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectSet.js","names":[],"sources":["ObjectSet.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 { AggregateOpts } from \"../aggregate/AggregateOpts.js\";\nimport type { AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy } from \"../aggregate/AggregateOptsThatErrors.js\";\nimport type { AggregationsResults } from \"../aggregate/AggregationsResults.js\";\nimport type { WhereClause } from \"../aggregate/WhereClause.js\";\nimport type { DerivedPropertyCreator } from \"../derivedProperties/DerivedProperty.js\";\nimport type {\n AsyncIterArgs,\n Augments,\n FetchPageArgs,\n NullabilityAdherence,\n ObjectSetArgs,\n SelectArg,\n} from \"../object/FetchPageArgs.js\";\nimport type { Result } from \"../object/Result.js\";\nimport type {\n DerivedObjectOrInterfaceDefinition,\n ObjectOrInterfaceDefinition,\n PropertyKeys,\n} from \"../ontology/ObjectOrInterface.js\";\nimport type {\n CompileTimeMetadata,\n ObjectTypeDefinition,\n} from \"../ontology/ObjectTypeDefinition.js\";\nimport type { SimplePropertyDef } from \"../ontology/SimplePropertyDef.js\";\nimport type { PrimaryKeyType } from \"../OsdkBase.js\";\nimport type {\n ExtractAllPropertiesOption,\n ExtractOptions,\n ExtractRidOption,\n Osdk,\n} from \"../OsdkObjectFrom.js\";\nimport type { PageResult } from \"../PageResult.js\";\nimport type { LinkedType, LinkNames } from \"../util/LinkUtils.js\";\nimport type { BaseObjectSet } from \"./BaseObjectSet.js\";\nimport type { ObjectSetSubscription } from \"./ObjectSetListener.js\";\n\ntype MergeObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n D extends Record<string, SimplePropertyDef> = {},\n> = DerivedObjectOrInterfaceDefinition.WithDerivedProperties<Q, D>;\n\ntype ExtractRdp<\n D extends\n | BaseObjectSet<any>\n | Record<string, SimplePropertyDef>,\n> = [D] extends [never] ? {}\n : D extends BaseObjectSet<any> ? {}\n : D extends Record<string, SimplePropertyDef> ? D\n : {};\n\ntype MaybeSimplifyPropertyKeys<\n Q extends ObjectOrInterfaceDefinition,\n L extends PropertyKeys<Q>,\n> = PropertyKeys<Q> extends L ? PropertyKeys<Q> : L;\n\ntype SubSelectKeysHelper<\n Q extends ObjectOrInterfaceDefinition,\n L extends string,\n> = [L] extends [never] ? PropertyKeys<Q>\n : PropertyKeys<Q> extends L ? PropertyKeys<Q>\n : L & PropertyKeys<Q>;\n\ntype SubSelectKeys<\n Q extends ObjectOrInterfaceDefinition,\n X extends SelectArg<Q, PropertyKeys<Q>, any, any> = never,\n> = SubSelectKeysHelper<Q, Extract$Select<X>>;\n\ntype NOOP<T> = T extends (...args: any[]) => any ? T\n : T extends abstract new(...args: any[]) => any ? T\n : { [K in keyof T]: T[K] };\n\ntype SubSelectRDPsHelper<\n X extends ValidFetchPageArgs<any, any> | ValidAsyncIterArgs<any, any>,\n DEFAULT extends string,\n> = [X] extends [never] ? DEFAULT\n : (X[\"$select\"] & string[])[number] & DEFAULT;\n\ntype SubSelectRDPs<\n RDPs extends Record<string, SimplePropertyDef>,\n X extends ValidFetchPageArgs<any, RDPs> | ValidAsyncIterArgs<any, RDPs>,\n> = [RDPs] extends [never] ? never\n : NOOP<{ [K in SubSelectRDPsHelper<X, string & keyof RDPs>]: RDPs[K] }>;\n\nexport interface MinimalObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends\n BaseObjectSet<Q>,\n FetchPage<Q, RDPs>,\n AsyncIter<Q, RDPs>,\n Where<Q, RDPs>\n{\n}\n\nexport type ExtractOptions2<\n X extends FetchPageArgs<any, any, any, any, any, any, any>,\n> = [X] extends [never] ? never\n :\n | ExtractRidOption<X[\"$includeRid\"] extends true ? true : false>\n | ExtractAllPropertiesOption<\n X[\"$includeAllBaseObjectProperties\"] extends true ? true : false\n >;\n\ntype Extract$Select<X extends FetchPageArgs<any, any>> = NonNullable<\n X[\"$select\"]\n>[number];\n\ninterface FetchPage<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n readonly fetchPage: FetchPageSignature<Q, RDPs>;\n readonly fetchPageWithErrors: FetchPageWithErrorsSignature<Q, RDPs>;\n}\n\ntype ValidFetchPageArgs<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n> =\n | ObjectSetArgs.FetchPage<\n Q,\n PropertyKeys<Q>,\n false,\n string & keyof RDPs\n >\n | ObjectSetArgs.FetchPage<\n Q,\n never,\n true,\n string & keyof RDPs\n >;\n\ntype ValidAsyncIterArgs<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n> =\n | ObjectSetArgs.AsyncIter<\n Q,\n PropertyKeys<Q>,\n false,\n string & keyof RDPs\n >\n | AsyncIterArgs<\n Q,\n never,\n any,\n any,\n any,\n true,\n string & keyof RDPs\n >;\n\ninterface FetchPageSignature<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Gets a page of objects of this type, with a result wrapper\n * @param args - Args to specify next page token and page size, if applicable\n * @example\n * const myObjs = await objectSet.fetchPage({\n $pageSize: 10,\n $nextPageToken: \"nextPage\"\n });\n const myObjsResult = myObjs.data;\n\n * @returns a page of objects\n */\n <const X extends ValidFetchPageArgs<Q, RDPs> = never>(\n args?: X,\n ): Promise<\n PageResult<\n Osdk.Instance<\n Q,\n ExtractOptions2<X>,\n SubSelectKeys<Q, X>,\n SubSelectRDPs<RDPs, X>\n >\n >\n >;\n\n /**\n * Gets a page of objects of this type, with a result wrapper\n * @param args - Args to specify next page token and page size, if applicable\n * @example\n * const myObjs = await objectSet.fetchPage({\n $pageSize: 10,\n $nextPageToken: \"nextPage\"\n });\n const myObjsResult = myObjs.data;\n\n * @returns a page of objects\n */\n <\n L extends PropertyKeys<Q>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n T extends boolean = false,\n >(\n args?: FetchPageArgs<Q, L, R, A, S, T>,\n ): Promise<\n PageResult<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S, T>,\n MaybeSimplifyPropertyKeys<Q, L>\n >\n >\n >;\n}\n\ninterface FetchPageWithErrorsSignature<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Gets a page of objects of this type, with a result wrapper\n * @param args - Args to specify next page token and page size, if applicable\n * @example\n * const myObjs = await objectSet.fetchPage({\n $pageSize: 10,\n $nextPageToken: \"nextPage\"\n });\n\n if(isOk(myObjs)){\n const myObjsResult = myObjs.value.data;\n }\n * @returns a page of objects, wrapped in a result wrapper\n */\n <X extends ValidFetchPageArgs<Q, RDPs> = never>(\n args?: X,\n ): Promise<\n Result<\n PageResult<\n Osdk.Instance<\n Q,\n ExtractOptions2<X>,\n SubSelectKeys<Q, X>,\n SubSelectRDPs<RDPs, X>\n >\n >\n >\n >;\n\n /**\n * Gets a page of objects of this type, with a result wrapper\n * @param args - Args to specify next page token and page size, if applicable\n * @example\n * const myObjs = await objectSet.fetchPage({\n $pageSize: 10,\n $nextPageToken: \"nextPage\"\n });\n\n if(isOk(myObjs)){\n const myObjsResult = myObjs.value.data;\n }\n * @returns a page of objects, wrapped in a result wrapper\n */\n <\n L extends PropertyKeys<Q>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n T extends boolean = false,\n >(\n args?: FetchPageArgs<Q, L, R, A, S, T>,\n ): Promise<\n Result<\n PageResult<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S, T>,\n MaybeSimplifyPropertyKeys<Q, L>\n >\n >\n >\n >;\n}\n\n// TODO MOVE THIS\ninterface Where<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Allows you to filter an object set with a given clause\n * @param clause - Takes a filter clause\n * @example\n * await client(Office).where({\n meetingRooms: { $contains: \"Grand Central\" },\n meetingRoomCapacities: { $contains: 30 },\n});\n* @returns an objectSet\n */\n readonly where: (\n clause: WhereClause<MergeObjectSet<Q, RDPs>>,\n ) => this;\n}\n\ninterface AsyncIterSignature<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Returns an async iterator to load all objects of this type\n * @example\n * for await (const obj of myObjectSet.asyncIter()){\n * // Handle obj\n * }\n * @returns an async iterator to load all objects\n */\n <X extends ValidAsyncIterArgs<Q, RDPs> = never>(\n args?: X,\n ): AsyncIterableIterator<\n Osdk.Instance<\n Q,\n ExtractOptions2<X>,\n SubSelectKeys<Q, X>,\n SubSelectRDPs<RDPs, X>\n >\n >;\n\n /**\n * Returns an async iterator to load all objects of this type\n * @example\n * for await (const obj of myObjectSet.asyncIter()){\n * // Handle obj\n * }\n * @returns an async iterator to load all objects\n */\n <\n L extends PropertyKeys<Q>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n T extends boolean = false,\n >(\n args?: AsyncIterArgs<Q, L, R, A, S, T>,\n ): AsyncIterableIterator<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S, T>,\n MaybeSimplifyPropertyKeys<Q, L>\n >\n >;\n}\n\ninterface AsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n asyncIter: AsyncIterSignature<Q, RDPs>;\n}\n\ninterface WithProperties<\n Q extends ObjectOrInterfaceDefinition = any,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n readonly withProperties: <\n NEW extends Record<string, SimplePropertyDef>,\n >(\n clause: { [K in keyof NEW]: DerivedPropertyCreator<Q, NEW[K]> },\n ) => ObjectSet<\n Q,\n {\n [NN in keyof NEW | keyof RDPs]: NN extends keyof NEW ? NEW[NN]\n : NN extends keyof RDPs ? RDPs[NN]\n : never;\n }\n >;\n}\n\nexport interface ObjectSet<\n Q extends ObjectOrInterfaceDefinition = any,\n // Generated code has what is basically ObjectSet<Q> set in here\n // but we never used it so I am repurposing it for RDP\n UNUSED_OR_RDP extends\n | BaseObjectSet<Q>\n | Record<string, SimplePropertyDef> = never,\n> extends\n ObjectSetCleanedTypes<\n Q,\n ExtractRdp<UNUSED_OR_RDP>,\n MergeObjectSet<Q, ExtractRdp<UNUSED_OR_RDP>>\n >\n{\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface Aggregate<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Aggregate on a field in an object type\n * @param req - an aggregation request where you can select fields and choose how to aggregate, e.g., max, min, avg, and also choose\n * whether or not you order your results. You can also specify a groupBy field to group your aggregations\n * @example\n * const testAggregateCountWithGroups = await client(BoundariesUsState)\n .aggregate({\n $select: {\n $count: \"unordered\",\n \"latitude:max\": \"unordered\",\n \"latitude:min\": \"unordered\",\n \"latitude:avg\": \"unordered\",\n },\n $groupBy: {\n usState: \"exact\",\n longitude: {\n $fixedWidth: 10,\n },\n },\n });\n\n * @returns aggregation results, sorted in the groups based on the groupBy clause (if applicable)\n */\n readonly aggregate: <AO extends AggregateOpts<Q>>(\n req: AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy<Q, AO>,\n ) => Promise<AggregationsResults<Q, AO>>;\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface SetArithmetic<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Unions object sets together\n * @param objectSets - objectSets you want to union with\n * @example\n * const unionObjectSet = complexFilteredEmployeeObjectSet.union(\n simpleFilteredEmployeeObjectSet,\n );\n * @returns the unioned object set\n */\n readonly union: (\n ...objectSets: ReadonlyArray<CompileTimeMetadata<Q>[\"objectSet\"]>\n ) => this;\n\n /**\n * Computes the intersection of object sets\n * @param objectSets - objectSets you want to intersect with\n * @example\n * const intersectedObjectSet = complexFilteredEmployeeObjectSet.intersect(\n simpleFilteredEmployeeObjectSet,\n );\n * @returns the intersected object set\n */\n readonly intersect: (\n ...objectSets: ReadonlyArray<CompileTimeMetadata<Q>[\"objectSet\"]>\n ) => this;\n\n /**\n * Computes the subtraction of object sets\n * @param objectSets - objectSets you want to subtract from\n * @example\n * const subtractObjectSet = complexFilteredEmployeeObjectSet.subtract(\n simpleFilteredEmployeeObjectSet,\n );\n * @returns the subtract object set\n */\n readonly subtract: (\n ...objectSets: ReadonlyArray<CompileTimeMetadata<Q>[\"objectSet\"]>\n ) => this;\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface PivotTo<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Pivots the object set over to all its linked objects of the specified type\n * @param type - The linked object type you want to pivot to\n * @returns an object set of the specified linked type\n */\n readonly pivotTo: <L extends LinkNames<Q>>(\n type: L,\n ) => ObjectSet<LinkedType<Q, L>>;\n}\n\ninterface FetchOneSignature<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n> {\n /**\n * Fetches one object with the specified primary key, without a result wrapper\n */\n <\n X extends ObjectSetArgs.Select<PropertyKeys<Q>, string & keyof RDPs> =\n never,\n >(\n primaryKey: PrimaryKeyType<Q>,\n options?: X,\n ): Promise<\n Osdk.Instance<\n Q,\n ExtractOptions2<X>,\n SubSelectKeys<Q, X>,\n SubSelectRDPs<RDPs, X>\n >\n >;\n\n /**\n * Fetches one object with the specified primary key, without a result wrapper\n */\n <\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n primaryKey: PrimaryKeyType<Q>,\n options?: SelectArg<Q, L, R, S>,\n ): Promise<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n MaybeSimplifyPropertyKeys<Q, L>\n >\n >;\n}\n\ninterface FetchOneWithErrorsSignature<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n> {\n /**\n * Fetches one object with the specified primary key, with a result wrapper\n */\n <X extends ObjectSetArgs.Select<PropertyKeys<Q>, string & keyof RDPs>>(\n primaryKey: PrimaryKeyType<Q>,\n options?: X,\n ): Promise<\n Result<\n Osdk.Instance<\n Q,\n ExtractOptions2<X>,\n SubSelectKeys<Q, X>,\n SubSelectRDPs<RDPs, X>\n >\n >\n >;\n\n /**\n * Fetches one object with the specified primary key, with a result wrapper\n */\n <\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n primaryKey: PrimaryKeyType<Q>,\n options?: SelectArg<Q, L, R, S>,\n ): Promise<\n Result<\n Osdk.Instance<\n Q,\n ExtractOptions<R, S>,\n MaybeSimplifyPropertyKeys<Q, L>\n >\n >\n >;\n}\n\ninterface FetchOne<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n> {\n fetchOne: Q extends ObjectTypeDefinition ? FetchOneSignature<Q, RDPs> : never;\n fetchOneWithErrors: Q extends ObjectTypeDefinition\n ? FetchOneWithErrorsSignature<Q, RDPs>\n : never;\n}\n\n// Q is the merged type here! Not renaming to keep diff small. Rename in follow up\ninterface Subscribe<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Request updates when the objects in an object set are added, updated, or removed.\n * @param listener - The handlers to be executed during the lifecycle of the subscription.\n * @param opts - Options to modify what properties are returned on subscription updates.\n * @returns an object containing a function to unsubscribe.\n */\n readonly subscribe: <\n const P extends PropertyKeys<Q>,\n >(\n listener: ObjectSetSubscription.Listener<Q, P>,\n opts?: ObjectSetSubscription.Options<Q, P>,\n ) => { unsubscribe: () => void };\n}\n\ninterface ObjectSetCleanedTypes<\n Q extends ObjectOrInterfaceDefinition,\n D extends Record<string, SimplePropertyDef>,\n MERGED extends ObjectOrInterfaceDefinition & Q,\n> extends\n MinimalObjectSet<Q, D>,\n WithProperties<Q, D>,\n Aggregate<MERGED>,\n SetArithmetic<MERGED>,\n PivotTo<Q>,\n FetchOne<Q, D>,\n Subscribe<MERGED>\n{\n}\n"],"mappings":"","ignoreList":[]}
@@ -15,23 +15,53 @@
15
15
  */
16
16
 
17
17
  import { describe, expectTypeOf, it, test, vi } from "vitest";
18
- describe("ObjectSet", () => {
19
- const fauxObjectSet = {
18
+ export function createMockObjectSet() {
19
+ let fauxObject, fauxResults, fauxObjectSet;
20
+
21
+ // eslint-disable-next-line prefer-const
22
+ fauxObject = {
23
+ $link: {
24
+ peeps: {
25
+ $objectSetInternals: {
26
+ def: {}
27
+ }
28
+ }
29
+ }
30
+ };
31
+ fauxResults = {
32
+ data: [fauxObject]
33
+ };
34
+ fauxObjectSet = {
20
35
  where: vi.fn(() => {
21
36
  return fauxObjectSet;
22
37
  }),
23
38
  withProperties: vi.fn(() => {
24
39
  return fauxObjectSet;
25
40
  }),
26
- fetchPage: vi.fn(() => Promise.resolve()),
41
+ fetchPage: vi.fn(() => Promise.resolve(fauxResults)),
42
+ fetchOne: vi.fn(() => fauxObject),
27
43
  asyncIter: vi.fn(() => {
28
44
  return {};
45
+ }),
46
+ aggregate: vi.fn(() => {
47
+ return {};
48
+ }),
49
+ pivotTo: vi.fn(() => {
50
+ return fauxObjectSet;
29
51
  })
30
52
  };
53
+ return fauxObjectSet;
54
+ }
55
+ describe("ObjectSet", () => {
56
+ const fauxObjectSet = createMockObjectSet();
31
57
  describe("normal", () => {
32
58
  test("select none", async () => {
33
59
  await fauxObjectSet.fetchPage();
34
60
  expectTypeOf().toEqualTypeOf();
61
+
62
+ // Do it again but be explicit about the params to be sure
63
+ // we don't break them
64
+ await fauxObjectSet.fetchPage();
35
65
  });
36
66
  test("select one", async () => {
37
67
  await fauxObjectSet.fetchPage({
@@ -40,6 +70,73 @@ describe("ObjectSet", () => {
40
70
  expectTypeOf().toEqualTypeOf();
41
71
  });
42
72
  });
73
+ describe("includeAllBaseObjectProperties", () => {
74
+ it("has the right types if you pass true", async () => {
75
+ const fetchPageResult = await fauxObjectSet.where({
76
+ class: "idk"
77
+ }).fetchPage({
78
+ $includeAllBaseObjectProperties: true
79
+ });
80
+ expectTypeOf(fetchPageResult).toEqualTypeOf();
81
+ const asyncIterResult = fauxObjectSet.where({
82
+ class: "idk"
83
+ }).asyncIter({
84
+ $includeAllBaseObjectProperties: true
85
+ });
86
+ expectTypeOf(asyncIterResult).toEqualTypeOf();
87
+ });
88
+ it("does not let you pass partial $select and true", async () => {
89
+ await fauxObjectSet.where({
90
+ class: "idk"
91
+ }).fetchPage({
92
+ // @ts-expect-error
93
+ $includeAllBaseObjectProperties: true,
94
+ $select: ["attachment"]
95
+ });
96
+ fauxObjectSet.where({
97
+ class: "idk"
98
+ }).asyncIter({
99
+ // @ts-expect-error
100
+ $includeAllBaseObjectProperties: true,
101
+ $select: ["attachment"]
102
+ });
103
+ });
104
+ it("does let you pass full select options and false", async () => {
105
+ await fauxObjectSet.where({
106
+ class: "idk"
107
+ }).fetchPage({
108
+ $includeAllBaseObjectProperties: true,
109
+ // this select list is intended to represent all properties on `EmployeeApiTest`,
110
+ // so if you get an error here later and you added properties to that object,
111
+ // be sure to add them here too.
112
+ $select: ["attachment", "class", "employeeId", "fullName", "geopoint", "geotimeSeriesReference", "isActive", "mediaReference", "timeseries", "dateOfJoining", "hourlyRate", "yearsOfExperience", "rank", "performanceScore", "mediaReference", "lastUpdated"]
113
+ });
114
+ await fauxObjectSet.where({
115
+ class: "idk"
116
+ }).fetchPage({
117
+ $includeAllBaseObjectProperties: true,
118
+ // this select list is intended to represent all properties on `EmployeeApiTest`,
119
+ // so if you get an error here later and you added properties to that object,
120
+ // be sure to add them here too.
121
+ $select: ["attachment", "class", "employeeId", "fullName", "geopoint", "geotimeSeriesReference", "isActive", "mediaReference", "timeseries", "dateOfJoining", "hourlyRate", "yearsOfExperience", "rank", "performanceScore", "mediaReference", "lastUpdated"]
122
+ });
123
+ });
124
+ });
125
+ test("includeRid", async () => {
126
+ const x = await fauxObjectSet.where({
127
+ class: "idk"
128
+ }).fetchPage({
129
+ $includeRid: true
130
+ });
131
+ expectTypeOf(x).toEqualTypeOf();
132
+ });
133
+ test("pivotTo", async () => {
134
+ await fauxObjectSet.pivotTo("peeps").fetchPage({});
135
+ const subselect = await fauxObjectSet.pivotTo("peeps").fetchPage({
136
+ $select: ["employeeId", "class"]
137
+ });
138
+ expectTypeOf(subselect).toEqualTypeOf();
139
+ });
43
140
  describe(".withProperties", () => {
44
141
  test("single property", async () => {
45
142
  const withA = fauxObjectSet.withProperties({
@@ -52,6 +149,13 @@ describe("ObjectSet", () => {
52
149
  expectTypeOf().toEqualTypeOf();
53
150
  expectTypeOf().toEqualTypeOf();
54
151
  });
152
+ it("can be sub-selected", () => {
153
+ fauxObjectSet.withProperties({
154
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId")
155
+ }).fetchOne(3, {
156
+ $select: ["derivedPropertyName"]
157
+ });
158
+ });
55
159
  test("multiple properties", async () => {
56
160
  const withFamily = fauxObjectSet.withProperties({
57
161
  "mom": base => base.pivotTo("lead").aggregate("$count"),
@@ -112,9 +216,23 @@ describe("ObjectSet", () => {
112
216
  const where = withFamily.where({
113
217
  "mom": 1
114
218
  });
115
- await where.fetchPage();
219
+ const whereResults = await where.fetchPage();
220
+
221
+ // Checks that if you did an `await where.fetchPage()` that you can then
222
+ // pass/assign it to something explicit.
223
+ // Checks that if you did an `await where.fetchPage()` that you can then
224
+ // pass/assign it to something explicit.
225
+ whereResults.data[0];
226
+ whereResults.data[0].$link.peeps.$objectSetInternals.def; // same as above but with expectTypeOf
116
227
  expectTypeOf().toEqualTypeOf();
117
228
  expectTypeOf().toEqualTypeOf();
229
+
230
+ // Checks that when you directly assign, it infers correctly.
231
+ // Sometimes an explicit assignment can affect how typescript infers
232
+ // types.
233
+ await where.fetchPage();
234
+ await withFamily.fetchOne(1);
235
+ await withFamily.fetchOne(1);
118
236
  });
119
237
  it("works with .async", () => {
120
238
  withFamily.asyncIter();
@@ -139,7 +257,7 @@ describe("ObjectSet", () => {
139
257
  });
140
258
  it("Works with selecting all non-RDP's", async () => {
141
259
  await withFamily.fetchPage({
142
- $select: ["class", "fullName", "employeeId"]
260
+ $select: ["employeeId", "fullName", "class", "attachment", "geopoint", "timeseries", "mediaReference", "geotimeSeriesReference", "isActive", "yearsOfExperience", "rank", "performanceScore", "hourlyRate", "dateOfJoining", "lastUpdated"]
143
261
  });
144
262
  expectTypeOf().toEqualTypeOf();
145
263
  expectTypeOf().toEqualTypeOf();
@@ -171,6 +289,282 @@ describe("ObjectSet", () => {
171
289
  "mom": base => base.pivotTo("lead").aggregate("$count")
172
290
  });
173
291
  });
292
+ it("has correct aggregation keys", () => {
293
+ fauxObjectSet.withProperties({
294
+ "integer": base => base.pivotTo("lead").aggregate("$count"),
295
+ "integerNumericAgg": base => base.pivotTo("lead").aggregate("employeeId:sum"),
296
+ "string": base => base.pivotTo("lead").aggregate("class:collectList"),
297
+ "stringDoesNotHaveNumericAgg": base =>
298
+ // @ts-expect-error
299
+ base.pivotTo("lead").aggregate("class:sum"),
300
+ "isActive": base => base.pivotTo("lead").aggregate("isActive:approximateDistinct"),
301
+ "attachment": base => base.pivotTo("lead").aggregate("attachment:collectList"),
302
+ "geopoint": base => base.pivotTo("lead").aggregate("geopoint:collectList"),
303
+ "numericTimeseries": base =>
304
+ // @ts-expect-error
305
+ base.pivotTo("lead").aggregate("timeseries:sum"),
306
+ "numericTimeseriesExactDistinct": base => base.pivotTo("lead").aggregate("timeseries:exactDistinct"),
307
+ "mediaReference": base =>
308
+ // @ts-expect-error
309
+ base.pivotTo("lead").aggregate("mediaReference:avg"),
310
+ "mediaReferenceExactDistinct": base => base.pivotTo("lead").aggregate("mediaReference:exactDistinct"),
311
+ "geotimeSeriesReference": base =>
312
+ // @ts-expect-error
313
+ base.pivotTo("lead").aggregate("geotimeSeriesReference:sum"),
314
+ "geotimeSeriesReferenceExactDistinct": base => base.pivotTo("lead").aggregate("geotimeSeriesReference:exactDistinct"),
315
+ "lastUpdated": base => {
316
+ base.pivotTo("lead").aggregate("lastUpdated:approximateDistinct");
317
+ base.pivotTo("lead").aggregate("lastUpdated:exactDistinct");
318
+ base.pivotTo("lead").aggregate("lastUpdated:max");
319
+ base.pivotTo("lead").aggregate("lastUpdated:min");
320
+ base.pivotTo("lead").aggregate("lastUpdated:collectList");
321
+ return base.pivotTo("lead").aggregate("lastUpdated:collectSet");
322
+ },
323
+ "dateOfJoining": base => {
324
+ base.pivotTo("lead").aggregate("dateOfJoining:approximateDistinct");
325
+ base.pivotTo("lead").aggregate("dateOfJoining:exactDistinct");
326
+ base.pivotTo("lead").aggregate("dateOfJoining:max");
327
+ base.pivotTo("lead").aggregate("dateOfJoining:min");
328
+ base.pivotTo("lead").aggregate("dateOfJoining:collectList");
329
+ return base.pivotTo("lead").aggregate("dateOfJoining:collectSet");
330
+ }
331
+ });
332
+ });
333
+ it("has correct aggregation return types", async () => {
334
+ const aggTestObjectSet = fauxObjectSet.withProperties({
335
+ "maxHasSameType": base => base.pivotTo("lead").aggregate("dateOfJoining:max"),
336
+ "minHasSameType": base => base.pivotTo("lead").aggregate("dateOfJoining:min"),
337
+ "approximateDistinctNumberNoUndefined": base => base.pivotTo("lead").aggregate("employeeId:approximateDistinct"),
338
+ "exactDistinctNumberNoUndefined": base => base.pivotTo("lead").aggregate("employeeId:exactDistinct"),
339
+ "countNumberNoUndefined": base => base.pivotTo("lead").aggregate("$count"),
340
+ "sumNumber": base => base.pivotTo("lead").aggregate("employeeId:sum"),
341
+ "avgNumber": base => base.pivotTo("lead").aggregate("employeeId:avg")
342
+ }).fetchPage();
343
+ const result = (await aggTestObjectSet).data[0];
344
+ expectTypeOf((await aggTestObjectSet).data[0]).toEqualTypeOf();
345
+ expectTypeOf(result.maxHasSameType).toEqualTypeOf();
346
+ expectTypeOf(result.minHasSameType).toEqualTypeOf();
347
+ expectTypeOf(result.approximateDistinctNumberNoUndefined).toEqualTypeOf();
348
+ expectTypeOf(result.exactDistinctNumberNoUndefined).toEqualTypeOf();
349
+ expectTypeOf(result.countNumberNoUndefined).toEqualTypeOf();
350
+ expectTypeOf(result.sumNumber).toEqualTypeOf();
351
+ expectTypeOf(result.avgNumber).toEqualTypeOf();
352
+ });
353
+ });
354
+ describe("aggregate", () => {
355
+ it("has correct aggregation keys", () => {
356
+ void fauxObjectSet.aggregate({
357
+ "$select": {
358
+ "lastUpdated:max": "asc",
359
+ "lastUpdated:min": "desc",
360
+ "lastUpdated:approximateDistinct": "asc",
361
+ "lastUpdated:exactDistinct": "desc",
362
+ "dateOfJoining:max": "desc",
363
+ "dateOfJoining:min": "asc",
364
+ "dateOfJoining:approximateDistinct": "asc",
365
+ "dateOfJoining:exactDistinct": "desc"
366
+ }
367
+ });
368
+ });
369
+ });
370
+ describe("expressions", () => {
371
+ "Test all property types";
372
+
373
+ describe("numeric expressions", () => {
374
+ it("provides correct methods off of selected numeric derived property definitions", () => {
375
+ fauxObjectSet.withProperties({
376
+ "myProp1": base => {
377
+ const selectedInteger = base.pivotTo("lead").selectProperty("employeeId");
378
+ expectTypeOf(selectedInteger).toEqualTypeOf;
379
+ selectedInteger.add(1);
380
+ selectedInteger.subtract(1);
381
+ selectedInteger.multiply(1);
382
+ selectedInteger.divide(1);
383
+ selectedInteger.abs();
384
+ selectedInteger.negate();
385
+ selectedInteger.max(1);
386
+ selectedInteger.min(1);
387
+
388
+ // @ts-expect-error
389
+ selectedInteger.extractPart("1");
390
+ expectTypeOf(base.pivotTo("lead").selectProperty("performanceScore")).toEqualTypeOf();
391
+ expectTypeOf(base.pivotTo("lead").selectProperty("rank")).toEqualTypeOf();
392
+ expectTypeOf(base.pivotTo("lead").selectProperty("yearsOfExperience")).toEqualTypeOf();
393
+ expectTypeOf(base.pivotTo("lead").selectProperty("hourlyRate")).toEqualTypeOf();
394
+ return selectedInteger;
395
+ }
396
+ });
397
+ });
398
+ it("provides correct methods off of selection definitions", () => {
399
+ fauxObjectSet.withProperties({
400
+ "myProp1": base => {
401
+ const selectedInteger = base.pivotTo("lead").selectProperty("employeeId");
402
+ expectTypeOf(selectedInteger).toEqualTypeOf;
403
+ selectedInteger.add(1);
404
+ selectedInteger.subtract(1);
405
+ selectedInteger.multiply(1);
406
+ selectedInteger.divide(1);
407
+ selectedInteger.abs();
408
+ selectedInteger.negate();
409
+ selectedInteger.max(1);
410
+ selectedInteger.min(1);
411
+
412
+ // @ts-expect-error
413
+ selectedInteger.extractPart("1");
414
+ expectTypeOf(base.pivotTo("lead").selectProperty("performanceScore")).toEqualTypeOf();
415
+ expectTypeOf(base.pivotTo("lead").selectProperty("rank")).toEqualTypeOf();
416
+ expectTypeOf(base.pivotTo("lead").selectProperty("yearsOfExperience")).toEqualTypeOf();
417
+ expectTypeOf(base.pivotTo("lead").selectProperty("hourlyRate")).toEqualTypeOf();
418
+ return selectedInteger;
419
+ }
420
+ });
421
+ });
422
+ it("provides correct methods off of aggregated properties", () => {
423
+ fauxObjectSet.withProperties({
424
+ "myProp1": base => {
425
+ const maxAggregation = base.pivotTo("lead").aggregate("employeeId:max");
426
+ expectTypeOf(maxAggregation).toEqualTypeOf;
427
+ maxAggregation.add(1);
428
+ maxAggregation.subtract(1);
429
+ maxAggregation.multiply(1);
430
+ maxAggregation.divide(1);
431
+ maxAggregation.abs();
432
+ maxAggregation.negate();
433
+ maxAggregation.max(1);
434
+ maxAggregation.min(1);
435
+ expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:sum")).toEqualTypeOf();
436
+ expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:avg")).toEqualTypeOf();
437
+ expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:min")).toEqualTypeOf();
438
+ const collectList = base.pivotTo("peeps").aggregate("employeeId:collectList");
439
+ expectTypeOf(collectList).toEqualTypeOf();
440
+
441
+ // @ts-expect-error
442
+ collectList.plus(1);
443
+ expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:collectList")).toEqualTypeOf();
444
+ return maxAggregation;
445
+ }
446
+ });
447
+ });
448
+ it("correctly coerces numeric types", () => {
449
+ fauxObjectSet.withProperties({
450
+ "myProp1": base => {
451
+ const intAndLong = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("yearsOfExperience")).add(base.selectProperty("employeeId"));
452
+ expectTypeOf(intAndLong).toEqualTypeOf();
453
+ const intAndDouble = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("performanceScore")).add(base.selectProperty("employeeId"));
454
+ expectTypeOf(intAndDouble).toEqualTypeOf();
455
+ const longAndDouble = base.pivotTo("lead").selectProperty("yearsOfExperience").add(base.selectProperty("performanceScore")).add(base.selectProperty("yearsOfExperience"));
456
+ expectTypeOf(longAndDouble).toEqualTypeOf();
457
+ const longAndLong = base.pivotTo("lead").selectProperty("yearsOfExperience").add(base.selectProperty("yearsOfExperience"));
458
+ expectTypeOf(longAndLong).toEqualTypeOf();
459
+ const intAndInt = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("employeeId"));
460
+ expectTypeOf(intAndInt).toEqualTypeOf();
461
+ const intLongDoubleChain = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("yearsOfExperience")).add(base.selectProperty("employeeId")).add(base.selectProperty("performanceScore")).add(base.selectProperty("employeeId"));
462
+ expectTypeOf(intLongDoubleChain).toEqualTypeOf();
463
+ const shortAndIntReturnsInt = base.pivotTo("lead").selectProperty("rank").add(base.selectProperty("employeeId"));
464
+ expectTypeOf(shortAndIntReturnsInt).toEqualTypeOf();
465
+ const shortAndFloatReturnsDouble = base.pivotTo("lead").selectProperty("rank").add(base.selectProperty("hourlyRate"));
466
+ expectTypeOf(shortAndFloatReturnsDouble).toEqualTypeOf();
467
+ return intLongDoubleChain;
468
+ }
469
+ });
470
+ });
471
+ it("allows adding number literals as a double", () => {
472
+ fauxObjectSet.withProperties({
473
+ "myProp1": base => {
474
+ const plus = base.pivotTo("lead").selectProperty("employeeId").add(1);
475
+ expectTypeOf(plus).toEqualTypeOf();
476
+ return plus;
477
+ }
478
+ });
479
+ });
480
+ it("allows adding literals via base.constant", () => {
481
+ fauxObjectSet.withProperties({
482
+ "myProp1": base => {
483
+ const plus = base.pivotTo("lead").selectProperty("employeeId").add(base.constant.double(1));
484
+ expectTypeOf(plus).toEqualTypeOf();
485
+ const intPlusIntReturnsInt = base.pivotTo("lead").selectProperty("employeeId").add(base.constant.integer(1));
486
+ expectTypeOf(intPlusIntReturnsInt).toEqualTypeOf();
487
+ return plus;
488
+ }
489
+ });
490
+ });
491
+ it("allows correctly typed nested property definitions", () => {
492
+ fauxObjectSet.withProperties({
493
+ "myProp1": base => {
494
+ const nested = base.pivotTo("lead").selectProperty("employeeId").add(base.pivotTo("peeps").aggregate("employeeId:sum"));
495
+ expectTypeOf(nested).toEqualTypeOf();
496
+ return nested;
497
+ }
498
+ });
499
+ });
500
+ it("allows correctly types property keys off the linked OT", () => {
501
+ fauxObjectSet.withProperties({
502
+ "myProp1": base => {
503
+ const nested = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("performanceScore"));
504
+ expectTypeOf(nested).toEqualTypeOf();
505
+ return nested;
506
+ }
507
+ });
508
+ });
509
+
510
+ // it("allows correctly types property keys off the base OT", () => {});
511
+ });
512
+ describe("datetime expressions", () => {
513
+ it("provides correct methods off of datetime selections", () => {
514
+ fauxObjectSet.withProperties({
515
+ "myProp1": base => {
516
+ const selectedDatetime = base.pivotTo("lead").selectProperty("dateOfJoining");
517
+ expectTypeOf(selectedDatetime).toEqualTypeOf();
518
+ selectedDatetime.max(base.selectProperty("dateOfJoining"));
519
+ selectedDatetime.min(base.selectProperty("lastUpdated"));
520
+ expectTypeOf(base.pivotTo("lead").selectProperty("lastUpdated")).toEqualTypeOf();
521
+ return selectedDatetime;
522
+ }
523
+ });
524
+ });
525
+ it("correctly coerces datetime types", () => {
526
+ fauxObjectSet.withProperties({
527
+ "myProp1": base => {
528
+ const max = base.pivotTo("lead").selectProperty("dateOfJoining").max(base.selectProperty("lastUpdated"));
529
+ expectTypeOf(max).toEqualTypeOf();
530
+ const min = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.selectProperty("dateOfJoining"));
531
+ expectTypeOf(min).toEqualTypeOf();
532
+ return max;
533
+ }
534
+ });
535
+ });
536
+ it("allows adding literals via base.constant", () => {
537
+ fauxObjectSet.withProperties({
538
+ "myProp1": base => {
539
+ const dateAndDateReturnDate = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.constant.datetime("2025-01-01T00:00:00Z"));
540
+ expectTypeOf(dateAndDateReturnDate).toEqualTypeOf();
541
+ const dateAndTimeReturnTime = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.constant.timestamp("2025-01-01T00:00:00Z"));
542
+ expectTypeOf(dateAndTimeReturnTime).toEqualTypeOf();
543
+ return dateAndTimeReturnTime;
544
+ }
545
+ });
546
+ });
547
+ it("allows correctly typed nested property definitions", () => {
548
+ fauxObjectSet.withProperties({
549
+ "myProp1": base => {
550
+ const nested = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.pivotTo("lead").pivotTo("lead").selectProperty("lastUpdated"));
551
+ expectTypeOf(nested).toEqualTypeOf();
552
+ return nested;
553
+ }
554
+ });
555
+ });
556
+ it("allows correctly typed property keys off the linked OT", () => {
557
+ fauxObjectSet.withProperties({
558
+ "myProp1": base => {
559
+ const nested = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.selectProperty("lastUpdated"));
560
+ expectTypeOf(nested).toEqualTypeOf();
561
+ return nested;
562
+ }
563
+ });
564
+ });
565
+
566
+ // it("allows correctly typed property keys off the base OT", () => {});
567
+ });
174
568
  });
175
569
  });
176
570
  //# sourceMappingURL=ObjectSet.test.js.map