@osdk/client 2.3.0-rc.11 → 2.4.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.
- package/CHANGELOG.md +155 -7
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +41 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
- package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
- package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
- package/build/browser/fetchMetadata.test.js +14 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/intellisense.test.js +1 -1
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +7 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +9 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +240 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/mediaUpload.js +3 -0
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +105 -106
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +22 -0
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +1 -0
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/Store.js +7 -0
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/ontology/StandardOntologyProvider.js +3 -2
- package/build/browser/ontology/StandardOntologyProvider.js.map +1 -1
- package/build/browser/public-utils/hydrateObjectSetFromObjectRids.js +4 -1
- package/build/browser/public-utils/hydrateObjectSetFromObjectRids.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/deepFreeze.js +26 -0
- package/build/browser/util/deepFreeze.js.map +1 -0
- package/build/browser/util/toDataValue.js +17 -1
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +42 -2
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-LZ4GFSOQ.cjs → chunk-NOQSRSD6.cjs} +102 -62
- package/build/cjs/chunk-NOQSRSD6.cjs.map +1 -0
- package/build/cjs/{chunk-QHPACIXZ.cjs → chunk-OKQUXVEK.cjs} +158 -24
- package/build/cjs/chunk-OKQUXVEK.cjs.map +1 -0
- package/build/cjs/index.cjs +10 -6
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/internal.cjs +12 -9
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/internal.d.cts +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +23 -15
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +2 -1
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +41 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
- package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
- package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
- package/build/esm/fetchMetadata.test.js +14 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/intellisense.test.js +1 -1
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +7 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +9 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +240 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/mediaUpload.js +3 -0
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +105 -106
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +22 -0
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +1 -0
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/Store.js +7 -0
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/ontology/StandardOntologyProvider.js +3 -2
- package/build/esm/ontology/StandardOntologyProvider.js.map +1 -1
- package/build/esm/public-utils/hydrateObjectSetFromObjectRids.js +4 -1
- package/build/esm/public-utils/hydrateObjectSetFromObjectRids.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/deepFreeze.js +26 -0
- package/build/esm/util/deepFreeze.js.map +1 -0
- package/build/esm/util/toDataValue.js +17 -1
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +42 -2
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
- package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/object/mediaUpload.d.ts +2 -1
- package/build/types/object/mediaUpload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +2 -1
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +2 -1
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/ontology/StandardOntologyProvider.d.ts.map +1 -1
- package/build/types/public-utils/hydrateObjectSetFromObjectRids.d.ts +1 -1
- package/build/types/public-utils/hydrateObjectSetFromObjectRids.d.ts.map +1 -1
- package/build/types/util/deepFreeze.d.ts +1 -0
- package/build/types/util/deepFreeze.d.ts.map +1 -0
- package/package.json +11 -11
- package/build/cjs/chunk-LZ4GFSOQ.cjs.map +0 -1
- package/build/cjs/chunk-QHPACIXZ.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.4.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8c95154: Add nearestNeighbor support
|
|
8
|
+
- c32dcf2: Add a metadata field to all loaded objects
|
|
9
|
+
- 37c7c0b: Add validateAction support to useOsdkAction hook
|
|
10
|
+
|
|
11
|
+
The `useOsdkAction` hook in `@osdk/react` now provides a `validateAction` function that allows you to check if an action is valid without executing it. This is useful for providing real-time validation feedback to users before they commit to performing an action.
|
|
12
|
+
|
|
13
|
+
### New features:
|
|
14
|
+
|
|
15
|
+
- **validateAction**: A new async function that validates action parameters without executing the action
|
|
16
|
+
- **isValidating**: A boolean state that indicates when validation is in progress
|
|
17
|
+
- **validationResult**: Contains the validation response from the server, including whether the action is valid and any validation errors
|
|
18
|
+
|
|
19
|
+
### Example usage:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
const { applyAction, validateAction, isValidating, validationResult } =
|
|
23
|
+
useOsdkAction(myAction);
|
|
24
|
+
|
|
25
|
+
// Validate without executing
|
|
26
|
+
await validateAction({ param1: "value" });
|
|
27
|
+
|
|
28
|
+
// Check validation result
|
|
29
|
+
if (validationResult?.result === "VALID") {
|
|
30
|
+
console.log("Action is valid!");
|
|
31
|
+
} else {
|
|
32
|
+
console.log("Validation failed:", validationResult);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Implementation details:
|
|
37
|
+
|
|
38
|
+
- Multiple validation calls can be made - new calls automatically cancel previous pending validations
|
|
39
|
+
- Validation and action execution are mutually exclusive - you cannot validate while an action is being applied and vice versa
|
|
40
|
+
- The underlying `ObservableClient` in `@osdk/client` has been extended with a `validateAction` method to support this functionality
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
6
43
|
|
|
7
|
-
-
|
|
8
|
-
- Updated dependencies [
|
|
9
|
-
- Updated dependencies [
|
|
10
|
-
- @osdk/
|
|
11
|
-
- @osdk/
|
|
12
|
-
- @osdk/
|
|
44
|
+
- Updated dependencies [29d2ada]
|
|
45
|
+
- Updated dependencies [8c95154]
|
|
46
|
+
- Updated dependencies [c32dcf2]
|
|
47
|
+
- @osdk/api@2.4.0-beta.2
|
|
48
|
+
- @osdk/generator-converters@2.4.0-beta.2
|
|
49
|
+
- @osdk/client.unstable@2.4.0-beta.2
|
|
13
50
|
|
|
14
51
|
## 2.3.0-beta.10
|
|
15
52
|
|
|
@@ -125,6 +162,117 @@
|
|
|
125
162
|
- @osdk/client.unstable@2.3.0-beta.2
|
|
126
163
|
- @osdk/generator-converters@2.3.0-beta.2
|
|
127
164
|
|
|
165
|
+
## 2.2.0
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- 322c5bc: Simulated release
|
|
170
|
+
- b61e9f5: Make Query Map Types Optional
|
|
171
|
+
- 7416ce4: Adds deleted objects and links returned from applyAction
|
|
172
|
+
- 1ba3871: Support $clone for interface objects
|
|
173
|
+
- 12843cb: Add ability to load all underlying properties of an interface.
|
|
174
|
+
- 18ba34f: Adds the ability to generate and execute functions at pinned versions
|
|
175
|
+
- cdd3154: Revert allowing explicitly passing undefined values to reset on actions
|
|
176
|
+
- 56aa502: Improves exposed APIs
|
|
177
|
+
- abe4897: Removes support for boolean primary keys
|
|
178
|
+
- 63b2e63: Update Platform SDK Dependencies
|
|
179
|
+
- cddfbf9: Adds default value option to group by
|
|
180
|
+
- 5a12181: Quick fix for geohash params.
|
|
181
|
+
- 2ce3659: Update underlying pagination size for async iter.
|
|
182
|
+
- 7416ce4: Update Platform SDK Dependencies
|
|
183
|
+
- 26c2d95: Add experimental function to load page of objects by rid.
|
|
184
|
+
- 430dee3: JSdoc for object properties are generated
|
|
185
|
+
- 397f906: Ensure count operations return numbers
|
|
186
|
+
- 488b51c: Add support for using aggregations and GeoJSON types from runtime derived properties
|
|
187
|
+
- fccd9ac: "Allow selecting derived properties"
|
|
188
|
+
- 5665b18: Remove selection RDPs from the API
|
|
189
|
+
- 761e69d: Added type safety to createMediaReference
|
|
190
|
+
- 889e84b: Release
|
|
191
|
+
- 62e5965: Removed unneeded lint statements.
|
|
192
|
+
- ed69666: Update conjure-lite to 0.7.1
|
|
193
|
+
- c92fe73: Add OsdkConfig utils to client/unstable
|
|
194
|
+
- 2517750: observeList should work for interfaces and have the fully loaded content
|
|
195
|
+
- 4183a55: Refactor OsdkBase to avoid breaks with type not being discoverable
|
|
196
|
+
- 1e16dcb: Exposes MinimalLogger and BrowserLogger via @osdk/client/internal
|
|
197
|
+
- 70b4464: Fix types for RDPs
|
|
198
|
+
- 2f6206c: Improvements to @osdk/react
|
|
199
|
+
- 81c0d8c: Client will now provide a default logger to console.error if none is provided
|
|
200
|
+
- 81c0d8c: ObservableClient now queues up object loads for bulk processing
|
|
201
|
+
- 791e655: Add support for geoshape and geohash action parameters.
|
|
202
|
+
- 317b555: Release
|
|
203
|
+
- 879b6c3: Include a more descriptive error message for multiple filters on a single property filter clause
|
|
204
|
+
- 63b2e63: Supports generating queries for entrySet function types
|
|
205
|
+
- 2517750: Provides efficient OrderByCanonicalizer
|
|
206
|
+
- 1e16dcb: Default logging is error level only
|
|
207
|
+
- f4370e3: Fixes error when using intersection, subtraction, or union object sets
|
|
208
|
+
- ea4e4b1: Fix attachments to be upload sequentially rather than in parallel.
|
|
209
|
+
- a146ce4: Cleanup RDP API
|
|
210
|
+
- cc380b5: Use the latest Platform APIs
|
|
211
|
+
- e873024: Fixes issues requiring msw and p-defer
|
|
212
|
+
- 88591f7: Small fixes for ObjectSpecifier
|
|
213
|
+
- 751e5b3: Use client as peer dep in functions package.
|
|
214
|
+
- 805df40: Fix interface action types.
|
|
215
|
+
- fe0cc43: Experimental react changes
|
|
216
|
+
- 2517750: Initial internal architecture document for ObservableClient
|
|
217
|
+
- 5467a0f: Fix orderBy argument on object load methods
|
|
218
|
+
- 2517750: subscribe in ObservableClient now uses Observer
|
|
219
|
+
- 63b2e63: Adds ObjectSpecifiers to generated OSDK objects
|
|
220
|
+
- Updated dependencies [322c5bc]
|
|
221
|
+
- Updated dependencies [322c5bc]
|
|
222
|
+
- Updated dependencies [322c5bc]
|
|
223
|
+
- Updated dependencies [322c5bc]
|
|
224
|
+
- Updated dependencies [322c5bc]
|
|
225
|
+
- Updated dependencies [322c5bc]
|
|
226
|
+
- Updated dependencies [b68adea]
|
|
227
|
+
- Updated dependencies [c6bee50]
|
|
228
|
+
- Updated dependencies [7416ce4]
|
|
229
|
+
- Updated dependencies [6eeb423]
|
|
230
|
+
- Updated dependencies [7170fd1]
|
|
231
|
+
- Updated dependencies [12843cb]
|
|
232
|
+
- Updated dependencies [ad93d55]
|
|
233
|
+
- Updated dependencies [a08bdfb]
|
|
234
|
+
- Updated dependencies [18ba34f]
|
|
235
|
+
- Updated dependencies [6abf078]
|
|
236
|
+
- Updated dependencies [f82767c]
|
|
237
|
+
- Updated dependencies [56aa502]
|
|
238
|
+
- Updated dependencies [0e874b1]
|
|
239
|
+
- Updated dependencies [abe4897]
|
|
240
|
+
- Updated dependencies [63b2e63]
|
|
241
|
+
- Updated dependencies [cddfbf9]
|
|
242
|
+
- Updated dependencies [7416ce4]
|
|
243
|
+
- Updated dependencies [23ea0e4]
|
|
244
|
+
- Updated dependencies [26c2d95]
|
|
245
|
+
- Updated dependencies [10da391]
|
|
246
|
+
- Updated dependencies [488b51c]
|
|
247
|
+
- Updated dependencies [71462e9]
|
|
248
|
+
- Updated dependencies [6ac8f0b]
|
|
249
|
+
- Updated dependencies [fccd9ac]
|
|
250
|
+
- Updated dependencies [5e8e839]
|
|
251
|
+
- Updated dependencies [5665b18]
|
|
252
|
+
- Updated dependencies [46cede4]
|
|
253
|
+
- Updated dependencies [761e69d]
|
|
254
|
+
- Updated dependencies [889e84b]
|
|
255
|
+
- Updated dependencies [a6e5f89]
|
|
256
|
+
- Updated dependencies [ed69666]
|
|
257
|
+
- Updated dependencies [4183a55]
|
|
258
|
+
- Updated dependencies [70b4464]
|
|
259
|
+
- Updated dependencies [395ae07]
|
|
260
|
+
- Updated dependencies [37f8e60]
|
|
261
|
+
- Updated dependencies [791e655]
|
|
262
|
+
- Updated dependencies [317b555]
|
|
263
|
+
- Updated dependencies [63b2e63]
|
|
264
|
+
- Updated dependencies [a146ce4]
|
|
265
|
+
- Updated dependencies [3d0ab11]
|
|
266
|
+
- Updated dependencies [805df40]
|
|
267
|
+
- Updated dependencies [5467a0f]
|
|
268
|
+
- Updated dependencies [63b2e63]
|
|
269
|
+
- @osdk/api@2.2.0
|
|
270
|
+
- @osdk/client.unstable@2.2.0
|
|
271
|
+
- @osdk/generator-converters@2.2.0
|
|
272
|
+
- @osdk/shared.client.impl@1.2.0
|
|
273
|
+
- @osdk/shared.net.errors@2.2.0
|
|
274
|
+
- @osdk/shared.net.fetch@1.2.0
|
|
275
|
+
|
|
128
276
|
## 2.2.0-beta.23
|
|
129
277
|
|
|
130
278
|
### Minor Changes
|
package/build/browser/Client.js
CHANGED
|
@@ -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.
|
|
24
|
+
const MaxOsdkVersion = "2.4.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.
|
|
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.4.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.
|
|
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,OA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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").
|
|
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
|
-
"
|
|
33
|
+
"link": "lead",
|
|
34
|
+
"objectSet": {
|
|
35
|
+
"type": "methodInput",
|
|
36
|
+
},
|
|
37
|
+
"type": "searchAround",
|
|
36
38
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"type": "
|
|
42
|
-
}
|
|
43
|
-
|
|
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,QAAQ,EAAE;MAC9DQ,IAAI,EAA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AU,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;AACA;AACA;AACA;AACA;AACA;AACA;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AU,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;I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