@osdk/client 2.3.1 → 2.4.0-beta.10
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 +117 -57
- 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/internal/conversions/modernToLegacyGroupByClause.js +2 -1
- package/build/browser/internal/conversions/modernToLegacyGroupByClause.js.map +1 -1
- package/build/browser/object/aggregate.test.js +85 -0
- package/build/browser/object/aggregate.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-FWYXUSCF.cjs → chunk-3DKSV2QU.cjs} +103 -63
- package/build/cjs/chunk-3DKSV2QU.cjs.map +1 -0
- package/build/cjs/{chunk-T5KGTBH2.cjs → chunk-E5BQ7757.cjs} +187 -38
- package/build/cjs/chunk-E5BQ7757.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 +24 -16
- 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/internal/conversions/modernToLegacyGroupByClause.js +2 -1
- package/build/esm/internal/conversions/modernToLegacyGroupByClause.js.map +1 -1
- package/build/esm/object/aggregate.test.js +85 -0
- package/build/esm/object/aggregate.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 +13 -13
- package/build/cjs/chunk-FWYXUSCF.cjs.map +0 -1
- package/build/cjs/chunk-T5KGTBH2.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,73 +1,133 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.4.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f022ffe: Add experimental transactions shape
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
- @osdk/api@2.4.0-beta.10
|
|
12
|
+
- @osdk/client.unstable@2.4.0-beta.10
|
|
13
|
+
- @osdk/generator-converters@2.4.0-beta.10
|
|
14
|
+
|
|
15
|
+
## 2.4.0-beta.9
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
- 9101bad: Adds "includeNullValues" option for exact match filters
|
|
13
20
|
|
|
14
21
|
### Patch Changes
|
|
15
22
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- Updated dependencies [
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
- Updated dependencies [9101bad]
|
|
24
|
+
- @osdk/api@2.4.0-beta.9
|
|
25
|
+
- @osdk/generator-converters@2.4.0-beta.9
|
|
26
|
+
- @osdk/client.unstable@2.4.0-beta.9
|
|
27
|
+
|
|
28
|
+
## 2.4.0-beta.8
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 9f4fe9e: Add new types mapping for internal creation workflow.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [9f4fe9e]
|
|
37
|
+
- @osdk/api@2.4.0-beta.8
|
|
38
|
+
- @osdk/generator-converters@2.4.0-beta.8
|
|
39
|
+
- @osdk/client.unstable@2.4.0-beta.8
|
|
40
|
+
|
|
41
|
+
## 2.4.0-beta.7
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- @osdk/api@2.4.0-beta.7
|
|
46
|
+
- @osdk/client.unstable@2.4.0-beta.7
|
|
47
|
+
- @osdk/generator-converters@2.4.0-beta.7
|
|
48
|
+
|
|
49
|
+
## 2.4.0-beta.6
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [764e5f1]
|
|
54
|
+
- @osdk/client.unstable@2.4.0-beta.6
|
|
55
|
+
- @osdk/api@2.4.0-beta.6
|
|
56
|
+
- @osdk/generator-converters@2.4.0-beta.6
|
|
57
|
+
|
|
58
|
+
## 2.4.0-beta.5
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- @osdk/api@2.4.0-beta.5
|
|
63
|
+
- @osdk/client.unstable@2.4.0-beta.5
|
|
64
|
+
- @osdk/generator-converters@2.4.0-beta.5
|
|
65
|
+
|
|
66
|
+
## 2.4.0-beta.4
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Updated dependencies [a01b8d4]
|
|
71
|
+
- @osdk/client.unstable@2.4.0-beta.4
|
|
72
|
+
- @osdk/api@2.4.0-beta.4
|
|
73
|
+
- @osdk/generator-converters@2.4.0-beta.4
|
|
74
|
+
|
|
75
|
+
## 2.4.0-beta.3
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [988bf66]
|
|
80
|
+
- @osdk/client.unstable@2.4.0-beta.3
|
|
81
|
+
- @osdk/api@2.4.0-beta.3
|
|
82
|
+
- @osdk/generator-converters@2.4.0-beta.3
|
|
83
|
+
|
|
84
|
+
## 2.4.0-beta.2
|
|
85
|
+
|
|
86
|
+
### Minor Changes
|
|
87
|
+
|
|
88
|
+
- 8c95154: Add nearestNeighbor support
|
|
89
|
+
- c32dcf2: Add a metadata field to all loaded objects
|
|
90
|
+
- 37c7c0b: Add validateAction support to useOsdkAction hook
|
|
91
|
+
|
|
92
|
+
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.
|
|
93
|
+
|
|
94
|
+
### New features:
|
|
95
|
+
|
|
96
|
+
- **validateAction**: A new async function that validates action parameters without executing the action
|
|
97
|
+
- **isValidating**: A boolean state that indicates when validation is in progress
|
|
98
|
+
- **validationResult**: Contains the validation response from the server, including whether the action is valid and any validation errors
|
|
99
|
+
|
|
100
|
+
### Example usage:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
const { applyAction, validateAction, isValidating, validationResult } =
|
|
104
|
+
useOsdkAction(myAction);
|
|
105
|
+
|
|
106
|
+
// Validate without executing
|
|
107
|
+
await validateAction({ param1: "value" });
|
|
108
|
+
|
|
109
|
+
// Check validation result
|
|
110
|
+
if (validationResult?.result === "VALID") {
|
|
111
|
+
console.log("Action is valid!");
|
|
112
|
+
} else {
|
|
113
|
+
console.log("Validation failed:", validationResult);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Implementation details:
|
|
60
118
|
|
|
61
|
-
|
|
119
|
+
- Multiple validation calls can be made - new calls automatically cancel previous pending validations
|
|
120
|
+
- Validation and action execution are mutually exclusive - you cannot validate while an action is being applied and vice versa
|
|
121
|
+
- The underlying `ObservableClient` in `@osdk/client` has been extended with a `validateAction` method to support this functionality
|
|
62
122
|
|
|
63
123
|
### Patch Changes
|
|
64
124
|
|
|
65
|
-
-
|
|
66
|
-
- Updated dependencies [
|
|
67
|
-
- Updated dependencies [
|
|
68
|
-
- @osdk/
|
|
69
|
-
- @osdk/
|
|
70
|
-
- @osdk/
|
|
125
|
+
- Updated dependencies [29d2ada]
|
|
126
|
+
- Updated dependencies [8c95154]
|
|
127
|
+
- Updated dependencies [c32dcf2]
|
|
128
|
+
- @osdk/api@2.4.0-beta.2
|
|
129
|
+
- @osdk/generator-converters@2.4.0-beta.2
|
|
130
|
+
- @osdk/client.unstable@2.4.0-beta.2
|
|
71
131
|
|
|
72
132
|
## 2.3.0-beta.10
|
|
73
133
|
|
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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AEU;QAC3B;MACF,CAAC;MACD,MAAMH,cAAoD,GACxD9B,gCAAgC,CAAC4B,gBAAgB,EAAExB,aAAa,CAAC;MACnEA,aAAa,CAAC2B,GAAG,CAACD,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").
|
|
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;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AAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAElC,MAAMU,YAAY,GAAGH,MAAM,CAAC,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 \"type\": \"selection\",\n },\n \"type\": \"extract\",\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,EAAE;IACR,CAAC,EAAEH,GAAG,CAAC;IAOP,MAAMI,MAAM,GALG;MACb,qBAAqB,EAAGC,IAAI,IAC1BA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACC,cAAc,CAAC,YAAY;IACpD,CAAC,CAEqB,qBAAqB,CAAC,CAACL,eAAe,CAAC;IAC7D,MAAMM,UAAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAClCP,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;EAEFZ,EAAE,CAAC,0DAA0D,EAAE,MAAM;IACnE,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CACnDJ,QAAQ,EACR;MACEQ,IAAI,EAAE;IACR,CAAC,EACDH,GAAG,EACH,IACF,CAAC;IAMD,MAAMI,MAAM,GAJG;MACb,qBAAqB,EAAG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;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
|