@osdk/client 2.3.0-rc.11 → 2.4.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 (62) hide show
  1. package/CHANGELOG.md +111 -11
  2. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +41 -1
  3. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  4. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
  5. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  6. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  7. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  8. package/build/browser/index.js +1 -1
  9. package/build/browser/index.js.map +1 -1
  10. package/build/browser/object/mediaUpload.js +3 -0
  11. package/build/browser/object/mediaUpload.js.map +1 -1
  12. package/build/browser/objectSet/ObjectSet.test.js +85 -106
  13. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  14. package/build/browser/public-utils/hydrateObjectSetFromObjectRids.js +4 -1
  15. package/build/browser/public-utils/hydrateObjectSetFromObjectRids.js.map +1 -1
  16. package/build/browser/util/UserAgent.js +2 -2
  17. package/build/browser/util/UserAgent.js.map +1 -1
  18. package/build/browser/util/toDataValue.js +17 -1
  19. package/build/browser/util/toDataValue.js.map +1 -1
  20. package/build/browser/util/toDataValue.test.js +42 -2
  21. package/build/browser/util/toDataValue.test.js.map +1 -1
  22. package/build/cjs/{chunk-QHPACIXZ.cjs → chunk-YGJRXE4F.cjs} +136 -24
  23. package/build/cjs/chunk-YGJRXE4F.cjs.map +1 -0
  24. package/build/cjs/{chunk-LZ4GFSOQ.cjs → chunk-Z6X7WQDP.cjs} +73 -60
  25. package/build/cjs/chunk-Z6X7WQDP.cjs.map +1 -0
  26. package/build/cjs/index.cjs +10 -6
  27. package/build/cjs/index.d.cts +1 -1
  28. package/build/cjs/public/internal.cjs +12 -9
  29. package/build/cjs/public/internal.cjs.map +1 -1
  30. package/build/cjs/public/internal.d.cts +1 -1
  31. package/build/cjs/public/unstable-do-not-use.cjs +15 -15
  32. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +41 -1
  33. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  34. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
  35. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  36. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  37. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  38. package/build/esm/index.js +1 -1
  39. package/build/esm/index.js.map +1 -1
  40. package/build/esm/object/mediaUpload.js +3 -0
  41. package/build/esm/object/mediaUpload.js.map +1 -1
  42. package/build/esm/objectSet/ObjectSet.test.js +85 -106
  43. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  44. package/build/esm/public-utils/hydrateObjectSetFromObjectRids.js +4 -1
  45. package/build/esm/public-utils/hydrateObjectSetFromObjectRids.js.map +1 -1
  46. package/build/esm/util/UserAgent.js +2 -2
  47. package/build/esm/util/UserAgent.js.map +1 -1
  48. package/build/esm/util/toDataValue.js +17 -1
  49. package/build/esm/util/toDataValue.js.map +1 -1
  50. package/build/esm/util/toDataValue.test.js +42 -2
  51. package/build/esm/util/toDataValue.test.js.map +1 -1
  52. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
  53. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
  54. package/build/types/index.d.ts +1 -1
  55. package/build/types/index.d.ts.map +1 -1
  56. package/build/types/object/mediaUpload.d.ts +2 -1
  57. package/build/types/object/mediaUpload.d.ts.map +1 -1
  58. package/build/types/public-utils/hydrateObjectSetFromObjectRids.d.ts +1 -1
  59. package/build/types/public-utils/hydrateObjectSetFromObjectRids.d.ts.map +1 -1
  60. package/package.json +11 -11
  61. package/build/cjs/chunk-LZ4GFSOQ.cjs.map +0 -1
  62. package/build/cjs/chunk-QHPACIXZ.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,16 +1,5 @@
1
1
  # @osdk/client
2
2
 
3
- ## 2.3.0-rc.11
4
-
5
- ### Patch Changes
6
-
7
- - f82cff2: Remove Calculated RDPs and Media
8
- - Updated dependencies [43554b4]
9
- - Updated dependencies [f82cff2]
10
- - @osdk/client.unstable@2.3.0-rc.11
11
- - @osdk/api@2.3.0-rc.11
12
- - @osdk/generator-converters@2.3.0-rc.11
13
-
14
3
  ## 2.3.0-beta.10
15
4
 
16
5
  ### Minor Changes
@@ -125,6 +114,117 @@
125
114
  - @osdk/client.unstable@2.3.0-beta.2
126
115
  - @osdk/generator-converters@2.3.0-beta.2
127
116
 
117
+ ## 2.2.0
118
+
119
+ ### Patch Changes
120
+
121
+ - 322c5bc: Simulated release
122
+ - b61e9f5: Make Query Map Types Optional
123
+ - 7416ce4: Adds deleted objects and links returned from applyAction
124
+ - 1ba3871: Support $clone for interface objects
125
+ - 12843cb: Add ability to load all underlying properties of an interface.
126
+ - 18ba34f: Adds the ability to generate and execute functions at pinned versions
127
+ - cdd3154: Revert allowing explicitly passing undefined values to reset on actions
128
+ - 56aa502: Improves exposed APIs
129
+ - abe4897: Removes support for boolean primary keys
130
+ - 63b2e63: Update Platform SDK Dependencies
131
+ - cddfbf9: Adds default value option to group by
132
+ - 5a12181: Quick fix for geohash params.
133
+ - 2ce3659: Update underlying pagination size for async iter.
134
+ - 7416ce4: Update Platform SDK Dependencies
135
+ - 26c2d95: Add experimental function to load page of objects by rid.
136
+ - 430dee3: JSdoc for object properties are generated
137
+ - 397f906: Ensure count operations return numbers
138
+ - 488b51c: Add support for using aggregations and GeoJSON types from runtime derived properties
139
+ - fccd9ac: "Allow selecting derived properties"
140
+ - 5665b18: Remove selection RDPs from the API
141
+ - 761e69d: Added type safety to createMediaReference
142
+ - 889e84b: Release
143
+ - 62e5965: Removed unneeded lint statements.
144
+ - ed69666: Update conjure-lite to 0.7.1
145
+ - c92fe73: Add OsdkConfig utils to client/unstable
146
+ - 2517750: observeList should work for interfaces and have the fully loaded content
147
+ - 4183a55: Refactor OsdkBase to avoid breaks with type not being discoverable
148
+ - 1e16dcb: Exposes MinimalLogger and BrowserLogger via @osdk/client/internal
149
+ - 70b4464: Fix types for RDPs
150
+ - 2f6206c: Improvements to @osdk/react
151
+ - 81c0d8c: Client will now provide a default logger to console.error if none is provided
152
+ - 81c0d8c: ObservableClient now queues up object loads for bulk processing
153
+ - 791e655: Add support for geoshape and geohash action parameters.
154
+ - 317b555: Release
155
+ - 879b6c3: Include a more descriptive error message for multiple filters on a single property filter clause
156
+ - 63b2e63: Supports generating queries for entrySet function types
157
+ - 2517750: Provides efficient OrderByCanonicalizer
158
+ - 1e16dcb: Default logging is error level only
159
+ - f4370e3: Fixes error when using intersection, subtraction, or union object sets
160
+ - ea4e4b1: Fix attachments to be upload sequentially rather than in parallel.
161
+ - a146ce4: Cleanup RDP API
162
+ - cc380b5: Use the latest Platform APIs
163
+ - e873024: Fixes issues requiring msw and p-defer
164
+ - 88591f7: Small fixes for ObjectSpecifier
165
+ - 751e5b3: Use client as peer dep in functions package.
166
+ - 805df40: Fix interface action types.
167
+ - fe0cc43: Experimental react changes
168
+ - 2517750: Initial internal architecture document for ObservableClient
169
+ - 5467a0f: Fix orderBy argument on object load methods
170
+ - 2517750: subscribe in ObservableClient now uses Observer
171
+ - 63b2e63: Adds ObjectSpecifiers to generated OSDK objects
172
+ - Updated dependencies [322c5bc]
173
+ - Updated dependencies [322c5bc]
174
+ - Updated dependencies [322c5bc]
175
+ - Updated dependencies [322c5bc]
176
+ - Updated dependencies [322c5bc]
177
+ - Updated dependencies [322c5bc]
178
+ - Updated dependencies [b68adea]
179
+ - Updated dependencies [c6bee50]
180
+ - Updated dependencies [7416ce4]
181
+ - Updated dependencies [6eeb423]
182
+ - Updated dependencies [7170fd1]
183
+ - Updated dependencies [12843cb]
184
+ - Updated dependencies [ad93d55]
185
+ - Updated dependencies [a08bdfb]
186
+ - Updated dependencies [18ba34f]
187
+ - Updated dependencies [6abf078]
188
+ - Updated dependencies [f82767c]
189
+ - Updated dependencies [56aa502]
190
+ - Updated dependencies [0e874b1]
191
+ - Updated dependencies [abe4897]
192
+ - Updated dependencies [63b2e63]
193
+ - Updated dependencies [cddfbf9]
194
+ - Updated dependencies [7416ce4]
195
+ - Updated dependencies [23ea0e4]
196
+ - Updated dependencies [26c2d95]
197
+ - Updated dependencies [10da391]
198
+ - Updated dependencies [488b51c]
199
+ - Updated dependencies [71462e9]
200
+ - Updated dependencies [6ac8f0b]
201
+ - Updated dependencies [fccd9ac]
202
+ - Updated dependencies [5e8e839]
203
+ - Updated dependencies [5665b18]
204
+ - Updated dependencies [46cede4]
205
+ - Updated dependencies [761e69d]
206
+ - Updated dependencies [889e84b]
207
+ - Updated dependencies [a6e5f89]
208
+ - Updated dependencies [ed69666]
209
+ - Updated dependencies [4183a55]
210
+ - Updated dependencies [70b4464]
211
+ - Updated dependencies [395ae07]
212
+ - Updated dependencies [37f8e60]
213
+ - Updated dependencies [791e655]
214
+ - Updated dependencies [317b555]
215
+ - Updated dependencies [63b2e63]
216
+ - Updated dependencies [a146ce4]
217
+ - Updated dependencies [3d0ab11]
218
+ - Updated dependencies [805df40]
219
+ - Updated dependencies [5467a0f]
220
+ - Updated dependencies [63b2e63]
221
+ - @osdk/api@2.2.0
222
+ - @osdk/client.unstable@2.2.0
223
+ - @osdk/generator-converters@2.2.0
224
+ - @osdk/shared.client.impl@1.2.0
225
+ - @osdk/shared.net.errors@2.2.0
226
+ - @osdk/shared.net.fetch@1.2.0
227
+
128
228
  ## 2.2.0-beta.23
129
229
 
130
230
  ### Minor Changes
@@ -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,aAA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uBAAuB,KAAK,QAAQ,EAAE;YACxCE,8BAA8B,GAAG;cAC/Bd,IAAI,EAAE;YACR,CAAC;YACD;UACF;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,EACl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D,cAAc,EAAEF,gBAAgB,CAAC;MACnD,OAAOE,cAAc;IACvB,CAAC;IACDK,QAAQ,EAAE;MACRC,MAAM,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;I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AC,8BAA8B,CAAC,CACzDT,eACF,CAAC;IACD,MAAMa,gBAAgB,GAAGf,GAAG,CAACS,GAAG,CAACK,YAAY,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 \"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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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B,aAAkD,KACpB;EAC9B,IAAI,OAAOkB,GAAG,KAAK,QAAQ,EAAE;IAC3B,MAAMjB,UAAU,GAAGD,aAAa,CAACmB,GAAG,CAACD,GAAG,CAAC;IACzC,CAAUjB,UAAU,GAAAmB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAApBzB,SAAS,QAAa,iCAAiC,IAAvDA,SAAS;IACT,OAAOI,UAAU;EACnB,CAAC,MAAM,IAAI,OAAOiB,GAAG,KAAK,QAAQ,EAAE;IAClCE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAzB,SAAS,QAAQ,uDAAuD,IAAxEA,SAAS;EACX;EACAuB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAzB,SAAS,QAAQ,8CAA8C,IAA/DA,SAAS;AACX,CAAC","ignoreList":[]}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export { isOk } from "@osdk/api";
17
+ export { isOk, NULL_VALUE } from "@osdk/api";
18
18
  export { PalantirApiError } from "@osdk/shared.net.errors";
19
19
  export { ActionValidationError } from "./actions/ActionValidationError.js";
20
20
  export { createClient } from "./createClient.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["isOk","PalantirApiError","ActionValidationError","createClient","createPlatformClient","createAttachmentUpload","extractDate","extractDateInLocalTime","extractDateInUTC"],"sources":["index.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\nexport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ActionValidationResponse,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n Attachment,\n CompileTimeMetadata,\n InterfaceDefinition,\n Logger,\n ObjectMetadata,\n ObjectSet,\n ObjectSpecifier,\n ObjectTypeDefinition,\n Osdk,\n OsdkObject,\n OsdkObjectPropertyType,\n PageResult,\n PropertyDef,\n PropertyKeys,\n PropertyValueWireToClient,\n QueryDefinition,\n QueryParam,\n QueryResult,\n Range,\n Result,\n SingleLinkAccessor,\n ThreeDimensionalAggregation,\n TwoDimensionalAggregation,\n VersionBound,\n WhereClause,\n} from \"@osdk/api\";\nexport { isOk } from \"@osdk/api\";\nexport { PalantirApiError } from \"@osdk/shared.net.errors\";\n\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport type { Client } from \"./Client.js\";\nexport { createClient } from \"./createClient.js\";\nexport { createPlatformClient } from \"./createPlatformClient.js\";\nexport type { PlatformClient } from \"./createPlatformClient.js\";\nexport { createAttachmentUpload } from \"./object/AttachmentUpload.js\";\nexport type { ResultOrError } from \"./ResultOrError.js\";\n\nexport {\n extractDate,\n extractDateInLocalTime,\n extractDateInUTC,\n} from \"./util/datetimeConverters.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,SAASA,IAAI,QAAQ,WAAW;AAChC,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,SAASC,qBAAqB,QAAQ,oCAAoC;AAE1E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,SAASC,sBAAsB,QAAQ,8BAA8B;AAGrE,SACEC,WAAW,EACXC,sBAAsB,EACtBC,gBAAgB,QACX,8BAA8B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["isOk","NULL_VALUE","PalantirApiError","ActionValidationError","createClient","createPlatformClient","createAttachmentUpload","extractDate","extractDateInLocalTime","extractDateInUTC"],"sources":["index.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\nexport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ActionValidationResponse,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n Attachment,\n CompileTimeMetadata,\n InterfaceDefinition,\n Logger,\n ObjectMetadata,\n ObjectSet,\n ObjectSpecifier,\n ObjectTypeDefinition,\n Osdk,\n OsdkObject,\n OsdkObjectPropertyType,\n PageResult,\n PropertyDef,\n PropertyKeys,\n PropertyValueWireToClient,\n QueryDefinition,\n QueryParam,\n QueryResult,\n Range,\n Result,\n SingleLinkAccessor,\n ThreeDimensionalAggregation,\n TwoDimensionalAggregation,\n VersionBound,\n WhereClause,\n} from \"@osdk/api\";\nexport { isOk, NULL_VALUE } from \"@osdk/api\";\nexport { PalantirApiError } from \"@osdk/shared.net.errors\";\n\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport type { Client } from \"./Client.js\";\nexport { createClient } from \"./createClient.js\";\nexport { createPlatformClient } from \"./createPlatformClient.js\";\nexport type { PlatformClient } from \"./createPlatformClient.js\";\nexport { createAttachmentUpload } from \"./object/AttachmentUpload.js\";\nexport type { ResultOrError } from \"./ResultOrError.js\";\n\nexport {\n extractDate,\n extractDateInLocalTime,\n extractDateInUTC,\n} from \"./util/datetimeConverters.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAW;AAC5C,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,SAASC,qBAAqB,QAAQ,oCAAoC;AAE1E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,SAASC,sBAAsB,QAAQ,8BAA8B;AAGrE,SACEC,WAAW,EACXC,sBAAsB,EACtBC,gBAAgB,QACX,8BAA8B","ignoreList":[]}
@@ -17,4 +17,7 @@
17
17
  export function isMediaReference(o) {
18
18
  return typeof o === `object` && typeof o.mimeType === "string" && "reference" in o && typeof o.reference === "object" && o.reference.type === "mediaSetViewItem" && "mediaSetViewItem" in o.reference && typeof o.reference.mediaSetViewItem === "object" && typeof o.reference.mediaSetViewItem.mediaSetRid === "string" && typeof o.reference.mediaSetViewItem.mediaSetViewRid === "string" && typeof o.reference.mediaSetViewItem.mediaItemRid === "string";
19
19
  }
20
+ export function isMediaUpload(o) {
21
+ return typeof o === "object" && "path" in o && typeof o.path === "string" && "data" in o && typeof o.data === "object" && o.data instanceof Blob;
22
+ }
20
23
  //# sourceMappingURL=mediaUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mediaUpload.js","names":["isMediaReference","o","mimeType","reference","type","mediaSetViewItem","mediaSetRid","mediaSetViewRid","mediaItemRid"],"sources":["mediaUpload.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 { MediaReference } from \"@osdk/api\";\n\nexport function isMediaReference(o: any): o is MediaReference {\n return typeof o === `object`\n && typeof o.mimeType === \"string\"\n && \"reference\" in o\n && typeof o.reference === \"object\"\n && o.reference.type === \"mediaSetViewItem\"\n && \"mediaSetViewItem\" in o.reference\n && typeof o.reference.mediaSetViewItem === \"object\"\n && typeof o.reference.mediaSetViewItem.mediaSetRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaSetViewRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaItemRid === \"string\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,gBAAgBA,CAACC,CAAM,EAAuB;EAC5D,OAAO,OAAOA,CAAC,KAAK,QAAQ,IACvB,OAAOA,CAAC,CAACC,QAAQ,KAAK,QAAQ,IAC9B,WAAW,IAAID,CAAC,IAChB,OAAOA,CAAC,CAACE,SAAS,KAAK,QAAQ,IAC/BF,CAAC,CAACE,SAAS,CAACC,IAAI,KAAK,kBAAkB,IACvC,kBAAkB,IAAIH,CAAC,CAACE,SAAS,IACjC,OAAOF,CAAC,CAACE,SAAS,CAACE,gBAAgB,KAAK,QAAQ,IAChD,OAAOJ,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACC,WAAW,KAAK,QAAQ,IAC5D,OAAOL,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACE,eAAe,KAAK,QAAQ,IAChE,OAAON,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACG,YAAY,KAAK,QAAQ;AACpE","ignoreList":[]}
1
+ {"version":3,"file":"mediaUpload.js","names":["isMediaReference","o","mimeType","reference","type","mediaSetViewItem","mediaSetRid","mediaSetViewRid","mediaItemRid","isMediaUpload","path","data","Blob"],"sources":["mediaUpload.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 { MediaReference, MediaUpload } from \"@osdk/api\";\n\nexport function isMediaReference(o: any): o is MediaReference {\n return typeof o === `object`\n && typeof o.mimeType === \"string\"\n && \"reference\" in o\n && typeof o.reference === \"object\"\n && o.reference.type === \"mediaSetViewItem\"\n && \"mediaSetViewItem\" in o.reference\n && typeof o.reference.mediaSetViewItem === \"object\"\n && typeof o.reference.mediaSetViewItem.mediaSetRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaSetViewRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaItemRid === \"string\";\n}\n\nexport function isMediaUpload(o: any): o is MediaUpload {\n return typeof o === \"object\"\n && \"path\" in o\n && typeof o.path === \"string\"\n && \"data\" in o\n && typeof o.data === \"object\"\n && o.data instanceof Blob;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,gBAAgBA,CAACC,CAAM,EAAuB;EAC5D,OAAO,OAAOA,CAAC,KAAK,QAAQ,IACvB,OAAOA,CAAC,CAACC,QAAQ,KAAK,QAAQ,IAC9B,WAAW,IAAID,CAAC,IAChB,OAAOA,CAAC,CAACE,SAAS,KAAK,QAAQ,IAC/BF,CAAC,CAACE,SAAS,CAACC,IAAI,KAAK,kBAAkB,IACvC,kBAAkB,IAAIH,CAAC,CAACE,SAAS,IACjC,OAAOF,CAAC,CAACE,SAAS,CAACE,gBAAgB,KAAK,QAAQ,IAChD,OAAOJ,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACC,WAAW,KAAK,QAAQ,IAC5D,OAAOL,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACE,eAAe,KAAK,QAAQ,IAChE,OAAON,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACG,YAAY,KAAK,QAAQ;AACpE;AAEA,OAAO,SAASC,aAAaA,CAACR,CAAM,EAAoB;EACtD,OAAO,OAAOA,CAAC,KAAK,QAAQ,IACvB,MAAM,IAAIA,CAAC,IACX,OAAOA,CAAC,CAACS,IAAI,KAAK,QAAQ,IAC1B,MAAM,IAAIT,CAAC,IACX,OAAOA,CAAC,CAACU,IAAI,KAAK,QAAQ,IAC1BV,CAAC,CAACU,IAAI,YAAYC,IAAI;AAC7B","ignoreList":[]}