@osdk/client 2.6.0-beta.6 → 2.6.0-beta.8
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 +27 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +31 -23
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +233 -63
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/mediaUpload.js +1 -1
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/observable/internal/base-list/BaseListQuery.js +133 -2
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/browser/observable/internal/links/LinksHelper.js +3 -0
- package/build/browser/observable/internal/links/LinksHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ListQuery.js +6 -58
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js +5 -1
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js +3 -0
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
- package/build/browser/observable/internal/types/ObjectUpdate.js +2 -0
- package/build/browser/observable/internal/types/ObjectUpdate.js.map +1 -0
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/toDataValue.js +3 -2
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +1 -1
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-VNLY3YOJ.cjs → chunk-HJV24UL2.cjs} +76 -78
- package/build/cjs/chunk-HJV24UL2.cjs.map +1 -0
- package/build/cjs/{chunk-3ZJESPX6.cjs → chunk-PCNVSZXT.cjs} +133 -67
- package/build/cjs/chunk-PCNVSZXT.cjs.map +1 -0
- package/build/cjs/index.cjs +8 -8
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +179 -92
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +31 -23
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +233 -63
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/mediaUpload.js +1 -1
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/observable/internal/base-list/BaseListQuery.js +133 -2
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/esm/observable/internal/links/LinksHelper.js +3 -0
- package/build/esm/observable/internal/links/LinksHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ListQuery.js +6 -58
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js +5 -1
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js +3 -0
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
- package/build/esm/observable/internal/types/ObjectUpdate.js +2 -0
- package/build/esm/observable/internal/types/ObjectUpdate.js.map +1 -0
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/toDataValue.js +3 -2
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +1 -1
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts +42 -2
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/links/LinksHelper.d.ts +4 -0
- package/build/types/observable/internal/links/LinksHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQuery.d.ts +2 -8
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +1 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -1
- package/build/types/observable/internal/types/ObjectUpdate.d.ts +11 -0
- package/build/types/observable/internal/types/ObjectUpdate.d.ts.map +1 -0
- package/package.json +9 -8
- package/build/cjs/chunk-3ZJESPX6.cjs.map +0 -1
- package/build/cjs/chunk-VNLY3YOJ.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
+
## 2.6.0-beta.8
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a1ffb20: Use new ephemeral media upload endpoint.
|
|
8
|
+
- e62c692: Allow all applicable filters for struct sub properties to be applied on struct arrays
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [a1ffb20]
|
|
13
|
+
- Updated dependencies [e62c692]
|
|
14
|
+
- @osdk/generator-converters@2.6.0-beta.8
|
|
15
|
+
- @osdk/api@2.6.0-beta.8
|
|
16
|
+
- @osdk/client.unstable@2.6.0-beta.8
|
|
17
|
+
|
|
18
|
+
## 2.6.0-beta.7
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 507ec7f: Allows top level filters with an implied and clause to support a combination of a not and and clause
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- @osdk/api@2.6.0-beta.7
|
|
27
|
+
- @osdk/client.unstable@2.6.0-beta.7
|
|
28
|
+
- @osdk/generator-converters@2.6.0-beta.7
|
|
29
|
+
|
|
3
30
|
## 2.6.0-beta.6
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isOk","NULL_VALUE","PalantirApiError","ActionValidationError","createClient","createPlatformClient","createAttachmentUpload","extractDate","extractDateInLocalTime","extractDateInUTC","createObjectSpecifierFromPrimaryKey","extractPrimaryKeyFromObjectSpecifier"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nexport { isOk, NULL_VALUE } from \"@osdk/api\";\nexport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ActionValidationResponse,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n Attachment,\n CompileTimeMetadata,\n DerivedProperty,\n InterfaceDefinition,\n InterfaceMetadata,\n Logger,\n ObjectMetadata,\n ObjectSet,\n ObjectSpecifier,\n ObjectTypeDefinition,\n Osdk,\n OsdkObject,\n OsdkObjectCreatePropertyType,\n OsdkObjectPropertyType,\n PageResult,\n PropertyDef,\n PropertyKeys,\n PropertyValueWireToClient,\n QueryDefinition,\n QueryParam,\n QueryResult,\n Range,\n Result,\n SingleLinkAccessor,\n ThreeDimensionalAggregation,\n TwoDimensionalAggregation,\n VersionBound,\n WhereClause,\n} from \"@osdk/api\";\nexport { PalantirApiError } from \"@osdk/shared.net.errors\";\n\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport type { Client } from \"./Client.js\";\nexport { createClient } from \"./createClient.js\";\nexport { createPlatformClient } from \"./createPlatformClient.js\";\nexport type { PlatformClient } from \"./createPlatformClient.js\";\nexport { createAttachmentUpload } from \"./object/AttachmentUpload.js\";\nexport type { ResultOrError } from \"./ResultOrError.js\";\n\nexport {\n extractDate,\n extractDateInLocalTime,\n extractDateInUTC,\n} from \"./util/datetimeConverters.js\";\n\nexport {\n createObjectSpecifierFromPrimaryKey,\n extractPrimaryKeyFromObjectSpecifier,\n} from \"./util/objectSpecifierUtils.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"index.js","names":["isOk","NULL_VALUE","PalantirApiError","ActionValidationError","createClient","createPlatformClient","createAttachmentUpload","extractDate","extractDateInLocalTime","extractDateInUTC","createObjectSpecifierFromPrimaryKey","extractPrimaryKeyFromObjectSpecifier"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nexport { isOk, NULL_VALUE } from \"@osdk/api\";\nexport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ActionValidationResponse,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n Attachment,\n CompileTimeMetadata,\n DerivedProperty,\n InterfaceDefinition,\n InterfaceMetadata,\n Logger,\n MediaReference,\n MediaUpload,\n ObjectMetadata,\n ObjectSet,\n ObjectSpecifier,\n ObjectTypeDefinition,\n Osdk,\n OsdkObject,\n OsdkObjectCreatePropertyType,\n OsdkObjectPropertyType,\n PageResult,\n PropertyDef,\n PropertyKeys,\n PropertyValueWireToClient,\n QueryDefinition,\n QueryParam,\n QueryResult,\n Range,\n Result,\n SingleLinkAccessor,\n ThreeDimensionalAggregation,\n TwoDimensionalAggregation,\n VersionBound,\n WhereClause,\n} from \"@osdk/api\";\nexport { PalantirApiError } from \"@osdk/shared.net.errors\";\n\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport type { Client } from \"./Client.js\";\nexport { createClient } from \"./createClient.js\";\nexport { createPlatformClient } from \"./createPlatformClient.js\";\nexport type { PlatformClient } from \"./createPlatformClient.js\";\nexport { createAttachmentUpload } from \"./object/AttachmentUpload.js\";\nexport type { ResultOrError } from \"./ResultOrError.js\";\n\nexport {\n extractDate,\n extractDateInLocalTime,\n extractDateInUTC,\n} from \"./util/datetimeConverters.js\";\n\nexport {\n createObjectSpecifierFromPrimaryKey,\n extractPrimaryKeyFromObjectSpecifier,\n} from \"./util/objectSpecifierUtils.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAW;AAyC5C,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,SAASC,qBAAqB,QAAQ,oCAAoC;AAE1E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,SAASC,sBAAsB,QAAQ,8BAA8B;AAGrE,SACEC,WAAW,EACXC,sBAAsB,EACtBC,gBAAgB,QACX,8BAA8B;AAErC,SACEC,mCAAmC,EACnCC,oCAAoC,QAC/B,gCAAgC","ignoreList":[]}
|
|
@@ -30,6 +30,22 @@ function isNotClause(whereClause) {
|
|
|
30
30
|
|
|
31
31
|
/** @internal */
|
|
32
32
|
export function modernToLegacyWhereClause(whereClause, objectOrInterface, rdpNames) {
|
|
33
|
+
const parts = Object.entries(whereClause).map(([key, value]) => ({
|
|
34
|
+
[key]: value
|
|
35
|
+
}));
|
|
36
|
+
if (parts.length === 1) {
|
|
37
|
+
return modernToLegacyWhereClauseInner(whereClause, objectOrInterface, rdpNames);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
type: "and",
|
|
41
|
+
value: parts.map(v => modernToLegacyWhereClauseInner(v, objectOrInterface, rdpNames))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
export function modernToLegacyWhereClauseInner(whereClause, objectOrInterface, rdpNames) {
|
|
47
|
+
const parts = Object.entries(whereClause);
|
|
48
|
+
!(parts.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "Invalid where clause provided.") : invariant(false) : void 0;
|
|
33
49
|
if (isAndClause(whereClause)) {
|
|
34
50
|
return {
|
|
35
51
|
type: "and",
|
|
@@ -46,14 +62,7 @@ export function modernToLegacyWhereClause(whereClause, objectOrInterface, rdpNam
|
|
|
46
62
|
value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface, rdpNames)
|
|
47
63
|
};
|
|
48
64
|
}
|
|
49
|
-
|
|
50
|
-
if (parts.length === 1) {
|
|
51
|
-
return handleWherePair(parts[0], objectOrInterface, undefined, rdpNames);
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
type: "and",
|
|
55
|
-
value: parts.map(v => handleWherePair(v, objectOrInterface, undefined, rdpNames))
|
|
56
|
-
};
|
|
65
|
+
return handleWherePair(parts[0], objectOrInterface, undefined, rdpNames);
|
|
57
66
|
}
|
|
58
67
|
function handleWherePair([fieldName, filter], objectOrInterface, structFieldSelector, rdpNames) {
|
|
59
68
|
!(filter != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Defined key values are only allowed when they are not undefined.") : invariant(false) : void 0;
|
|
@@ -67,6 +76,7 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
67
76
|
propertyApiName: fullyQualifyPropName(structFieldSelector.propertyApiName, objectOrInterface)
|
|
68
77
|
} : undefined;
|
|
69
78
|
const field = !isRdp && structFieldSelector == null ? fullyQualifyPropName(fieldName, objectOrInterface) : undefined;
|
|
79
|
+
!(field == null || propertyIdentifier == null && (field != null || isRdp != null)) ? process.env.NODE_ENV !== "production" ? invariant(false, "Encountered error constructing where clause: field and propertyIdentifier cannot both be defined") : invariant(false) : void 0;
|
|
70
80
|
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
71
81
|
return {
|
|
72
82
|
type: "eq",
|
|
@@ -83,6 +93,8 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
83
93
|
// e.g. `where({ name: { $eq: "foo", $ne: "bar" } })` is invalid currently
|
|
84
94
|
const hasDollarSign = keysOfFilter.some(key => key.startsWith("$"));
|
|
85
95
|
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.") : invariant(false) : void 0;
|
|
96
|
+
|
|
97
|
+
// Struct
|
|
86
98
|
if (!hasDollarSign) {
|
|
87
99
|
const structFilter = Object.entries(filter);
|
|
88
100
|
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant(false) : void 0;
|
|
@@ -94,6 +106,17 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
94
106
|
}
|
|
95
107
|
const firstKey = keysOfFilter[0];
|
|
96
108
|
!(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
|
|
109
|
+
|
|
110
|
+
// Struct array
|
|
111
|
+
if (firstKey === "$contains" && filter[firstKey] instanceof Object) {
|
|
112
|
+
const structFilter = Object.entries(filter[firstKey]);
|
|
113
|
+
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant(false) : void 0;
|
|
114
|
+
const structFieldApiName = structFilter[0][0];
|
|
115
|
+
return handleWherePair(structFilter[0], objectOrInterface, {
|
|
116
|
+
propertyApiName: fieldName,
|
|
117
|
+
structFieldApiName
|
|
118
|
+
});
|
|
119
|
+
}
|
|
97
120
|
if (firstKey === "$ne") {
|
|
98
121
|
return {
|
|
99
122
|
type: "not",
|
|
@@ -124,21 +147,6 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
124
147
|
fuzzy: typeof filter[firstKey] === "string" ? false : filter[firstKey]["fuzzySearch"] ?? false
|
|
125
148
|
};
|
|
126
149
|
}
|
|
127
|
-
if (firstKey === "$contains" && filter[firstKey] instanceof Object) {
|
|
128
|
-
const structFilter = Object.entries(filter[firstKey]);
|
|
129
|
-
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant(false) : void 0;
|
|
130
|
-
const structFieldApiName = structFilter[0][0];
|
|
131
|
-
!(structFilter[0][1] != null && Object.keys(structFilter[0][1]).length === 1 && "$eq" in structFilter[0][1]) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot filter on a struct field in an array with anything other than a single $eq") : invariant(false) : void 0;
|
|
132
|
-
return {
|
|
133
|
-
type: "contains",
|
|
134
|
-
propertyIdentifier: {
|
|
135
|
-
type: "structField",
|
|
136
|
-
propertyApiName: fieldName,
|
|
137
|
-
structFieldApiName
|
|
138
|
-
},
|
|
139
|
-
value: structFilter[0][1]["$eq"]
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
150
|
return {
|
|
143
151
|
type: firstKey.substring(1),
|
|
144
152
|
...(propertyIdentifier != null && {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.js","names":["invariant","fullyQualifyPropName","makeGeoFilterIntersects","makeGeoFilterWithin","isAndClause","whereClause","$and","undefined","isOrClause","$or","isNotClause","$not","modernToLegacyWhereClause","objectOrInterface","rdpNames","type","value","map","clause","parts","Object","entries","length","handleWherePair","v","fieldName","filter","structFieldSelector","process","env","NODE_ENV","isRdp","has","propertyIdentifier","apiName","propertyApiName","field","keysOfFilter","keys","hasDollarSign","some","key","startsWith","structFilter","structFieldApiName","firstKey","substring","fuzzy"],"sources":["modernToLegacyWhereClause.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 AndWhereClause,\n NotWhereClause,\n ObjectOrInterfaceDefinition,\n OrWhereClause,\n PossibleWhereClauseFilters,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport type {\n PropertyIdentifier,\n SearchJsonQueryV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { fullyQualifyPropName } from \"./fullyQualifyPropName.js\";\nimport { makeGeoFilterIntersects } from \"./makeGeoFilterIntersects.js\";\nimport { makeGeoFilterWithin } from \"./makeGeoFilterWithin.js\";\n\ntype DropDollarSign<T extends `$${string}`> = T extends `$${infer U}` ? U\n : never;\n\nfunction isAndClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is AndWhereClause<T, RDPs> {\n return \"$and\" in whereClause && whereClause.$and !== undefined;\n}\n\nfunction isOrClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is OrWhereClause<T, RDPs> {\n return \"$or\" in whereClause && whereClause.$or !== undefined;\n}\n\nfunction isNotClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is NotWhereClause<T, RDPs> {\n return \"$not\" in whereClause && whereClause.$not !== undefined;\n}\n\n/** @internal */\nexport function modernToLegacyWhereClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n if (isAndClause(whereClause)) {\n return {\n type: \"and\",\n value: (whereClause.$and as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isOrClause(whereClause)) {\n return {\n type: \"or\",\n value: (whereClause.$or as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isNotClause(whereClause)) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(\n whereClause.$not as WhereClause<T, RDPs>,\n objectOrInterface,\n rdpNames,\n ),\n };\n }\n\n const parts = Object.entries(whereClause);\n\n if (parts.length === 1) {\n return handleWherePair(parts[0], objectOrInterface, undefined, rdpNames);\n }\n\n return {\n type: \"and\",\n value: parts.map<SearchJsonQueryV2>(\n v => handleWherePair(v, objectOrInterface, undefined, rdpNames),\n ),\n };\n}\n\nfunction handleWherePair(\n [fieldName, filter]: [string, any],\n objectOrInterface: ObjectOrInterfaceDefinition,\n structFieldSelector?: { propertyApiName: string; structFieldApiName: string },\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n invariant(\n filter != null,\n \"Defined key values are only allowed when they are not undefined.\",\n );\n\n const isRdp = !structFieldSelector && rdpNames?.has(fieldName);\n\n const propertyIdentifier: PropertyIdentifier | undefined = isRdp\n ? {\n type: \"property\",\n apiName: fieldName,\n }\n : structFieldSelector != null\n ? {\n type: \"structField\",\n ...structFieldSelector,\n propertyApiName: fullyQualifyPropName(\n structFieldSelector.propertyApiName,\n objectOrInterface,\n ),\n }\n : undefined;\n\n const field = !isRdp && structFieldSelector == null\n ? fullyQualifyPropName(fieldName, objectOrInterface)\n : undefined;\n\n if (\n typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\"\n ) {\n propertyIdentifier;\n return {\n type: \"eq\",\n ...(propertyIdentifier != null\n && { propertyIdentifier }),\n field,\n value: filter,\n };\n }\n\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some((key) => key.startsWith(\"$\"));\n invariant(\n !hasDollarSign\n || keysOfFilter.length === 1,\n \"A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.\",\n );\n\n if (!hasDollarSign) {\n const structFilter = Object.entries(filter);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = keysOfFilter[0];\n return handleWherePair(Object.entries(filter)[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n }, rdpNames);\n }\n\n const firstKey = keysOfFilter[0] as PossibleWhereClauseFilters;\n invariant(filter[firstKey] != null);\n\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey],\n },\n };\n }\n\n if (firstKey === \"$within\") {\n return makeGeoFilterWithin(filter[firstKey], propertyIdentifier, field);\n }\n if (firstKey === \"$intersects\") {\n return makeGeoFilterIntersects(filter[firstKey], propertyIdentifier, field);\n }\n\n if (firstKey === \"$containsAllTerms\" || firstKey === \"$containsAnyTerm\") {\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: typeof filter[firstKey] === \"string\"\n ? filter[firstKey]\n : filter[firstKey][\"term\"],\n fuzzy: typeof filter[firstKey] === \"string\"\n ? false\n : filter[firstKey][\"fuzzySearch\"] ?? false,\n };\n }\n\n if (firstKey === \"$contains\" && filter[firstKey] instanceof Object) {\n const structFilter: [string, any][] = Object.entries(filter[firstKey]);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = structFilter[0][0];\n invariant(\n structFilter[0][1] != null\n && Object.keys(structFilter[0][1]).length === 1\n && \"$eq\" in structFilter[0][1],\n \"Cannot filter on a struct field in an array with anything other than a single $eq\",\n );\n return {\n type: \"contains\",\n propertyIdentifier: {\n type: \"structField\",\n propertyApiName: fieldName,\n structFieldApiName,\n },\n value: structFilter[0][1][\"$eq\"],\n };\n }\n\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey] as any,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,mBAAmB,QAAQ,0BAA0B;AAK9D,SAASC,WAA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AAM,CAACkB,IAAI,CAACK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACrB,MAAM,KAAK,CAAC,IAC5C,KAAK,IAAIqB,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAAf,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAHlC9B,SAAS,QAIP,mFAAmF,IAJrFA,SAAS;IAMT,OAAO;MACLe,IAAI,EAAE,UAAU;MAChBkB,kBAAkB,EAAE;QAClBlB,IAAI,EAAE,aAAa;QACnBoB,eAAe,EAAEV,SAAS;QAC1BmB;MACF,CAAC;MACD5B,KAAK,EAAE2B,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;IACjC,CAAC;EACH;EAEA,OAAO;IACL5B,IAAI,EAAE8B,QAAQ,CAACC,SAAS,CAAC,CAAC,CAAoC;IAC9D,IAAIb,kBAAkB,IAAI,IAAI,IAAI;MAAEA;IAAmB,CAAC,CAAC;IACzDG,KAAK;IACLpB,KAAK,EAAEU,MAAM,CAACmB,QAAQ;EACxB,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.js","names":["invariant","fullyQualifyPropName","makeGeoFilterIntersects","makeGeoFilterWithin","isAndClause","whereClause","$and","undefined","isOrClause","$or","isNotClause","$not","modernToLegacyWhereClause","objectOrInterface","rdpNames","parts","Object","entries","map","key","value","length","modernToLegacyWhereClauseInner","type","v","process","env","NODE_ENV","clause","handleWherePair","fieldName","filter","structFieldSelector","isRdp","has","propertyIdentifier","apiName","propertyApiName","field","keysOfFilter","keys","hasDollarSign","some","startsWith","structFilter","structFieldApiName","firstKey","substring","fuzzy"],"sources":["modernToLegacyWhereClause.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 AndWhereClause,\n NotWhereClause,\n ObjectOrInterfaceDefinition,\n OrWhereClause,\n PossibleWhereClauseFilters,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport type {\n PropertyIdentifier,\n SearchJsonQueryV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { fullyQualifyPropName } from \"./fullyQualifyPropName.js\";\nimport { makeGeoFilterIntersects } from \"./makeGeoFilterIntersects.js\";\nimport { makeGeoFilterWithin } from \"./makeGeoFilterWithin.js\";\n\ntype DropDollarSign<T extends `$${string}`> = T extends `$${infer U}` ? U\n : never;\n\nfunction isAndClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is AndWhereClause<T, RDPs> {\n return \"$and\" in whereClause && whereClause.$and !== undefined;\n}\n\nfunction isOrClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is OrWhereClause<T, RDPs> {\n return \"$or\" in whereClause && whereClause.$or !== undefined;\n}\n\nfunction isNotClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n): whereClause is NotWhereClause<T, RDPs> {\n return \"$not\" in whereClause && whereClause.$not !== undefined;\n}\n\n/** @internal */\nexport function modernToLegacyWhereClause<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n const parts = Object.entries(whereClause).map(([key, value]) => ({\n [key]: value,\n })) as WhereClause<T, RDPs>[];\n if (parts.length === 1) {\n return modernToLegacyWhereClauseInner(\n whereClause,\n objectOrInterface,\n rdpNames,\n );\n }\n return {\n type: \"and\",\n value: parts.map<SearchJsonQueryV2>(\n v => modernToLegacyWhereClauseInner(v, objectOrInterface, rdpNames),\n ),\n };\n}\n\n/** @internal */\nexport function modernToLegacyWhereClauseInner<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n whereClause: WhereClause<T, RDPs>,\n objectOrInterface: T,\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n const parts = Object.entries(whereClause);\n\n invariant(parts.length === 1, \"Invalid where clause provided.\");\n\n if (isAndClause(whereClause)) {\n return {\n type: \"and\",\n value: (whereClause.$and as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isOrClause(whereClause)) {\n return {\n type: \"or\",\n value: (whereClause.$or as WhereClause<T, RDPs>[]).map(\n (clause) =>\n modernToLegacyWhereClause(clause, objectOrInterface, rdpNames),\n ),\n };\n } else if (isNotClause(whereClause)) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(\n whereClause.$not as WhereClause<T, RDPs>,\n objectOrInterface,\n rdpNames,\n ),\n };\n }\n\n return handleWherePair(parts[0], objectOrInterface, undefined, rdpNames);\n}\n\nfunction handleWherePair(\n [fieldName, filter]: [string, any],\n objectOrInterface: ObjectOrInterfaceDefinition,\n structFieldSelector?: { propertyApiName: string; structFieldApiName: string },\n rdpNames?: Set<string>,\n): SearchJsonQueryV2 {\n invariant(\n filter != null,\n \"Defined key values are only allowed when they are not undefined.\",\n );\n\n const isRdp = !structFieldSelector && rdpNames?.has(fieldName);\n\n const propertyIdentifier: PropertyIdentifier | undefined = isRdp\n ? {\n type: \"property\",\n apiName: fieldName,\n }\n : structFieldSelector != null\n ? {\n type: \"structField\",\n ...structFieldSelector,\n propertyApiName: fullyQualifyPropName(\n structFieldSelector.propertyApiName,\n objectOrInterface,\n ),\n }\n : undefined;\n\n const field = !isRdp && structFieldSelector == null\n ? fullyQualifyPropName(fieldName, objectOrInterface)\n : undefined;\n\n invariant(\n field == null\n || propertyIdentifier == null && (field != null || isRdp != null),\n \"Encountered error constructing where clause: field and propertyIdentifier cannot both be defined\",\n );\n\n if (\n typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\"\n ) {\n return {\n type: \"eq\",\n ...(propertyIdentifier != null\n && { propertyIdentifier }),\n field,\n value: filter,\n };\n }\n\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some((key) => key.startsWith(\"$\"));\n invariant(\n !hasDollarSign\n || keysOfFilter.length === 1,\n \"A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.\",\n );\n\n // Struct\n if (!hasDollarSign) {\n const structFilter = Object.entries(filter);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = keysOfFilter[0];\n return handleWherePair(Object.entries(filter)[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n }, rdpNames);\n }\n\n const firstKey = keysOfFilter[0] as PossibleWhereClauseFilters;\n invariant(filter[firstKey] != null);\n\n // Struct array\n if (firstKey === \"$contains\" && filter[firstKey] instanceof Object) {\n const structFilter: [string, any][] = Object.entries(filter[firstKey]);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = structFilter[0][0];\n\n return handleWherePair(structFilter[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n });\n }\n\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey],\n },\n };\n }\n\n if (firstKey === \"$within\") {\n return makeGeoFilterWithin(filter[firstKey], propertyIdentifier, field);\n }\n if (firstKey === \"$intersects\") {\n return makeGeoFilterIntersects(filter[firstKey], propertyIdentifier, field);\n }\n\n if (firstKey === \"$containsAllTerms\" || firstKey === \"$containsAnyTerm\") {\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: typeof filter[firstKey] === \"string\"\n ? filter[firstKey]\n : filter[firstKey][\"term\"],\n fuzzy: typeof filter[firstKey] === \"string\"\n ? false\n : filter[firstKey][\"fuzzySearch\"] ?? false,\n };\n }\n\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey] as any,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,mBAAmB,QAAQ,0BAA0B;AAK9D,SAASC,WAAWA,CAIlBC,WAAiC,EACO;EACxC,OAAO,MAAM,IAAIA,WAAW,IAAIA,WAAW,CAACC,IAAI,KAAKC,SAAS;AAChE;AAEA,SAASC,UAAUA,CAIjBH,WAAiC,EACM;EACvC,OAAO,KAAK,IAAIA,WAAW,IAAIA,WAAW,CAACI,GAAG,KAAKF,SAAS;AAC9D;AAEA,SAASG,WAAWA,CAIlBL,WAAiC,EACO;EACxC,OAAO,MAAM,IAAIA,WAAW,IAAIA,WAAW,CAACM,IAAI,KAAKJ,SAAS;AAChE;;AAEA;AACA,OAAO,SAASK,yBAAyBA,CAIvCP,WAAiC,EACjCQ,iBAAoB,EACpBC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;MACLlB,KAAK,EAAE,OAAOW,MAAM,CAACe,QAAQ,CAAC,KAAK,QAAQ,GACvCf,MAAM,CAACe,QAAQ,CAAC,GAChBf,MAAM,CAACe,QAAQ,CAAC,CAAC,MAAM,CAAC;MAC5BE,KAAK,EAAE,OAAOjB,MAAM,CAACe,QAAQ,CAAC,KAAK,QAAQ,GACvC,KAAK,GACLf,MAAM,CAACe,QAAQ,CAAC,CAAC,aAAa,CAAC,IAAI;IACzC,CAAC;EACH;EAEA,OAAO;IACLvB,IAAI,EAAEuB,QAAQ,CAACC,SAAS,CAAC,CAAC,CAAoC;IAC9D,IAAIZ,kBAAkB,IAAI,IAAI,IAAI;MAAEA;IAAmB,CAAC,CAAC;IACzDG,KAAK;IACLlB,KAAK,EAAEW,MAAM,CAACe,QAAQ;EACxB,CAAC;AACH","ignoreList":[]}
|
|
@@ -907,6 +907,68 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
907
907
|
}
|
|
908
908
|
`);
|
|
909
909
|
});
|
|
910
|
+
it("converts struct arrays correctly", () => {
|
|
911
|
+
expect(modernToLegacyWhereClause({
|
|
912
|
+
$and: [{
|
|
913
|
+
addressArray: {
|
|
914
|
+
$contains: {
|
|
915
|
+
zipCode: {
|
|
916
|
+
$gte: 10001
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}, {
|
|
921
|
+
addressArray: {
|
|
922
|
+
$contains: {
|
|
923
|
+
location: {
|
|
924
|
+
$within: [1, 2, 3, 4]
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}]
|
|
929
|
+
}, BgaoNflPlayer)).toMatchInlineSnapshot(`
|
|
930
|
+
{
|
|
931
|
+
"type": "and",
|
|
932
|
+
"value": [
|
|
933
|
+
{
|
|
934
|
+
"field": undefined,
|
|
935
|
+
"propertyIdentifier": {
|
|
936
|
+
"propertyApiName": "addressArray",
|
|
937
|
+
"structFieldApiName": "zipCode",
|
|
938
|
+
"type": "structField",
|
|
939
|
+
},
|
|
940
|
+
"type": "gte",
|
|
941
|
+
"value": 10001,
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
"field": undefined,
|
|
945
|
+
"propertyIdentifier": {
|
|
946
|
+
"propertyApiName": "addressArray",
|
|
947
|
+
"structFieldApiName": "location",
|
|
948
|
+
"type": "structField",
|
|
949
|
+
},
|
|
950
|
+
"type": "withinBoundingBox",
|
|
951
|
+
"value": {
|
|
952
|
+
"bottomRight": {
|
|
953
|
+
"coordinates": [
|
|
954
|
+
3,
|
|
955
|
+
2,
|
|
956
|
+
],
|
|
957
|
+
"type": "Point",
|
|
958
|
+
},
|
|
959
|
+
"topLeft": {
|
|
960
|
+
"coordinates": [
|
|
961
|
+
1,
|
|
962
|
+
4,
|
|
963
|
+
],
|
|
964
|
+
"type": "Point",
|
|
965
|
+
},
|
|
966
|
+
},
|
|
967
|
+
},
|
|
968
|
+
],
|
|
969
|
+
}
|
|
970
|
+
`);
|
|
971
|
+
});
|
|
910
972
|
});
|
|
911
973
|
describe("multiple checks", () => {
|
|
912
974
|
it("properly handles multiple simple where checks", () => {
|
|
@@ -983,6 +1045,80 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
983
1045
|
});
|
|
984
1046
|
});
|
|
985
1047
|
});
|
|
1048
|
+
describe("mixed $ operators and regular properties", () => {
|
|
1049
|
+
it("should handle $not operator with regular properties at top level", () => {
|
|
1050
|
+
const result = modernToLegacyWhereClause({
|
|
1051
|
+
integer: {
|
|
1052
|
+
$eq: 5
|
|
1053
|
+
},
|
|
1054
|
+
$not: {
|
|
1055
|
+
string: {
|
|
1056
|
+
$in: ["a", "b", "c"]
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
}, objectTypeWithAllPropertyTypes);
|
|
1060
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1061
|
+
{
|
|
1062
|
+
"type": "and",
|
|
1063
|
+
"value": [
|
|
1064
|
+
{
|
|
1065
|
+
"field": "integer",
|
|
1066
|
+
"type": "eq",
|
|
1067
|
+
"value": 5,
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
"type": "not",
|
|
1071
|
+
"value": {
|
|
1072
|
+
"field": "string",
|
|
1073
|
+
"type": "in",
|
|
1074
|
+
"value": [
|
|
1075
|
+
"a",
|
|
1076
|
+
"b",
|
|
1077
|
+
"c",
|
|
1078
|
+
],
|
|
1079
|
+
},
|
|
1080
|
+
},
|
|
1081
|
+
],
|
|
1082
|
+
}
|
|
1083
|
+
`);
|
|
1084
|
+
});
|
|
1085
|
+
it("should handle multiple regular properties with $not at top level", () => {
|
|
1086
|
+
const result = modernToLegacyWhereClause({
|
|
1087
|
+
integer: 5,
|
|
1088
|
+
boolean: true,
|
|
1089
|
+
$not: {
|
|
1090
|
+
string: {
|
|
1091
|
+
$eq: "excluded"
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}, objectTypeWithAllPropertyTypes);
|
|
1095
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1096
|
+
{
|
|
1097
|
+
"type": "and",
|
|
1098
|
+
"value": [
|
|
1099
|
+
{
|
|
1100
|
+
"field": "integer",
|
|
1101
|
+
"type": "eq",
|
|
1102
|
+
"value": 5,
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
"field": "boolean",
|
|
1106
|
+
"type": "eq",
|
|
1107
|
+
"value": true,
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
"type": "not",
|
|
1111
|
+
"value": {
|
|
1112
|
+
"field": "string",
|
|
1113
|
+
"type": "eq",
|
|
1114
|
+
"value": "excluded",
|
|
1115
|
+
},
|
|
1116
|
+
},
|
|
1117
|
+
],
|
|
1118
|
+
}
|
|
1119
|
+
`);
|
|
1120
|
+
});
|
|
1121
|
+
});
|
|
986
1122
|
describe("RDP properties", () => {
|
|
987
1123
|
const mockObjectType = {
|
|
988
1124
|
type: "object",
|
|
@@ -1022,28 +1158,36 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
1022
1158
|
},
|
|
1023
1159
|
managerName: "John"
|
|
1024
1160
|
}, mockObjectType, rdpNames);
|
|
1025
|
-
expect(result).
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1161
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1162
|
+
{
|
|
1163
|
+
"type": "and",
|
|
1164
|
+
"value": [
|
|
1165
|
+
{
|
|
1166
|
+
"field": "department",
|
|
1167
|
+
"type": "eq",
|
|
1168
|
+
"value": "Engineering",
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
"field": undefined,
|
|
1172
|
+
"propertyIdentifier": {
|
|
1173
|
+
"apiName": "reportCount",
|
|
1174
|
+
"type": "property",
|
|
1175
|
+
},
|
|
1176
|
+
"type": "gte",
|
|
1177
|
+
"value": 5,
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
"field": undefined,
|
|
1181
|
+
"propertyIdentifier": {
|
|
1182
|
+
"apiName": "managerName",
|
|
1183
|
+
"type": "property",
|
|
1184
|
+
},
|
|
1185
|
+
"type": "eq",
|
|
1186
|
+
"value": "John",
|
|
1187
|
+
},
|
|
1188
|
+
],
|
|
1189
|
+
}
|
|
1190
|
+
`);
|
|
1047
1191
|
});
|
|
1048
1192
|
it("should handle RDP properties in $and clauses", () => {
|
|
1049
1193
|
const rdpNames = new Set(["reportCount"]);
|
|
@@ -1056,21 +1200,27 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
1056
1200
|
}
|
|
1057
1201
|
}]
|
|
1058
1202
|
}, mockObjectType, rdpNames);
|
|
1059
|
-
expect(result).
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1203
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1204
|
+
{
|
|
1205
|
+
"type": "and",
|
|
1206
|
+
"value": [
|
|
1207
|
+
{
|
|
1208
|
+
"field": "department",
|
|
1209
|
+
"type": "eq",
|
|
1210
|
+
"value": "Engineering",
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
"field": undefined,
|
|
1214
|
+
"propertyIdentifier": {
|
|
1215
|
+
"apiName": "reportCount",
|
|
1216
|
+
"type": "property",
|
|
1217
|
+
},
|
|
1218
|
+
"type": "gte",
|
|
1219
|
+
"value": 5,
|
|
1220
|
+
},
|
|
1221
|
+
],
|
|
1222
|
+
}
|
|
1223
|
+
`);
|
|
1074
1224
|
});
|
|
1075
1225
|
it("should handle complex nested structures with RDP", () => {
|
|
1076
1226
|
const rdpNames = new Set(["reportCount", "managerName"]);
|
|
@@ -1092,34 +1242,54 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
1092
1242
|
}, mockObjectType, rdpNames);
|
|
1093
1243
|
|
|
1094
1244
|
// The actual structure flattens the nested $and differently
|
|
1095
|
-
expect(result).
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
}, {
|
|
1104
|
-
type: "gte",
|
|
1105
|
-
propertyIdentifier: {
|
|
1106
|
-
type: "property",
|
|
1107
|
-
apiName: "reportCount"
|
|
1245
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1246
|
+
{
|
|
1247
|
+
"type": "and",
|
|
1248
|
+
"value": [
|
|
1249
|
+
{
|
|
1250
|
+
"field": "department",
|
|
1251
|
+
"type": "eq",
|
|
1252
|
+
"value": "Engineering",
|
|
1108
1253
|
},
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1254
|
+
{
|
|
1255
|
+
"type": "and",
|
|
1256
|
+
"value": [
|
|
1257
|
+
{
|
|
1258
|
+
"type": "or",
|
|
1259
|
+
"value": [
|
|
1260
|
+
{
|
|
1261
|
+
"field": "status",
|
|
1262
|
+
"type": "eq",
|
|
1263
|
+
"value": "active",
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
"field": undefined,
|
|
1267
|
+
"propertyIdentifier": {
|
|
1268
|
+
"apiName": "reportCount",
|
|
1269
|
+
"type": "property",
|
|
1270
|
+
},
|
|
1271
|
+
"type": "gte",
|
|
1272
|
+
"value": 10,
|
|
1273
|
+
},
|
|
1274
|
+
],
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
"type": "not",
|
|
1278
|
+
"value": {
|
|
1279
|
+
"field": undefined,
|
|
1280
|
+
"propertyIdentifier": {
|
|
1281
|
+
"apiName": "managerName",
|
|
1282
|
+
"type": "property",
|
|
1283
|
+
},
|
|
1284
|
+
"type": "eq",
|
|
1285
|
+
"value": "Admin",
|
|
1286
|
+
},
|
|
1287
|
+
},
|
|
1288
|
+
],
|
|
1118
1289
|
},
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
});
|
|
1290
|
+
],
|
|
1291
|
+
}
|
|
1292
|
+
`);
|
|
1123
1293
|
});
|
|
1124
1294
|
});
|
|
1125
1295
|
});
|