@osdk/client 2.2.0-rc.24 → 2.3.0-beta.2

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 (38) hide show
  1. package/CHANGELOG.md +4 -9
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +41 -1
  5. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  6. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
  7. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  8. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  9. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  10. package/build/browser/objectSet/ObjectSet.test.js +85 -106
  11. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  12. package/build/browser/util/UserAgent.js +1 -1
  13. package/build/browser/util/UserAgent.js.map +1 -1
  14. package/build/cjs/{chunk-GTDO4U7H.cjs → chunk-JEHRAVC5.cjs} +143 -31
  15. package/build/cjs/chunk-JEHRAVC5.cjs.map +1 -0
  16. package/build/cjs/{chunk-W5PFESFR.cjs → chunk-ZV5KKQ4R.cjs} +2 -2
  17. package/build/cjs/{chunk-W5PFESFR.cjs.map → chunk-ZV5KKQ4R.cjs.map} +1 -1
  18. package/build/cjs/index.cjs +47 -47
  19. package/build/cjs/index.cjs.map +1 -1
  20. package/build/cjs/public/internal.cjs +8 -8
  21. package/build/cjs/public/unstable-do-not-use.cjs +8 -8
  22. package/build/esm/Client.js +1 -1
  23. package/build/esm/Client.js.map +1 -1
  24. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +41 -1
  25. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  26. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
  27. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  28. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  29. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  30. package/build/esm/objectSet/ObjectSet.test.js +85 -106
  31. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  32. package/build/esm/util/UserAgent.js +1 -1
  33. package/build/esm/util/UserAgent.js.map +1 -1
  34. package/build/types/Client.d.ts +1 -1
  35. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
  36. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
  37. package/package.json +11 -11
  38. package/build/cjs/chunk-GTDO4U7H.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,17 +1,12 @@
1
1
  # @osdk/client
2
2
 
3
- ## 2.2.0-rc.24
3
+ ## 2.3.0-beta.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - cdd3154: Revert allowing explicitly passing undefined values to reset on actions
8
- - 5665b18: Remove selection RDPs from the API
9
- - a146ce4: Cleanup RDP API
10
- - Updated dependencies [5665b18]
11
- - Updated dependencies [a146ce4]
12
- - @osdk/api@2.2.0-rc.24
13
- - @osdk/generator-converters@2.2.0-rc.24
14
- - @osdk/client.unstable@2.2.0-rc.24
7
+ - @osdk/api@2.3.0-beta.2
8
+ - @osdk/client.unstable@2.3.0-beta.2
9
+ - @osdk/generator-converters@2.3.0-beta.2
15
10
 
16
11
  ## 2.2.0-beta.23
17
12
 
@@ -21,7 +21,7 @@
21
21
  export const additionalContext = Symbol("additionalContext");
22
22
 
23
23
  // BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
24
- const MaxOsdkVersion = "2.2.0";
24
+ const MaxOsdkVersion = "2.3.0";
25
25
  // END: THIS IS GENERATED CODE. DO NOT EDIT.
26
26
 
27
27
  const ErrorMessage = Symbol("ErrorMessage");
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\"> | Experiment<\"2.2.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.2.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\"> | Experiment<\"2.2.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.3.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
@@ -16,6 +16,7 @@
16
16
 
17
17
  import invariant from "tiny-invariant";
18
18
  import { modernToLegacyWhereClause } from "../internal/conversions/modernToLegacyWhereClause.js";
19
+ import { derivedPropertyDefinitionFactory } from "./derivedPropertyDefinitionFactory.js";
19
20
  /** @internal */
20
21
  export function createWithPropertiesObjectSet(objectType, objectSet, definitionMap, fromBaseObjectSet = false) {
21
22
  return {
@@ -80,9 +81,48 @@ export function createWithPropertiesObjectSet(objectType, objectSet, definitionM
80
81
  objectSet: objectSet,
81
82
  operation: aggregationOperationDefinition
82
83
  };
83
- const selectorResult = {};
84
+ const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
84
85
  definitionMap.set(selectorResult, wrappedObjectSet);
85
86
  return selectorResult;
87
+ },
88
+ selectProperty: name => {
89
+ if (fromBaseObjectSet) {
90
+ const wrappedObjectSet = {
91
+ type: "property",
92
+ apiName: name
93
+ };
94
+ const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
95
+ definitionMap.set(selectorResult, wrappedObjectSet);
96
+ return selectorResult;
97
+ }
98
+ const wrappedObjectSet = {
99
+ type: "selection",
100
+ objectSet: objectSet,
101
+ operation: {
102
+ type: "get",
103
+ selectedPropertyApiName: name
104
+ }
105
+ };
106
+ const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
107
+ definitionMap.set(selectorResult, wrappedObjectSet);
108
+ return selectorResult;
109
+ },
110
+ constant: {
111
+ double: () => {
112
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
113
+ },
114
+ integer: () => {
115
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
116
+ },
117
+ long: () => {
118
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
119
+ },
120
+ datetime: () => {
121
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
122
+ },
123
+ timestamp: () => {
124
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
125
+ }
86
126
  }
87
127
  };
88
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createWithPropertiesObjectSet.js","names":["invariant","modernToLegacyWhereClause","createWithPropertiesObjectSet","objectType","objectSet","definitionMap","fromBaseObjectSet","pivotTo","link","type","where","clause","aggregate","aggregation","opt","splitAggregation","split","length","process","env","NODE_ENV","aggregationPropertyName","aggregationOperation","aggregationOperationDefinition","selectedPropertyApiName","approximatePercentile","percentile","limit","undefined","wrappedObjectSet","operation","selectorResult","set"],"sources":["createWithPropertiesObjectSet.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 { DerivedProperty, ObjectOrInterfaceDefinition } from \"@osdk/api\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n SelectedPropertyOperation,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\n\ntype WithConstSelect<Q extends ObjectOrInterfaceDefinition> =\n DerivedProperty.AggregateBuilder<Q, false>;\n\n/** @internal */\nexport function createWithPropertiesObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n>(\n objectType: Q,\n objectSet: WireObjectSet,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n fromBaseObjectSet: boolean = false,\n): WithConstSelect<Q> {\n return {\n pivotTo: (link) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"searchAround\",\n objectSet,\n link,\n }, definitionMap);\n },\n where: (clause) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n }, definitionMap);\n },\n aggregate: (aggregation: string, opt: any) => {\n const splitAggregation = aggregation.split(\":\");\n invariant(\n splitAggregation.length === 2 || splitAggregation[0] === \"$count\",\n \"Invalid aggregation format\",\n );\n const [aggregationPropertyName, aggregationOperation] = splitAggregation;\n let aggregationOperationDefinition: SelectedPropertyOperation;\n switch (aggregationOperation) {\n case \"sum\":\n case \"avg\":\n case \"min\":\n case \"max\":\n case \"exactDistinct\":\n case \"approximateDistinct\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n };\n break;\n case \"approximatePercentile\":\n aggregationOperationDefinition = {\n type: \"approximatePercentile\",\n selectedPropertyApiName: aggregationPropertyName,\n approximatePercentile: opt?.percentile ?? .5,\n };\n break;\n case \"collectSet\":\n case \"collectList\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n limit: opt?.limit ?? 100,\n };\n break;\n case undefined:\n if (aggregationPropertyName === \"$count\") {\n aggregationOperationDefinition = {\n type: \"count\",\n };\n break;\n }\n default:\n invariant(\n false,\n \"Invalid aggregation operation \" + aggregationOperation,\n );\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: aggregationOperationDefinition,\n };\n const selectorResult = {} as DerivedProperty.Definition<any, any>;\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sDAAsD;AAKhG;AACA,OAAO,SAASC,6BAA6BA,CAG3CC,UAAa,EACbC,SAAwB,EACxBC,aAAkD,EAClDC,iBAA0B,GAAG,KAAK,EACd;EACpB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;MACjB,OAAON,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,cAAc;QACpBL,SAAS;QACTI;MACF,CAAC,EAAEH,aAAa,CAAC;IACnB,CAAC;IACDK,KAAK,EAAGC,MAAM,IAAK;MACjB,OAAOT,6BAA6B,CAACC,UAAU,EAA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F;QACF;UACES,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAApB,SAAS,QAEP,gCAAgC,GAAGsB,oBAAoB,IAFzDtB,SAAS;MAIb;MACA,MAAM6B,gBAA2C,GAAG;QAClDpB,IAAI,EAAE,WAAW;QACjBL,SAAS,EAAEA,SAAS;QACpB0B,SAAS,EAAEP;MACb,CAAC;MACD,MAAMQ,cAAc,GAAG,CAAC,CAAyC;MACjE1B,aAAa,CAAC2B,GAAG,CAACD,cAAc,EAAEF,gBAAgB,CAAC;MACnD,OAAOE,cAAc;IACvB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"createWithPropertiesObjectSet.js","names":["invariant","modernToLegacyWhereClause","derivedPropertyDefinitionFactory","createWithPropertiesObjectSet","objectType","objectSet","definitionMap","fromBaseObjectSet","pivotTo","link","type","where","clause","aggregate","aggregation","opt","splitAggregation","split","length","process","env","NODE_ENV","aggregationPropertyName","aggregationOperation","aggregationOperationDefinition","selectedPropertyApiName","approximatePercentile","percentile","limit","undefined","wrappedObjectSet","operation","selectorResult","set","selectProperty","name","apiName","constant","double","integer","long","datetime","timestamp"],"sources":["createWithPropertiesObjectSet.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 { DerivedProperty, ObjectOrInterfaceDefinition } from \"@osdk/api\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n SelectedPropertyOperation,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { derivedPropertyDefinitionFactory } from \"./derivedPropertyDefinitionFactory.js\";\n\ntype WithConstSelect<Q extends ObjectOrInterfaceDefinition> =\n & DerivedProperty.SelectPropertyBuilder<Q, false>\n & {\n constant: DerivedProperty.Builder<Q, true>[\"constant\"];\n };\n\n/** @internal */\nexport function createWithPropertiesObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n>(\n objectType: Q,\n objectSet: WireObjectSet,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n fromBaseObjectSet: boolean = false,\n): WithConstSelect<Q> {\n return {\n pivotTo: (link) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"searchAround\",\n objectSet,\n link,\n }, definitionMap);\n },\n where: (clause) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n }, definitionMap);\n },\n aggregate: (aggregation: string, opt: any) => {\n const splitAggregation = aggregation.split(\":\");\n invariant(\n splitAggregation.length === 2 || splitAggregation[0] === \"$count\",\n \"Invalid aggregation format\",\n );\n const [aggregationPropertyName, aggregationOperation] = splitAggregation;\n let aggregationOperationDefinition: SelectedPropertyOperation;\n switch (aggregationOperation) {\n case \"sum\":\n case \"avg\":\n case \"min\":\n case \"max\":\n case \"exactDistinct\":\n case \"approximateDistinct\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n };\n break;\n case \"approximatePercentile\":\n aggregationOperationDefinition = {\n type: \"approximatePercentile\",\n selectedPropertyApiName: aggregationPropertyName,\n approximatePercentile: opt?.percentile ?? .5,\n };\n break;\n case \"collectSet\":\n case \"collectList\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n limit: opt?.limit ?? 100,\n };\n break;\n case undefined:\n if (aggregationPropertyName === \"$count\") {\n aggregationOperationDefinition = {\n type: \"count\",\n };\n break;\n }\n default:\n invariant(\n false,\n \"Invalid aggregation operation \" + aggregationOperation,\n );\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: aggregationOperationDefinition,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n selectProperty: (name) => {\n if (fromBaseObjectSet) {\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"property\",\n apiName: name,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: {\n type: \"get\",\n selectedPropertyApiName: name,\n },\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n constant: {\n double: (value) => {\n invariant(false, \"Not supported\");\n },\n integer: (value) => {\n invariant(false, \"Not supported\");\n },\n long: (value) => {\n invariant(false, \"Not supported\");\n },\n datetime: (value) => {\n invariant(false, \"Not supported\");\n },\n timestamp: (value) => {\n invariant(false, \"Not supported\");\n },\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,gCAAgC,QAAQ,uCAAuC;AAQxF;AACA,OAAO,SAASC,6BAA6BA,CAG3CC,UAAa,EACbC,SAAwB,EACxBC,aAAkD,EAClDC,iBAA0B,GAAG,KAAK,EACd;EACpB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;MACjB,OAAON,6BAA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AM,EAAEA,CAAA,KAAW;QACjBnB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACDuC,OAAO,EAAEA,CAAA,KAAW;QAClBpB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACDwC,IAAI,EAAEA,CAAA,KAAW;QACfrB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACDyC,QAAQ,EAAEA,CAAA,KAAW;QACnBtB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACD0C,SAAS,EAAEA,CAAA,KAAW;QACpBvB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -24,23 +24,39 @@ describe(createWithPropertiesObjectSet, () => {
24
24
  type: "methodInput"
25
25
  }, map);
26
26
  const result = {
27
- "derivedPropertyName": base => base.pivotTo("lead").aggregate("employeeId:avg")
27
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId")
28
28
  }["derivedPropertyName"](deriveObjectSet);
29
29
  const definition = map.get(result);
30
30
  expect(definition).toMatchInlineSnapshot(`
31
- {
32
- "objectSet": {
33
- "link": "lead",
31
+ {
34
32
  "objectSet": {
35
- "type": "methodInput",
33
+ "link": "lead",
34
+ "objectSet": {
35
+ "type": "methodInput",
36
+ },
37
+ "type": "searchAround",
36
38
  },
37
- "type": "searchAround",
38
- },
39
- "operation": {
40
- "selectedPropertyApiName": "employeeId",
41
- "type": "avg",
42
- },
43
- "type": "selection",
39
+ "operation": {
40
+ "selectedPropertyApiName": "employeeId",
41
+ "type": "get",
42
+ },
43
+ "type": "selection",
44
+ }
45
+ `);
46
+ });
47
+ it("correctly allows select property off the base object set", () => {
48
+ const map = new Map();
49
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
50
+ type: "methodInput"
51
+ }, map, true);
52
+ const result = {
53
+ "derivedPropertyName": base => base.selectProperty("employeeId")
54
+ }["derivedPropertyName"](deriveObjectSet);
55
+ const definition = map.get(result);
56
+ expect(definition).toMatchInlineSnapshot(`
57
+ {
58
+ "apiName": "employeeId",
59
+ "type": "property",
44
60
  }
45
61
  `);
46
62
  });
@@ -96,5 +112,122 @@ describe(createWithPropertiesObjectSet, () => {
96
112
  }
97
113
  `);
98
114
  });
115
+ describe("expressions", () => {
116
+ it("can handle expressions referencing other property keys", () => {
117
+ const map = new Map();
118
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
119
+ type: "methodInput"
120
+ }, map, true);
121
+ const result = {
122
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("employeeId"))
123
+ // "secondaryDerivedPropertyName": (base) =>
124
+ // base.pivotTo("lead").aggregate("employeeId:avg").divide("employeeId", 2),
125
+ }["derivedPropertyName"](deriveObjectSet);
126
+ const definition = map.get(result);
127
+ expect(definition).toMatchInlineSnapshot(`
128
+ {
129
+ "properties": [
130
+ {
131
+ "objectSet": {
132
+ "link": "lead",
133
+ "objectSet": {
134
+ "type": "methodInput",
135
+ },
136
+ "type": "searchAround",
137
+ },
138
+ "operation": {
139
+ "selectedPropertyApiName": "employeeId",
140
+ "type": "get",
141
+ },
142
+ "type": "selection",
143
+ },
144
+ {
145
+ "apiName": "employeeId",
146
+ "type": "property",
147
+ },
148
+ ],
149
+ "type": "add",
150
+ }
151
+ `);
152
+ });
153
+
154
+ // TODO: Add test for literal
155
+ it("can handle nested definitions in an expression", () => {
156
+ const map = new Map();
157
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
158
+ type: "methodInput"
159
+ }, map);
160
+ const result = {
161
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId").add(base.pivotTo("lead").selectProperty("employeeId"))
162
+ }["derivedPropertyName"](deriveObjectSet);
163
+ const definition = map.get(result);
164
+ expect(definition).toMatchInlineSnapshot(`
165
+ {
166
+ "properties": [
167
+ {
168
+ "objectSet": {
169
+ "link": "lead",
170
+ "objectSet": {
171
+ "type": "methodInput",
172
+ },
173
+ "type": "searchAround",
174
+ },
175
+ "operation": {
176
+ "selectedPropertyApiName": "employeeId",
177
+ "type": "get",
178
+ },
179
+ "type": "selection",
180
+ },
181
+ {
182
+ "objectSet": {
183
+ "link": "lead",
184
+ "objectSet": {
185
+ "type": "methodInput",
186
+ },
187
+ "type": "searchAround",
188
+ },
189
+ "operation": {
190
+ "selectedPropertyApiName": "employeeId",
191
+ "type": "get",
192
+ },
193
+ "type": "selection",
194
+ },
195
+ ],
196
+ "type": "add",
197
+ }
198
+ `);
199
+ });
200
+ });
201
+ it("handles datetime expressions", () => {
202
+ const map = new Map();
203
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
204
+ type: "methodInput"
205
+ }, map);
206
+ const result = {
207
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("startDate").extractPart("MONTHS"),
208
+ "secondaryDerivedPropertyName": base => base.pivotTo("lead").selectProperty("startDate").min(base.pivotTo("lead").selectProperty("startDate"))
209
+ }["derivedPropertyName"](deriveObjectSet);
210
+ const definition = map.get(result);
211
+ expect(definition).toMatchInlineSnapshot(`
212
+ {
213
+ "part": "MONTHS",
214
+ "property": {
215
+ "objectSet": {
216
+ "link": "lead",
217
+ "objectSet": {
218
+ "type": "methodInput",
219
+ },
220
+ "type": "searchAround",
221
+ },
222
+ "operation": {
223
+ "selectedPropertyApiName": "startDate",
224
+ "type": "get",
225
+ },
226
+ "type": "selection",
227
+ },
228
+ "type": "extract",
229
+ }
230
+ `);
231
+ });
99
232
  });
100
233
  //# sourceMappingURL=createWithPropertiesObjectSet.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createWithPropertiesObjectSet.test.js","names":["Employee","describe","expect","it","createWithPropertiesObjectSet","map","Map","deriveObjectSet","type","result","base","pivotTo","aggregate","definition","get","toMatchInlineSnapshot","clause","percentile","limit","secondResult","secondDefinition"],"sources":["createWithPropertiesObjectSet.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { createWithPropertiesObjectSet } from \"./createWithPropertiesObjectSet.js\";\n\ndescribe(createWithPropertiesObjectSet, () => {\n it(\"correctly creates basic object set with derived properties\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"employeeId:avg\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"avg\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n it(\"correctly handles multiple definitions in one clause\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"employeeId:approximatePercentile\", {\n percentile: 0.5,\n }),\n\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"fullName:collectSet\", {\n limit: 10,\n }),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n const secondResult = clause[\"secondaryDerivedPropertyName\"](\n deriveObjectSet,\n );\n const secondDefinition = map.get(secondResult);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"approximatePercentile\": 0.5,\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"approximatePercentile\",\n },\n \"type\": \"selection\",\n }\n `);\n\n expect(secondDefinition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"limit\": 10,\n \"selectedPropertyApiName\": \"fullName\",\n \"type\": \"collectSet\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,6BAA6B,QAAQ,oCAAoC;AAElFH,QAAQ,CAACG,6BAA6B,EAAE,MAAM;EAC5CD,EAAE,CAAC,4DAA4D,EAAE,MAAM;IACrE,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CAACJ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AAY,CAAC;IAE9CjB,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IAEJb,MAAM,CAACkB,gBAAgB,CAAC,CAACL,qBAAqB,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createWithPropertiesObjectSet.test.js","names":["Employee","describe","expect","it","createWithPropertiesObjectSet","map","Map","deriveObjectSet","type","result","base","pivotTo","selectProperty","definition","get","toMatchInlineSnapshot","clause","aggregate","percentile","limit","secondResult","secondDefinition","add","extractPart","min"],"sources":["createWithPropertiesObjectSet.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { createWithPropertiesObjectSet } from \"./createWithPropertiesObjectSet.js\";\n\ndescribe(createWithPropertiesObjectSet, () => {\n it(\"correctly creates basic object set with derived properties\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n it(\"correctly allows select property off the base object set\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(\n Employee,\n {\n type: \"methodInput\",\n },\n map,\n true,\n );\n\n const clause = {\n \"derivedPropertyName\": (base) => base.selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"apiName\": \"employeeId\",\n \"type\": \"property\",\n }\n `);\n });\n\n it(\"correctly handles multiple definitions in one clause\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"employeeId:approximatePercentile\", {\n percentile: 0.5,\n }),\n\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"fullName:collectSet\", {\n limit: 10,\n }),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n const secondResult = clause[\"secondaryDerivedPropertyName\"](\n deriveObjectSet,\n );\n const secondDefinition = map.get(secondResult);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"approximatePercentile\": 0.5,\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"approximatePercentile\",\n },\n \"type\": \"selection\",\n }\n `);\n\n expect(secondDefinition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"limit\": 10,\n \"selectedPropertyApiName\": \"fullName\",\n \"type\": \"collectSet\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n describe(\"expressions\", () => {\n it(\"can handle expressions referencing other property keys\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(\n Employee,\n {\n type: \"methodInput\",\n },\n map,\n true,\n );\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\").add(\n base.selectProperty(\"employeeId\"),\n ),\n // \"secondaryDerivedPropertyName\": (base) =>\n // base.pivotTo(\"lead\").aggregate(\"employeeId:avg\").divide(\"employeeId\", 2),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"properties\": [\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n {\n \"apiName\": \"employeeId\",\n \"type\": \"property\",\n },\n ],\n \"type\": \"add\",\n }\n `);\n });\n\n // TODO: Add test for literal\n it(\"can handle nested definitions in an expression\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\").add(\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n ),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"properties\": [\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n ],\n \"type\": \"add\",\n }\n `);\n });\n });\n\n it(\"handles datetime expressions\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"startDate\").extractPart(\"MONTHS\"),\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"startDate\").min(\n base.pivotTo(\"lead\").selectProperty(\"startDate\"),\n ),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"part\": \"MONTHS\",\n \"property\": {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"startDate\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n \"type\": \"extract\",\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;A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CAAC;MAElCP,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFZ,EAAE,CAAC,8BAA8B,EAAE,MAAM;IACvC,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CAACJ,QAAQ,EAAE;MAC9DQ,IAAI,EAAE;IACR,CAAC,EAAEH,GAAG,CAAC;IAWP,MAAMI,MAAM,GATqC;MAC/C,qBAAqB,EAAGC,IAAI,IAC1BA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACC,cAAc,CAAC,WAAW,CAAC,CAACW,WAAW,CAAC,QAAQ,CAAC;MACxE,8BAA8B,EAAGb,IAAI,IACnCA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACC,cAAc,CAAC,WAAW,CAAC,CAACY,GAAG,CAClDd,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACC,cAAc,CAAC,WAAW,CACjD;IACJ,CAAC,CAEqB,qBAAqB,CAAC,CAACL,eAAe,CAAC;IAC7D,MAAMM,UAAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAElCP,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import invariant from "tiny-invariant";
18
+
19
+ /** @internal */
20
+ export function derivedPropertyDefinitionFactory(wireDefinition, definitionMap) {
21
+ const definition = {
22
+ abs() {
23
+ return derivedPropertyDefinitionFactory({
24
+ type: "absoluteValue",
25
+ property: wireDefinition
26
+ }, definitionMap);
27
+ },
28
+ negate() {
29
+ return derivedPropertyDefinitionFactory({
30
+ type: "negate",
31
+ property: wireDefinition
32
+ }, definitionMap);
33
+ },
34
+ max(value) {
35
+ return derivedPropertyDefinitionFactory({
36
+ type: "greatest",
37
+ properties: [wireDefinition, getDefinitionFromMap(value, definitionMap)]
38
+ }, definitionMap);
39
+ },
40
+ min(value) {
41
+ return derivedPropertyDefinitionFactory({
42
+ type: "least",
43
+ properties: [wireDefinition, getDefinitionFromMap(value, definitionMap)]
44
+ }, definitionMap);
45
+ },
46
+ add(value) {
47
+ return derivedPropertyDefinitionFactory({
48
+ type: "add",
49
+ properties: [wireDefinition, getDefinitionFromMap(value, definitionMap)]
50
+ }, definitionMap);
51
+ },
52
+ subtract(value) {
53
+ return derivedPropertyDefinitionFactory({
54
+ "type": "subtract",
55
+ "left": wireDefinition,
56
+ "right": getDefinitionFromMap(value, definitionMap)
57
+ }, definitionMap);
58
+ },
59
+ multiply(value) {
60
+ return derivedPropertyDefinitionFactory({
61
+ type: "multiply",
62
+ properties: [wireDefinition, getDefinitionFromMap(value, definitionMap)]
63
+ }, definitionMap);
64
+ },
65
+ divide(value) {
66
+ return derivedPropertyDefinitionFactory({
67
+ "type": "subtract",
68
+ "left": wireDefinition,
69
+ "right": getDefinitionFromMap(value, definitionMap)
70
+ }, definitionMap);
71
+ },
72
+ extractPart: part => {
73
+ return derivedPropertyDefinitionFactory({
74
+ type: "extract",
75
+ part,
76
+ property: wireDefinition
77
+ }, definitionMap);
78
+ }
79
+ };
80
+ definitionMap.set(definition, wireDefinition);
81
+ return definition;
82
+ }
83
+ const getDefinitionFromMap = (arg, definitionMap) => {
84
+ if (typeof arg === "object") {
85
+ const definition = definitionMap.get(arg);
86
+ !definition ? process.env.NODE_ENV !== "production" ? invariant(false, "Derived Property is not defined") : invariant(false) : void 0;
87
+ return definition;
88
+ } else if (typeof arg === "number") {
89
+ process.env.NODE_ENV !== "production" ? invariant(false, "Literals for derived properties are not yet supported") : invariant(false);
90
+ }
91
+ process.env.NODE_ENV !== "production" ? invariant(false, "Invalid argument type for a derived property") : invariant(false);
92
+ };
93
+ //# sourceMappingURL=derivedPropertyDefinitionFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derivedPropertyDefinitionFactory.js","names":["invariant","derivedPropertyDefinitionFactory","wireDefinition","definitionMap","definition","abs","type","property","negate","max","value","properties","getDefinitionFromMap","min","add","subtract","multiply","divide","extractPart","part","set","arg","get","process","env","NODE_ENV"],"sources":["derivedPropertyDefinitionFactory.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\n\n/** @internal */\nexport function derivedPropertyDefinitionFactory(\n wireDefinition: DerivedPropertyDefinition,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n): DerivedProperty.NumericPropertyDefinition<any, any> & {\n extractPart: DerivedProperty.DatetimePropertyDefinition<\n any,\n any\n >[\"extractPart\"];\n} {\n type RemoveSymbolKeys<T> = {\n [K in keyof T as K extends symbol ? never : K]: T[K];\n };\n\n const definition:\n & RemoveSymbolKeys<DerivedProperty.NumericPropertyDefinition<any, any>>\n & {\n extractPart: DerivedProperty.DatetimePropertyDefinition<\n any,\n any\n >[\"extractPart\"];\n } = {\n abs() {\n return derivedPropertyDefinitionFactory({\n type: \"absoluteValue\",\n property: wireDefinition,\n }, definitionMap);\n },\n negate() {\n return derivedPropertyDefinitionFactory({\n type: \"negate\",\n property: wireDefinition,\n }, definitionMap);\n },\n max(value) {\n return derivedPropertyDefinitionFactory({\n type: \"greatest\",\n properties: [\n wireDefinition,\n getDefinitionFromMap(value, definitionMap),\n ],\n }, definitionMap);\n },\n min(value) {\n return derivedPropertyDefinitionFactory({\n type: \"least\",\n properties: [\n wireDefinition,\n getDefinitionFromMap(value, definitionMap),\n ],\n }, definitionMap);\n },\n add(\n value,\n ) {\n return derivedPropertyDefinitionFactory({\n type: \"add\",\n properties: [\n wireDefinition,\n getDefinitionFromMap(value, definitionMap),\n ],\n }, definitionMap);\n },\n subtract(\n value,\n ) {\n return derivedPropertyDefinitionFactory({\n \"type\": \"subtract\",\n \"left\": wireDefinition,\n \"right\": getDefinitionFromMap(value, definitionMap),\n }, definitionMap);\n },\n multiply(\n value,\n ) {\n return derivedPropertyDefinitionFactory({\n type: \"multiply\",\n properties: [\n wireDefinition,\n getDefinitionFromMap(value, definitionMap),\n ],\n }, definitionMap);\n },\n divide(\n value,\n ) {\n return derivedPropertyDefinitionFactory({\n \"type\": \"subtract\",\n \"left\": wireDefinition,\n \"right\": getDefinitionFromMap(value, definitionMap),\n }, definitionMap);\n },\n extractPart: (part) => {\n return derivedPropertyDefinitionFactory({\n type: \"extract\",\n part,\n property: wireDefinition,\n }, definitionMap);\n },\n };\n\n definitionMap.set(definition, wireDefinition);\n return definition as any;\n}\n\nconst getDefinitionFromMap = (\n arg: string | number | DerivedProperty.Definition<any, any>,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n): DerivedPropertyDefinition => {\n if (typeof arg === \"object\") {\n const definition = definitionMap.get(arg);\n invariant(definition, \"Derived Property is not defined\");\n return definition;\n } else if (typeof arg === \"number\") {\n invariant(false, \"Literals for derived properties are not yet supported\");\n }\n invariant(false, \"Invalid argument type for a derived property\");\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,SAAS,MAAM,gBAAgB;;AAEtC;AACA,OAAO,SAASC,gCAAgCA,CAC9CC,cAAyC,EACzCC,aAAkD,EAMlD;EAKA,MAAMC,UAOH,GAAG;IACFC,GAAGA,CAAA,EAAG;MACJ,OAAOJ,gCAAgC,CAAC;QACtCK,IAAI,EAAE,eAAe;QACrBC,QAAQ,EAAEL;MACZ,CAAC,EAAEC,aAAa,CAAC;IACnB,CAAC;IACDK,MAAMA,CAAA,EAAG;MACP,OAAOP,gCAAgC,CAAC;QACtCK,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAEL;MACZ,CAAC,EAAEC,aAAa,CAAC;IACnB,CAAC;IACDM,GAAGA,CAACC,KAAK,EAAE;MACT,OAAOT,gCAAgC,CAAC;QACtCK,IAAI,EAAE,UAAU;QAChBK,UAAU,EAAE,CACVT,cAAc,EACdU,oBAAoB,CAACF,KAAK,EAAEP,aAAa,CAAC;MAE9C,CAAC,EAAEA,aAAa,CAAC;IACnB,CAAC;IACDU,GAAGA,CAACH,KAAK,EAAE;MACT,OAAOT,gCAAgC,CAAC;QACtCK,IAAI,EAAE,OAAO;QACbK,UAAU,EAAE,CACVT,cAAc,EACdU,oBAAoB,CAACF,KAAK,EAAEP,aAAa,CAAC;MAE9C,CAAC,EAAE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