@osdk/client 2.1.0-beta.25 → 2.1.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/browser/actions/actions.test.js +11 -2
  3. package/build/browser/actions/actions.test.js.map +1 -1
  4. package/build/browser/createClient.js +17 -1
  5. package/build/browser/createClient.js.map +1 -1
  6. package/build/browser/index.js.map +1 -1
  7. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +56 -18
  8. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  9. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +193 -7
  10. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  11. package/build/browser/object/aggregate.js +0 -4
  12. package/build/browser/object/aggregate.js.map +1 -1
  13. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +22 -0
  14. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  15. package/build/browser/object/convertWireToOsdkObjects.test.js +8 -8
  16. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  17. package/build/browser/object/mediaUpload.js +20 -0
  18. package/build/browser/object/mediaUpload.js.map +1 -0
  19. package/build/browser/object/object.test.js +172 -11
  20. package/build/browser/object/object.test.js.map +1 -1
  21. package/build/browser/objectSet/ObjectSet.test.js +28 -0
  22. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  23. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  24. package/build/browser/util/UserAgent.js +1 -1
  25. package/build/browser/util/toDataValue.js +4 -0
  26. package/build/browser/util/toDataValue.js.map +1 -1
  27. package/build/browser/util/toDataValue.test.js +4 -0
  28. package/build/browser/util/toDataValue.test.js.map +1 -1
  29. package/build/cjs/{chunk-RWHJNRHF.cjs → chunk-AMEMEGJZ.cjs} +69 -33
  30. package/build/cjs/chunk-AMEMEGJZ.cjs.map +1 -0
  31. package/build/cjs/{chunk-Q4BVHDNO.cjs → chunk-HDBAHEBE.cjs} +19 -15
  32. package/build/cjs/chunk-HDBAHEBE.cjs.map +1 -0
  33. package/build/cjs/index.cjs +88 -43
  34. package/build/cjs/index.cjs.map +1 -1
  35. package/build/cjs/index.d.cts +1 -1
  36. package/build/cjs/public/internal.cjs +6 -6
  37. package/build/cjs/public/unstable-do-not-use.cjs +2 -2
  38. package/build/esm/actions/actions.test.js +11 -2
  39. package/build/esm/actions/actions.test.js.map +1 -1
  40. package/build/esm/createClient.js +17 -1
  41. package/build/esm/createClient.js.map +1 -1
  42. package/build/esm/index.js.map +1 -1
  43. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +56 -18
  44. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  45. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +193 -7
  46. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  47. package/build/esm/object/aggregate.js +0 -4
  48. package/build/esm/object/aggregate.js.map +1 -1
  49. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +22 -0
  50. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  51. package/build/esm/object/convertWireToOsdkObjects.test.js +8 -8
  52. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  53. package/build/esm/object/mediaUpload.js +20 -0
  54. package/build/esm/object/mediaUpload.js.map +1 -0
  55. package/build/esm/object/object.test.js +172 -11
  56. package/build/esm/object/object.test.js.map +1 -1
  57. package/build/esm/objectSet/ObjectSet.test.js +28 -0
  58. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  59. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  60. package/build/esm/util/UserAgent.js +1 -1
  61. package/build/esm/util/toDataValue.js +4 -0
  62. package/build/esm/util/toDataValue.js.map +1 -1
  63. package/build/esm/util/toDataValue.test.js +4 -0
  64. package/build/esm/util/toDataValue.test.js.map +1 -1
  65. package/build/types/index.d.ts +1 -1
  66. package/build/types/object/mediaUpload.d.ts +2 -0
  67. package/build/types/object/object.test.d.ts +1 -1
  68. package/package.json +11 -11
  69. package/build/cjs/chunk-Q4BVHDNO.cjs.map +0 -1
  70. package/build/cjs/chunk-RWHJNRHF.cjs.map +0 -1
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { objectTypeWithAllPropertyTypes } from "@osdk/client.test.ontology";
17
+ import { BgaoNflPlayer, objectTypeWithAllPropertyTypes } from "@osdk/client.test.ontology";
18
18
  import { expectType } from "ts-expect";
19
19
  import { describe, expect, it } from "vitest";
20
20
  import { modernToLegacyWhereClause } from "./modernToLegacyWhereClause.js";
@@ -23,7 +23,17 @@ describe(modernToLegacyWhereClause, () => {
23
23
  describe("interfaces", () => {
24
24
  it("properly converts shortname to fqApiName", () => {
25
25
  const r = modernToLegacyWhereClause({
26
- prop: 5
26
+ $and: [{
27
+ prop: {
28
+ $eq: 5
29
+ }
30
+ }, {
31
+ prop2: {
32
+ innerProp1: {
33
+ $eq: "myProp"
34
+ }
35
+ }
36
+ }]
27
37
  }, {
28
38
  type: "interface",
29
39
  apiName: "a.Foo",
@@ -32,6 +42,12 @@ describe(modernToLegacyWhereClause, () => {
32
42
  properties: {
33
43
  "prop": {
34
44
  type: "integer"
45
+ },
46
+ "prop2": {
47
+ type: {
48
+ "innerProp1": "string",
49
+ "innerProp2": "float"
50
+ }
35
51
  }
36
52
  },
37
53
  apiName: "a.Foo",
@@ -42,16 +58,36 @@ describe(modernToLegacyWhereClause, () => {
42
58
  });
43
59
  expect(r).toMatchInlineSnapshot(`
44
60
  {
45
- "field": "a.prop",
46
- "type": "eq",
47
- "value": 5,
61
+ "type": "and",
62
+ "value": [
63
+ {
64
+ "field": "a.prop",
65
+ "type": "eq",
66
+ "value": 5,
67
+ },
68
+ {
69
+ "field": undefined,
70
+ "propertyIdentifier": {
71
+ "propertyApiName": "a.prop2",
72
+ "structFieldApiName": "innerProp1",
73
+ "type": "structField",
74
+ },
75
+ "type": "eq",
76
+ "value": "myProp",
77
+ },
78
+ ],
48
79
  }
49
80
  `);
50
81
  });
51
82
  it("properly does not convert when interface has no apiNamespace", () => {
52
83
  const r = modernToLegacyWhereClause({
53
84
  "b.prop": 5,
54
- foo: 6
85
+ foo: 6,
86
+ "c.prop2": {
87
+ innerProp1: {
88
+ $eq: "myProp"
89
+ }
90
+ }
55
91
  }, {
56
92
  type: "interface",
57
93
  apiName: "Foo",
@@ -66,6 +102,12 @@ describe(modernToLegacyWhereClause, () => {
66
102
  },
67
103
  "prop": {
68
104
  type: "integer"
105
+ },
106
+ "c.prop2": {
107
+ type: {
108
+ "innerProp1": "string",
109
+ "innerProp2": "float"
110
+ }
69
111
  }
70
112
  },
71
113
  apiName: "Foo",
@@ -88,6 +130,16 @@ describe(modernToLegacyWhereClause, () => {
88
130
  "type": "eq",
89
131
  "value": 6,
90
132
  },
133
+ {
134
+ "field": undefined,
135
+ "propertyIdentifier": {
136
+ "propertyApiName": "c.prop2",
137
+ "structFieldApiName": "innerProp1",
138
+ "type": "structField",
139
+ },
140
+ "type": "eq",
141
+ "value": "myProp",
142
+ },
91
143
  ],
92
144
  }
93
145
  `);
@@ -95,7 +147,12 @@ describe(modernToLegacyWhereClause, () => {
95
147
  it("gracefully handles redundant apiNamespace in property", () => {
96
148
  const r = modernToLegacyWhereClause({
97
149
  "b.prop": 5,
98
- "a.foo": 6
150
+ "a.foo": 6,
151
+ "c.prop2": {
152
+ innerProp1: {
153
+ $eq: "myProp"
154
+ }
155
+ }
99
156
  }, {
100
157
  type: "interface",
101
158
  apiName: "a.Foo",
@@ -110,6 +167,12 @@ describe(modernToLegacyWhereClause, () => {
110
167
  },
111
168
  "prop": {
112
169
  type: "integer"
170
+ },
171
+ "c.prop2": {
172
+ type: {
173
+ "innerProp1": "string",
174
+ "innerProp2": "float"
175
+ }
113
176
  }
114
177
  },
115
178
  apiName: "a.Foo",
@@ -132,6 +195,16 @@ describe(modernToLegacyWhereClause, () => {
132
195
  "type": "eq",
133
196
  "value": 6,
134
197
  },
198
+ {
199
+ "field": undefined,
200
+ "propertyIdentifier": {
201
+ "propertyApiName": "c.prop2",
202
+ "structFieldApiName": "innerProp1",
203
+ "type": "structField",
204
+ },
205
+ "type": "eq",
206
+ "value": "myProp",
207
+ },
135
208
  ],
136
209
  }
137
210
  `);
@@ -711,6 +784,119 @@ describe(modernToLegacyWhereClause, () => {
711
784
  }
712
785
  `);
713
786
  });
787
+ it("converts struct where clauses correctly", () => {
788
+ expect(modernToLegacyWhereClause({
789
+ address: {
790
+ state: {
791
+ $eq: "NJ"
792
+ }
793
+ }
794
+ }, BgaoNflPlayer)).toMatchInlineSnapshot(`
795
+ {
796
+ "field": undefined,
797
+ "propertyIdentifier": {
798
+ "propertyApiName": "address",
799
+ "structFieldApiName": "state",
800
+ "type": "structField",
801
+ },
802
+ "type": "eq",
803
+ "value": "NJ",
804
+ }
805
+ `);
806
+ expect(modernToLegacyWhereClause({
807
+ $and: [{
808
+ address: {
809
+ state: {
810
+ $eq: "NJ"
811
+ }
812
+ }
813
+ }, {
814
+ address: {
815
+ city: {
816
+ $containsAnyTerm: "N"
817
+ }
818
+ }
819
+ }]
820
+ }, BgaoNflPlayer)).toMatchInlineSnapshot(`
821
+ {
822
+ "type": "and",
823
+ "value": [
824
+ {
825
+ "field": undefined,
826
+ "propertyIdentifier": {
827
+ "propertyApiName": "address",
828
+ "structFieldApiName": "state",
829
+ "type": "structField",
830
+ },
831
+ "type": "eq",
832
+ "value": "NJ",
833
+ },
834
+ {
835
+ "field": undefined,
836
+ "fuzzy": false,
837
+ "propertyIdentifier": {
838
+ "propertyApiName": "address",
839
+ "structFieldApiName": "city",
840
+ "type": "structField",
841
+ },
842
+ "type": "containsAnyTerm",
843
+ "value": "N",
844
+ },
845
+ ],
846
+ }
847
+ `);
848
+ expect(modernToLegacyWhereClause({
849
+ $or: [{
850
+ address: {
851
+ state: {
852
+ $eq: "NJ"
853
+ }
854
+ }
855
+ }, {
856
+ address: {
857
+ city: {
858
+ $containsAnyTerm: "N"
859
+ }
860
+ }
861
+ }, {
862
+ gamesPlayed: {
863
+ $gt: 5
864
+ }
865
+ }]
866
+ }, BgaoNflPlayer)).toMatchInlineSnapshot(`
867
+ {
868
+ "type": "or",
869
+ "value": [
870
+ {
871
+ "field": undefined,
872
+ "propertyIdentifier": {
873
+ "propertyApiName": "address",
874
+ "structFieldApiName": "state",
875
+ "type": "structField",
876
+ },
877
+ "type": "eq",
878
+ "value": "NJ",
879
+ },
880
+ {
881
+ "field": undefined,
882
+ "fuzzy": false,
883
+ "propertyIdentifier": {
884
+ "propertyApiName": "address",
885
+ "structFieldApiName": "city",
886
+ "type": "structField",
887
+ },
888
+ "type": "containsAnyTerm",
889
+ "value": "N",
890
+ },
891
+ {
892
+ "field": "gamesPlayed",
893
+ "type": "gt",
894
+ "value": 5,
895
+ },
896
+ ],
897
+ }
898
+ `);
899
+ });
714
900
  });
715
901
  describe("multiple checks", () => {
716
902
  it("properly handles multiple simple where checks", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"modernToLegacyWhereClause.test.js","names":["objectTypeWithAllPropertyTypes","expectType","describe","expect","it","modernToLegacyWhereClause","r","prop","type","apiName","__DefinitionMetadata","properties","displayName","links","rid","toMatchInlineSnapshot","foo","geoPoint","$within","$bbox","$distance","$of","coordinates","$polygon","geoShape","$intersects","integer","$ne","string","$containsAllTerms","term","fuzzySearch","$containsAnyTerm","decimal","$and","$or"],"sources":["modernToLegacyWhereClause.test.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 { ObjectOrInterfaceDefinition, WhereClause } from \"@osdk/api\";\nimport { objectTypeWithAllPropertyTypes } from \"@osdk/client.test.ontology\";\nimport type { Point } from \"geojson\";\nimport { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\n\ntype ObjAllProps = objectTypeWithAllPropertyTypes;\ndescribe(modernToLegacyWhereClause, () => {\n describe(\"api namespaces\", () => {\n describe(\"interfaces\", () => {\n it(\"properly converts shortname to fqApiName\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: { \"prop\": { type: \"integer\" } },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n\n it(\"properly does not convert when interface has no apiNamespace\", () => {\n const T = {\n type: \"interface\",\n apiName: \"Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"foo\": { type: \"integer\" },\n \"b.prop\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n },\n apiName: \"Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n foo: 6,\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n\n it(\"gracefully handles redundant apiNamespace in property\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"a.foo\": { type: \"integer\" },\n \"b.prop\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n \"a.foo\": 6,\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"a.foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n\n it(\"properly does not convert different apiNamespaces\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"a.foo\": { type: \"integer\" },\n \"b.prop\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n expect(modernToLegacyWhereClause({\n \"b.prop\": 5,\n }, T)).toMatchInlineSnapshot(`\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n\n describe(\"objects\", () => {\n it(\"does not convert object short property names to fq\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"a.foo\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n });\n\n describe(\"single checks\", () => {\n describe(\"$within\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n\n it(\"properly generates within radius\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: [-5, 5] },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n\n it(\"properly generates within radius of geopoint\", async () => {\n // suppose you loaded an object with a geopoint field\n // and you want to find all objects within 5 km of that point\n const pointAsGeoJsonPoint: Point = {\n type: \"Point\",\n coordinates: [-5, 5],\n };\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: pointAsGeoJsonPoint },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n\n it(\"properly generates within polygon\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"check types\", async () => {\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: { $distance: [2, \"centimeter\"], $of: [2, 2] },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: { $bbox: [-5, 5, -10, 10] },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n // @ts-expect-error\n $distance: [2, \"centimeter\"],\n // @ts-expect-error\n $of: [2, 2],\n },\n },\n });\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: {\n $polygon: [[[0, 1], [3, 2], [0, 1]]],\n // @ts-expect-error\n $bbox: [2, 2, 2, 2],\n },\n },\n });\n });\n describe(\"$intersects\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: [-5, 5, -10, 10],\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n\n it(\"properly generates intersects polygon\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n });\n\n it(\"inverts ne short hand properly\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n integer: { $ne: 5 },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"not\",\n \"value\": {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n }\n `);\n });\n it(\"converts $containsAllTerms correctly if using new type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: { term: \"test\", fuzzySearch: true } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": true,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: { term: \"test\", fuzzySearch: false } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: { term: \"test\" } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n });\n\n it(\"converts $containsAllTerms correctly if using old type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: \"test\" },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n });\n it(\"converts $containsAnyTerm correctly if using new type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: { term: \"test\", fuzzySearch: true } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": true,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: { term: \"test\", fuzzySearch: false } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: { term: \"test\" } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n });\n\n it(\"converts $containsAnyTerm correctly if using old type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: \"test\" },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n });\n });\n\n describe(\"multiple checks\", () => {\n it(\"properly handles multiple simple where checks\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n decimal: 5,\n integer: 10,\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n\n it(\"properly handles $and\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n $and: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n\n it(\"properly handles $or\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n $or: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,8BAA8B,QAAQ,4BAA4B;AAE3E,SAASC,UAAU,QAAQ,WAAW;AACtC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QA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C,CAAC;MAEFX,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC/BD,MAAM,CAACE,yBAAyB,CAC9B;UACE8B,GAAG,EAAE,CAAC;YACJF,OAAO,EAAE;UACX,CAAC,EAAE;YACDP,OAAO,EAAE;UACX,CAAC;QACH,CAAC,EACD1B,8BACF,CAAC,CAAC,CAACe,qBAAqB,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;MACN,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"modernToLegacyWhereClause.test.js","names":["BgaoNflPlayer","objectTypeWithAllPropertyTypes","expectType","describe","expect","it","modernToLegacyWhereClause","r","$and","prop","$eq","prop2","innerProp1","type","apiName","__DefinitionMetadata","properties","displayName","links","rid","toMatchInlineSnapshot","foo","geoPoint","$within","$bbox","$distance","$of","coordinates","$polygon","geoShape","$intersects","integer","$ne","string","$containsAllTerms","term","fuzzySearch","$containsAnyTerm","address","state","city","$or","gamesPlayed","$gt","decimal"],"sources":["modernToLegacyWhereClause.test.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 { ObjectOrInterfaceDefinition, WhereClause } from \"@osdk/api\";\nimport {\n BgaoNflPlayer,\n objectTypeWithAllPropertyTypes,\n} from \"@osdk/client.test.ontology\";\nimport type { Point } from \"geojson\";\nimport { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\n\ntype ObjAllProps = objectTypeWithAllPropertyTypes;\ntype structObj = BgaoNflPlayer;\ndescribe(modernToLegacyWhereClause, () => {\n describe(\"api namespaces\", () => {\n describe(\"interfaces\", () => {\n it(\"properly converts shortname to fqApiName\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"prop\": { type: \"integer\" },\n \"prop2\": {\n type: { \"innerProp1\": \"string\", \"innerProp2\": \"float\" },\n },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n const r = modernToLegacyWhereClause({\n $and: [\n { prop: { $eq: 5 } },\n { prop2: { innerProp1: { $eq: \"myProp\" } } },\n ],\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": undefined,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"a.prop2\",\n \"structFieldApiName\": \"innerProp1\",\n \"type\": \"structField\",\n },\n \"type\": \"eq\",\n \"value\": \"myProp\",\n },\n ],\n }\n `);\n });\n\n it(\"properly does not convert when interface has no apiNamespace\", () => {\n const T = {\n type: \"interface\",\n apiName: \"Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"foo\": { type: \"integer\" },\n \"b.prop\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n \"c.prop2\": {\n type: { \"innerProp1\": \"string\", \"innerProp2\": \"float\" },\n },\n },\n apiName: \"Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n foo: 6,\n \"c.prop2\": { innerProp1: { $eq: \"myProp\" } },\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n {\n \"field\": undefined,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"c.prop2\",\n \"structFieldApiName\": \"innerProp1\",\n \"type\": \"structField\",\n },\n \"type\": \"eq\",\n \"value\": \"myProp\",\n },\n ],\n }\n `);\n });\n\n it(\"gracefully handles redundant apiNamespace in property\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"a.foo\": { type: \"integer\" },\n \"b.prop\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n \"c.prop2\": {\n type: { \"innerProp1\": \"string\", \"innerProp2\": \"float\" },\n },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n \"a.foo\": 6,\n \"c.prop2\": { innerProp1: { $eq: \"myProp\" } },\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"a.foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n {\n \"field\": undefined,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"c.prop2\",\n \"structFieldApiName\": \"innerProp1\",\n \"type\": \"structField\",\n },\n \"type\": \"eq\",\n \"value\": \"myProp\",\n },\n ],\n }\n `);\n });\n\n it(\"properly does not convert different apiNamespaces\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"a.foo\": { type: \"integer\" },\n \"b.prop\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n\n expect(modernToLegacyWhereClause({\n \"b.prop\": 5,\n }, T)).toMatchInlineSnapshot(`\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n\n describe(\"objects\", () => {\n it(\"does not convert object short property names to fq\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n __DefinitionMetadata: {\n type: \"interface\",\n properties: {\n \"a.foo\": { type: \"integer\" },\n \"prop\": { type: \"integer\" },\n },\n apiName: \"a.Foo\",\n displayName: \"\",\n links: {},\n rid: \"\",\n },\n } as const satisfies ObjectOrInterfaceDefinition;\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n });\n\n describe(\"single checks\", () => {\n describe(\"$within\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n\n it(\"properly generates within radius\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: [-5, 5] },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n\n it(\"properly generates within radius of geopoint\", async () => {\n // suppose you loaded an object with a geopoint field\n // and you want to find all objects within 5 km of that point\n const pointAsGeoJsonPoint: Point = {\n type: \"Point\",\n coordinates: [-5, 5],\n };\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: pointAsGeoJsonPoint },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n\n it(\"properly generates within polygon\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"check types\", async () => {\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: { $distance: [2, \"centimeter\"], $of: [2, 2] },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: { $bbox: [-5, 5, -10, 10] },\n },\n });\n\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n // @ts-expect-error\n $distance: [2, \"centimeter\"],\n // @ts-expect-error\n $of: [2, 2],\n },\n },\n });\n expectType<WhereClause<ObjAllProps>>({\n geoPoint: {\n $within: {\n $polygon: [[[0, 1], [3, 2], [0, 1]]],\n // @ts-expect-error\n $bbox: [2, 2, 2, 2],\n },\n },\n });\n });\n describe(\"$intersects\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: [-5, 5, -10, 10],\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n\n it(\"properly generates intersects polygon\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n geoShape: {\n $intersects: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n });\n\n it(\"inverts ne short hand properly\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n integer: { $ne: 5 },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"not\",\n \"value\": {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n }\n `);\n });\n it(\"converts $containsAllTerms correctly if using new type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: { term: \"test\", fuzzySearch: true } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": true,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: { term: \"test\", fuzzySearch: false } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: { term: \"test\" } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n });\n\n it(\"converts $containsAllTerms correctly if using old type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAllTerms: \"test\" },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAllTerms\",\n \"value\": \"test\",\n }\n `);\n });\n it(\"converts $containsAnyTerm correctly if using new type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: { term: \"test\", fuzzySearch: true } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": true,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: { term: \"test\", fuzzySearch: false } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: { term: \"test\" } },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n });\n\n it(\"converts $containsAnyTerm correctly if using old type\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>({\n string: { $containsAnyTerm: \"test\" },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"string\",\n \"fuzzy\": false,\n \"type\": \"containsAnyTerm\",\n \"value\": \"test\",\n }\n `);\n });\n it(\"converts struct where clauses correctly\", () => {\n expect(modernToLegacyWhereClause<structObj>({\n address: { state: { $eq: \"NJ\" } },\n }, BgaoNflPlayer)).toMatchInlineSnapshot(`\n {\n \"field\": undefined,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"address\",\n \"structFieldApiName\": \"state\",\n \"type\": \"structField\",\n },\n \"type\": \"eq\",\n \"value\": \"NJ\",\n }\n `);\n\n expect(modernToLegacyWhereClause<structObj>({\n $and: [\n { address: { state: { $eq: \"NJ\" } } },\n { address: { city: { $containsAnyTerm: \"N\" } } },\n ],\n }, BgaoNflPlayer)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": undefined,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"address\",\n \"structFieldApiName\": \"state\",\n \"type\": \"structField\",\n },\n \"type\": \"eq\",\n \"value\": \"NJ\",\n },\n {\n \"field\": undefined,\n \"fuzzy\": false,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"address\",\n \"structFieldApiName\": \"city\",\n \"type\": \"structField\",\n },\n \"type\": \"containsAnyTerm\",\n \"value\": \"N\",\n },\n ],\n }\n `);\n\n expect(modernToLegacyWhereClause<structObj>({\n $or: [\n { address: { state: { $eq: \"NJ\" } } },\n { address: { city: { $containsAnyTerm: \"N\" } } },\n { gamesPlayed: { $gt: 5 } },\n ],\n }, BgaoNflPlayer)).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": undefined,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"address\",\n \"structFieldApiName\": \"state\",\n \"type\": \"structField\",\n },\n \"type\": \"eq\",\n \"value\": \"NJ\",\n },\n {\n \"field\": undefined,\n \"fuzzy\": false,\n \"propertyIdentifier\": {\n \"propertyApiName\": \"address\",\n \"structFieldApiName\": \"city\",\n \"type\": \"structField\",\n },\n \"type\": \"containsAnyTerm\",\n \"value\": \"N\",\n },\n {\n \"field\": \"gamesPlayed\",\n \"type\": \"gt\",\n \"value\": 5,\n },\n ],\n }\n `);\n });\n });\n\n describe(\"multiple checks\", () => {\n it(\"properly handles multiple simple where checks\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n decimal: 5,\n integer: 10,\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n\n it(\"properly handles $and\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n $and: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n\n it(\"properly handles $or\", () => {\n expect(modernToLegacyWhereClause<ObjAllProps>(\n {\n $or: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n },\n objectTypeWithAllPropertyTypes,\n )).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,aAAa,EACbC,8BAA8B,QACzB,4BAA4B;AAEnC,SAASC,UAAU,QAAQ,WAAW;AACtC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,yBAAyB,QAAQ,gCAAgC;AAI1EH,QAAQ,CAACG,yBAAyB,EAAE,MAAM;EACxCH,QAAQ,CAAC,gBAAgB,EAAE,MAAM;IAC/BA,QAAQ,CAAC,YAAY,EAAE,MAAM;MAC3BE,EAAE,CAAC,0CAA0C,EAAE,MAAM;QAmBnD,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAClCE,IAAI,EAAE,CACJ;YAAEC,IAAI,EAAE;cAAEC,GAAG,EAAE;YAAE;UAAE,CAAC,EACpB;YAAEC,KAAK,EAAE;cAAEC,UAAU,EAAE;gBAAEF,GAAG,EAAE;cAAS;YAAE;UAAE,CAAC;QAEhD,CAAC,EAvBS;UACRG,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE,OAAO;UAChBC,oBAAoB,EAAE;YACpBF,IAAI,EAAE,WAAW;YACjBG,UAAU,EAAE;cACV,MAAM,EAAE;gBAAEH,IAAI,EAAE;cA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E,IAAI,EAAE,CAAC;YACLoC,OAAO,EAAE;UACX,CAAC,EAAE;YACDb,OAAO,EAAE;UACX,CAAC;QACH,CAAC,EACD9B,8BACF,CAAC,CAAC,CAACmB,qBAAqB,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACJ,CAAC,CAAC;MAEFf,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC/BD,MAAM,CAACE,yBAAyB,CAC9B;UACEmC,GAAG,EAAE,CAAC;YACJG,OAAO,EAAE;UACX,CAAC,EAAE;YACDb,OAAO,EAAE;UACX,CAAC;QACH,CAAC,EACD9B,8BACF,CAAC,CAAC,CAACmB,qBAAqB,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;MACN,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -19,7 +19,6 @@ import invariant from "tiny-invariant";
19
19
  import { legacyToModernSingleAggregationResult } from "../internal/conversions/legacyToModernSingleAggregationResult.js";
20
20
  import { modernToLegacyAggregationClause } from "../internal/conversions/modernToLegacyAggregationClause.js";
21
21
  import { modernToLegacyGroupByClause } from "../internal/conversions/modernToLegacyGroupByClause.js";
22
- import { modernToLegacyWhereClause } from "../internal/conversions/modernToLegacyWhereClause.js";
23
22
  import { addUserAgentAndRequestContextHeaders } from "../util/addUserAgentAndRequestContextHeaders.js";
24
23
  import { resolveBaseObjectSetType } from "../util/objectSetUtils.js";
25
24
 
@@ -34,9 +33,6 @@ export async function aggregate(clientCtx, objectType, objectSet = resolveBaseOb
34
33
  if (req.$groupBy) {
35
34
  body.groupBy = modernToLegacyGroupByClause(req.$groupBy);
36
35
  }
37
- if (req.$where) {
38
- body.where = modernToLegacyWhereClause(req.$where, objectType);
39
- }
40
36
  const result = await OntologiesV2.OntologyObjectSets.aggregate(addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {
41
37
  objectSet,
42
38
  groupBy: body.groupBy,
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate.js","names":["OntologiesV2","invariant","legacyToModernSingleAggregationResult","modernToLegacyAggregationClause","modernToLegacyGroupByClause","modernToLegacyWhereClause","addUserAgentAndRequestContextHeaders","resolveBaseObjectSetType","aggregate","clientCtx","objectType","objectSet","req","body","aggregation","$select","groupBy","where","undefined","$groupBy","$where","result","OntologyObjectSets","ontologyRid","data","length","process","env","NODE_ENV","aggregationToCountResult","ret","map","entry","$group","group","aggregateResult","metrics","name","$count","value"],"sources":["aggregate.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 AggregateOpts,\n AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy,\n AggregationResultsWithGroups,\n AggregationsResults,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type {\n AggregateObjectsRequestV2,\n AggregateObjectsResponseV2,\n ObjectSet,\n} from \"@osdk/internal.foundry.core\";\nimport * as OntologiesV2 from \"@osdk/internal.foundry.ontologiesv2\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult } from \"../internal/conversions/legacyToModernSingleAggregationResult.js\";\nimport { modernToLegacyAggregationClause } from \"../internal/conversions/modernToLegacyAggregationClause.js\";\nimport { modernToLegacyGroupByClause } from \"../internal/conversions/modernToLegacyGroupByClause.js\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport type { ArrayElement } from \"../util/ArrayElement.js\";\nimport { resolveBaseObjectSetType } from \"../util/objectSetUtils.js\";\n\n/** @internal */\nexport async function aggregate<\n Q extends ObjectOrInterfaceDefinition,\n AO extends AggregateOpts<Q>,\n>(\n clientCtx: MinimalClient,\n objectType: Q,\n objectSet: ObjectSet = resolveBaseObjectSetType(objectType),\n req: AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy<Q, AO>,\n): Promise<AggregationsResults<Q, AO>> {\n const resolvedObjectSet = resolveBaseObjectSetType(objectType);\n const body: AggregateObjectsRequestV2 = {\n aggregation: modernToLegacyAggregationClause<AO[\"$select\"]>(\n req.$select,\n ),\n groupBy: [],\n where: undefined,\n };\n\n if (req.$groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.$groupBy);\n }\n if (req.$where) {\n body.where = modernToLegacyWhereClause(req.$where, objectType);\n }\n const result = await OntologiesV2.OntologyObjectSets.aggregate(\n addUserAgentAndRequestContextHeaders(clientCtx, objectType),\n await clientCtx.ontologyRid,\n {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation,\n },\n );\n\n if (!req.$groupBy) {\n invariant(\n result.data.length === 1,\n \"no group by clause should mean only one data result\",\n );\n\n return {\n ...aggregationToCountResult(result.data[0]),\n ...legacyToModernSingleAggregationResult(\n result.data[0],\n ),\n } as any;\n }\n\n const ret: AggregationResultsWithGroups<Q, AO[\"$select\"], any> = result.data\n .map((entry) => {\n return {\n $group: entry.group as any,\n ...aggregationToCountResult(entry),\n ...legacyToModernSingleAggregationResult(entry),\n };\n }) as any; // fixme\n\n return ret as any; // FIXME\n}\n\nfunction aggregationToCountResult(\n entry: ArrayElement<AggregateObjectsResponseV2[\"data\"]>,\n): { $count: number } | undefined {\n for (const aggregateResult of entry.metrics) {\n if (aggregateResult.name === \"count\") {\n return { $count: aggregateResult.value };\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAO,KAAKA,YAAY,MAAM,qCAAqC;AACnE,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,qCAAqC,QAAQ,kEAAkE;AACxH,SAASC,+BAA+B,QAAQ,4DAA4D;AAC5G,SAASC,2BAA2B,QAAQ,wDAAwD;AACpG,SAASC,yBAAyB,QAAQ,sDAAsD;AAEhG,SAASC,oCAAoC,QAAQ,iDAAiD;AAEtG,SAASC,wBAAwB,QAAQ,2BAA2B;;AAEpE;AACA,OAAO,eAAeC,SAASA,CAI7BC,SAAwB,EACxBC,UAAa,EACbC,SAAoB,GAAGJ,wBAAwB,CAACG,UAAU,CAAC,EAC3DE,GAA0E,EACrC;EACXL,wBAAwB,CAACG,UAAU,CAAC;EAC9D,MAAMG,IAA+B,GAAG;IACtCC,WAAW,EAAEX,+BAA+B,CAC1CS,GAAG,CAACG,OACN,CAAC;IACDC,OAAO,EAAE,EAAE;IACXC,KAAK,EAAEC;EACT,CAAC;EAED,IAAIN,GAAG,CAACO,QAAQ,EAAE;IAChBN,IAAI,CAACG,OAAO,GAAGZ,2BAA2B,CAACQ,GAAG,CAACO,QAAQ,CAAC;EAC1D;EACA,IAAIP,GAAG,CAACQ,MAAM,EAAE;IACdP,IAAI,CAACI,KAAK,GAAGZ,yBAAyB,CAACO,GAAG,CAACQ,MAAM,EAAEV,UAAU,CAAC;EAChE;EACA,MAAMW,MAAM,GAAG,MAAMrB,YAAY,CAACsB,kBAAkB,CAACd,SAAS,CAC5DF,oCAAoC,CAACG,SAAS,EAAEC,UAAU,CAAC,EAC3D,MAAMD,SAAS,CAACc,WAAW,EAC3B;IACEZ,SAAS;IACTK,OAAO,EAAEH,IAAI,CAACG,OAAO;IACrBF,WAAW,EAAED,IAAI,CAACC;EACpB,CACF,CAAC;EAED,IAAI,CAACF,GAAG,CAACO,QAAQ,EAAE;IACjB,EACEE,MAAM,CAACG,IAAI,CAACC,MAAM,KAAK,CAAC,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1B3B,SAAS,QAEP,qDAAqD,IAFvDA,SAAS;IAKT,OAAO;MACL,GAAG4B,wBAAwB,CAACR,MAAM,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;MAC3C,GAAGtB,qCAAqC,CACtCmB,MAAM,CAACG,IAAI,CAAC,CAAC,CACf;IACF,CAAC;EACH;EAEA,MAAMM,GAAwD,GAAGT,MAAM,CAACG,IAAI,CACzEO,GAAG,CAAEC,KAAK,IAAK;IACd,OAAO;MACLC,MAAM,EAAED,KAAK,CAACE,KAAY;MAC1B,GAAGL,wBAAwB,CAACG,KAAK,CAAC;MAClC,GAAG9B,qCAAqC,CAAC8B,KAAK;IAChD,CAAC;EACH,CAAC,CAAQ,CAAC,CAAC;;EAEb,OAAOF,GAAG,CAAQ,CAAC;AACrB;AAEA,SAASD,wBAAwBA,CAC/BG,KAAuD,EACvB;EAChC,KAAK,MAAMG,eAAe,IAAIH,KAAK,CAACI,OAAO,EAAE;IAC3C,IAAID,eAAe,CAACE,IAAI,KAAK,OAAO,EAAE;MACpC,OAAO;QAAEC,MAAM,EAAEH,eAAe,CAACI;MAAM,CAAC;IAC1C;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"aggregate.js","names":["OntologiesV2","invariant","legacyToModernSingleAggregationResult","modernToLegacyAggregationClause","modernToLegacyGroupByClause","addUserAgentAndRequestContextHeaders","resolveBaseObjectSetType","aggregate","clientCtx","objectType","objectSet","req","body","aggregation","$select","groupBy","where","undefined","$groupBy","result","OntologyObjectSets","ontologyRid","data","length","process","env","NODE_ENV","aggregationToCountResult","ret","map","entry","$group","group","aggregateResult","metrics","name","$count","value"],"sources":["aggregate.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 AggregateOpts,\n AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy,\n AggregationResultsWithGroups,\n AggregationsResults,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type {\n AggregateObjectsRequestV2,\n AggregateObjectsResponseV2,\n ObjectSet,\n} from \"@osdk/internal.foundry.core\";\nimport * as OntologiesV2 from \"@osdk/internal.foundry.ontologiesv2\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult } from \"../internal/conversions/legacyToModernSingleAggregationResult.js\";\nimport { modernToLegacyAggregationClause } from \"../internal/conversions/modernToLegacyAggregationClause.js\";\nimport { modernToLegacyGroupByClause } from \"../internal/conversions/modernToLegacyGroupByClause.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport type { ArrayElement } from \"../util/ArrayElement.js\";\nimport { resolveBaseObjectSetType } from \"../util/objectSetUtils.js\";\n\n/** @internal */\nexport async function aggregate<\n Q extends ObjectOrInterfaceDefinition,\n AO extends AggregateOpts<Q>,\n>(\n clientCtx: MinimalClient,\n objectType: Q,\n objectSet: ObjectSet = resolveBaseObjectSetType(objectType),\n req: AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy<Q, AO>,\n): Promise<AggregationsResults<Q, AO>> {\n const resolvedObjectSet = resolveBaseObjectSetType(objectType);\n const body: AggregateObjectsRequestV2 = {\n aggregation: modernToLegacyAggregationClause<AO[\"$select\"]>(\n req.$select,\n ),\n groupBy: [],\n where: undefined,\n };\n\n if (req.$groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.$groupBy);\n }\n\n const result = await OntologiesV2.OntologyObjectSets.aggregate(\n addUserAgentAndRequestContextHeaders(clientCtx, objectType),\n await clientCtx.ontologyRid,\n {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation,\n },\n );\n\n if (!req.$groupBy) {\n invariant(\n result.data.length === 1,\n \"no group by clause should mean only one data result\",\n );\n\n return {\n ...aggregationToCountResult(result.data[0]),\n ...legacyToModernSingleAggregationResult(\n result.data[0],\n ),\n } as any;\n }\n\n const ret: AggregationResultsWithGroups<Q, AO[\"$select\"], any> = result.data\n .map((entry) => {\n return {\n $group: entry.group as any,\n ...aggregationToCountResult(entry),\n ...legacyToModernSingleAggregationResult(entry),\n };\n }) as any; // fixme\n\n return ret as any; // FIXME\n}\n\nfunction aggregationToCountResult(\n entry: ArrayElement<AggregateObjectsResponseV2[\"data\"]>,\n): { $count: number } | undefined {\n for (const aggregateResult of entry.metrics) {\n if (aggregateResult.name === \"count\") {\n return { $count: aggregateResult.value };\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAO,KAAKA,YAAY,MAAM,qCAAqC;AACnE,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,qCAAqC,QAAQ,kEAAkE;AACxH,SAASC,+BAA+B,QAAQ,4DAA4D;AAC5G,SAASC,2BAA2B,QAAQ,wDAAwD;AAEpG,SAASC,oCAAoC,QAAQ,iDAAiD;AAEtG,SAASC,wBAAwB,QAAQ,2BAA2B;;AAEpE;AACA,OAAO,eAAeC,SAASA,CAI7BC,SAAwB,EACxBC,UAAa,EACbC,SAAoB,GAAGJ,wBAAwB,CAACG,UAAU,CAAC,EAC3DE,GAA0E,EACrC;EACXL,wBAAwB,CAACG,UAAU,CAAC;EAC9D,MAAMG,IAA+B,GA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,eAAe,CAACE,IAAI,KAAK,OAAO,EAAE;MACpC,OAAO;QAAEC,MAAM,EAAEH,eAAe,CAACI;MAAM,CAAC;IAC1C;EACF;AACF","ignoreList":[]}
@@ -36,6 +36,28 @@ const basePropDefs = {
36
36
  get: function () {
37
37
  return get$link(this);
38
38
  }
39
+ },
40
+ "$clone": {
41
+ value: function (update) {
42
+ const rawObj = this[UnderlyingOsdkObject];
43
+ const def = this[ObjectDefRef];
44
+ if (update == null) {
45
+ return createOsdkObject(this[ClientRef], def, {
46
+ ...rawObj
47
+ });
48
+ }
49
+ if (def.primaryKeyApiName in update && rawObj[def.primaryKeyApiName] !== update[def.primaryKeyApiName]) {
50
+ throw new Error(`Cannot update ${def.apiName} object with differing primary key values `);
51
+ }
52
+ if (def.titleProperty in update && !("$title" in update)) {
53
+ update.$title = update[def.titleProperty];
54
+ }
55
+ const newObject = {
56
+ ...this[UnderlyingOsdkObject],
57
+ ...update
58
+ };
59
+ return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);
60
+ }
39
61
  }
40
62
  };
41
63
 
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","createOsdkObject","client","objectDef","rawObj","Object","defineProperties","enumerable","value","propKey","keys","properties","type","has","createSpecialProperty","freeze","rawObject","p","rawValue","propDef","process","env","NODE_ENV","Array","isArray","map","a","rid","apiName","primaryKeyApiName","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName"],"sources":["createOsdkObject.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 { ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport type { OntologyObjectV2 } from \"@osdk/internal.foundry.core\";\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { MediaReferencePropertyImpl } from \"../../createMediaReferenceProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport type { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\ninterface InternalOsdkInstance {\n [ObjectDefRef]: FetchedObjectTypeDefinition;\n [ClientRef]: MinimalClient;\n}\n\nconst specialPropertyTypes = new Set(\n [\n \"attachment\",\n \"geotimeSeriesReference\",\n \"mediaReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n ],\n);\n\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function(this: InternalOsdkInstance) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: InternalOsdkInstance & ObjectHolder<any>) {\n return get$link(this);\n },\n },\n};\n\n/** @internal */\nexport function createOsdkObject<\n Q extends FetchedObjectTypeDefinition,\n>(\n client: MinimalClient,\n objectDef: Q,\n rawObj: OntologyObjectV2,\n): Osdk<ObjectTypeDefinition, any> {\n // updates the object's \"hidden class/map\".\n Object.defineProperties(rawObj, {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: rawObj,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false },\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n });\n\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (\n propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)\n ) {\n rawObj[propKey] = createSpecialProperty(\n client,\n objectDef,\n rawObj as any,\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj) as Osdk<ObjectTypeDefinition, any>;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: Osdk.Instance<any>,\n p: keyof typeof rawObject & string | symbol,\n) {\n const rawValue = rawObject[p as any];\n const propDef = objectDef.properties[p as any];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(\n propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type),\n );\n }\n {\n {\n {\n {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n }\n return hydrateAttachmentFromRidInternal(client, rawValue.rid);\n }\n\n if (\n propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\"\n ) {\n return new TimeSeriesPropertyImpl<\n (typeof propDef)[\"type\"] extends \"numericTimeseries\" ? number\n : (typeof propDef)[\"type\"] extends \"stringTimeseries\" ? string\n : number | string\n >(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n );\n }\n\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl<GeoJSON.Point>(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n rawValue.type === \"geotimeSeriesValue\"\n ? {\n time: rawValue.timestamp,\n value: {\n type: \"Point\",\n coordinates: rawValue.position,\n },\n }\n : undefined,\n );\n }\n if (propDef.type === \"mediaReference\") {\n return new MediaReferencePropertyImpl({\n client,\n objectApiName: objectDef.apiName,\n primaryKey: rawObject[objectDef.primaryKeyApiName as string],\n propertyName: p as string,\n });\n }\n }\n }\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,0BAA0B,QAAQ,uCAAuC;AAClF,SAASC,sBAAsB,QAAQ,mCAAmC;AAG1E,SAASC,gCAAgC,QAAQ,gDAAgD;AACjG,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACEC,SAAS,EACTC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAQ7B,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAClC,CACE,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CAEtB,CAAC;;AAED;AACA;AACA,MAAMC,YAAY,GAAG;EACnB,KAAK,EAAE;IACLC,GAAG,EAAE,SAAAA,CAAA,EAAqC;MACxC,OAAOR,MAAM,CAAC,IAAI,CAACG,YAAY,CAAC,CAAC;IACnC;EACF,CAAC;EACD,OAAO,EAAE;IACPK,GAAG,EAAE,SAAAA,CAAA,EAAyD;MAC5D,OAAOP,QAAQ,CAAC,IAAI,CAAC;IACvB;EACF;AACF,CAAC;;AAED;AACA,OAAO,SAASQ,gBAAgBA,CAG9BC,MAAqB,EACrBC,SAAY,EACZC,MAAwB,EACS;EACjC;EACAC,MAAM,CAACC,gBAAgB,CAACF,MAAM,EAAE;IAC9B,CAACR,oBAAoB,GAAG;MACtBW,UAAU,EAAE,KAAK;MACjBC,K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ariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","value","update","rawObj","def","createOsdkObject","primaryKeyApiName","Error","apiName","titleProperty","$title","newObject","client","objectDef","Object","defineProperties","enumerable","propKey","keys","properties","type","has","createSpecialProperty","freeze","rawObject","p","rawValue","propDef","process","env","NODE_ENV","Array","isArray","map","a","rid","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName"],"sources":["createOsdkObject.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 { ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport type { OntologyObjectV2 } from \"@osdk/internal.foundry.core\";\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { MediaReferencePropertyImpl } from \"../../createMediaReferenceProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport type { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\ninterface InternalOsdkInstance {\n [ObjectDefRef]: FetchedObjectTypeDefinition;\n [ClientRef]: MinimalClient;\n}\n\nconst specialPropertyTypes = new Set(\n [\n \"attachment\",\n \"geotimeSeriesReference\",\n \"mediaReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n ],\n);\n\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function(this: InternalOsdkInstance) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: InternalOsdkInstance & ObjectHolder<any>) {\n return get$link(this);\n },\n },\n \"$clone\": {\n value: function(\n this: InternalOsdkInstance & ObjectHolder<any>,\n update: Record<string, any> | undefined,\n ) {\n const rawObj = this[UnderlyingOsdkObject];\n const def = this[ObjectDefRef];\n\n if (update == null) {\n return createOsdkObject(this[ClientRef], def, { ...rawObj });\n }\n\n if (\n def.primaryKeyApiName in update\n && rawObj[def.primaryKeyApiName] !== update[def.primaryKeyApiName]\n ) {\n throw new Error(\n `Cannot update ${def.apiName} object with differing primary key values `,\n );\n }\n\n if (def.titleProperty in update && !(\"$title\" in update)) {\n update.$title = update[def.titleProperty];\n }\n\n const newObject = { ...this[UnderlyingOsdkObject], ...update };\n return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);\n },\n },\n};\n\n/** @internal */\nexport function createOsdkObject<\n Q extends FetchedObjectTypeDefinition,\n>(\n client: MinimalClient,\n objectDef: Q,\n rawObj: OntologyObjectV2,\n): Osdk<ObjectTypeDefinition, any> {\n // updates the object's \"hidden class/map\".\n Object.defineProperties(rawObj, {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: rawObj,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false },\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n });\n\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (\n propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)\n ) {\n rawObj[propKey] = createSpecialProperty(\n client,\n objectDef,\n rawObj as any,\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj) as Osdk<ObjectTypeDefinition, any>;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: Osdk.Instance<any>,\n p: keyof typeof rawObject & string | symbol,\n) {\n const rawValue = rawObject[p as any];\n const propDef = objectDef.properties[p as any];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(\n propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type),\n );\n }\n {\n {\n {\n {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n }\n return hydrateAttachmentFromRidInternal(client, rawValue.rid);\n }\n\n if (\n propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\"\n ) {\n return new TimeSeriesPropertyImpl<\n (typeof propDef)[\"type\"] extends \"numericTimeseries\" ? number\n : (typeof propDef)[\"type\"] extends \"stringTimeseries\" ? string\n : number | string\n >(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n );\n }\n\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl<GeoJSON.Point>(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n rawValue.type === \"geotimeSeriesValue\"\n ? {\n time: rawValue.timestamp,\n value: {\n type: \"Point\",\n coordinates: rawValue.position,\n },\n }\n : undefined,\n );\n }\n if (propDef.type === \"mediaReference\") {\n return new MediaReferencePropertyImpl({\n client,\n objectApiName: objectDef.apiName,\n primaryKey: rawObject[objectDef.primaryKeyApiName as string],\n propertyName: p as string,\n });\n }\n }\n }\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA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