@osdk/client 2.6.0-beta.6 → 2.6.0-beta.7

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 (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +18 -8
  3. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  4. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +171 -63
  5. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  6. package/build/browser/observable/internal/base-list/BaseListQuery.js +133 -2
  7. package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
  8. package/build/browser/observable/internal/links/LinksHelper.js +3 -0
  9. package/build/browser/observable/internal/links/LinksHelper.js.map +1 -1
  10. package/build/browser/observable/internal/list/ListQuery.js +6 -58
  11. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  12. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +5 -1
  13. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  14. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +3 -0
  15. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  16. package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
  17. package/build/browser/observable/internal/types/ObjectUpdate.js +2 -0
  18. package/build/browser/observable/internal/types/ObjectUpdate.js.map +1 -0
  19. package/build/browser/util/UserAgent.js +2 -2
  20. package/build/cjs/{chunk-VNLY3YOJ.cjs → chunk-3LMKH6RS.cjs} +55 -47
  21. package/build/cjs/chunk-3LMKH6RS.cjs.map +1 -0
  22. package/build/cjs/{chunk-3ZJESPX6.cjs → chunk-4ZOXOCQX.cjs} +54 -54
  23. package/build/cjs/{chunk-3ZJESPX6.cjs.map → chunk-4ZOXOCQX.cjs.map} +1 -1
  24. package/build/cjs/index.cjs +8 -8
  25. package/build/cjs/public/internal.cjs +8 -8
  26. package/build/cjs/public/unstable-do-not-use.cjs +179 -92
  27. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  28. package/build/cjs/public/unstable-do-not-use.d.cts +1 -0
  29. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +18 -8
  30. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  31. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +171 -63
  32. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  33. package/build/esm/observable/internal/base-list/BaseListQuery.js +133 -2
  34. package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
  35. package/build/esm/observable/internal/links/LinksHelper.js +3 -0
  36. package/build/esm/observable/internal/links/LinksHelper.js.map +1 -1
  37. package/build/esm/observable/internal/list/ListQuery.js +6 -58
  38. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  39. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +5 -1
  40. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  41. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +3 -0
  42. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  43. package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
  44. package/build/esm/observable/internal/types/ObjectUpdate.js +2 -0
  45. package/build/esm/observable/internal/types/ObjectUpdate.js.map +1 -0
  46. package/build/esm/util/UserAgent.js +2 -2
  47. package/build/types/observable/internal/base-list/BaseListQuery.d.ts +42 -2
  48. package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
  49. package/build/types/observable/internal/links/LinksHelper.d.ts +4 -0
  50. package/build/types/observable/internal/links/LinksHelper.d.ts.map +1 -1
  51. package/build/types/observable/internal/list/ListQuery.d.ts +2 -8
  52. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  53. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
  54. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -1
  55. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
  56. package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +1 -0
  57. package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -1
  58. package/build/types/observable/internal/types/ObjectUpdate.d.ts +11 -0
  59. package/build/types/observable/internal/types/ObjectUpdate.d.ts.map +1 -0
  60. package/package.json +6 -6
  61. package/build/cjs/chunk-VNLY3YOJ.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 2.6.0-beta.7
4
+
5
+ ### Minor Changes
6
+
7
+ - 507ec7f: Allows top level filters with an implied and clause to support a combination of a not and and clause
8
+
9
+ ### Patch Changes
10
+
11
+ - @osdk/api@2.6.0-beta.7
12
+ - @osdk/client.unstable@2.6.0-beta.7
13
+ - @osdk/generator-converters@2.6.0-beta.7
14
+
3
15
  ## 2.6.0-beta.6
4
16
 
5
17
  ### Minor Changes
@@ -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
- const parts = Object.entries(whereClause);
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",
@@ -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,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,QAAsB,EACH;EACnB,IAAIV,WAAW,CAACC,WAAW,CAAC,EAAE;IAC5B,OAAO;MACLU,IAAI,EAAE,KAAK;MACXC,KAAK,EAAGX,WAAW,CAACC,IAAI,CAA4BW,GAAG,CACpDC,MAA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AAkB,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 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,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,QAAsB,EACH;EACnB,MAAMC,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACZ,WAAW,CAAC,CAACa,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,MAAM;IAC/D,CAACD,GAAG,GAAGC;EACT,CAAC,CAAC,CAA2B;EAC7B,IAAIL,KAAK,CAACM,MAAM,KAAK,CAAC,EAAE;IACtB,OAAOC,8BAA8B,CACnCjB,WAAW,EACXQ,iBAAiB,EACjBC,QACF,CAAC;EACH;EACA,OAAO;IACLS,IAAI,EAAE,KAAK;IACXH,KAAK,EAAEL,KAAK,CAACG,GAAG,CACdM,CAAC,IAAIF,8BAA8B,CAACE,CAAC,EAAEX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AA,oBAHlC3B,SAAS,QAIP,mFAAmF,IAJrFA,SAAS;IAMT,OAAO;MACLuB,IAAI,EAAE,UAAU;MAChBY,kBAAkB,EAAE;QAClBZ,IAAI,EAAE,aAAa;QACnBc,eAAe,EAAEP,SAAS;QAC1Be;MACF,CAAC;MACDzB,KAAK,EAAEwB,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;IACjC,CAAC;EACH;EAEA,OAAO;IACLrB,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":[]}
@@ -983,6 +983,80 @@ describe(modernToLegacyWhereClause, () => {
983
983
  });
984
984
  });
985
985
  });
986
+ describe("mixed $ operators and regular properties", () => {
987
+ it("should handle $not operator with regular properties at top level", () => {
988
+ const result = modernToLegacyWhereClause({
989
+ integer: {
990
+ $eq: 5
991
+ },
992
+ $not: {
993
+ string: {
994
+ $in: ["a", "b", "c"]
995
+ }
996
+ }
997
+ }, objectTypeWithAllPropertyTypes);
998
+ expect(result).toMatchInlineSnapshot(`
999
+ {
1000
+ "type": "and",
1001
+ "value": [
1002
+ {
1003
+ "field": "integer",
1004
+ "type": "eq",
1005
+ "value": 5,
1006
+ },
1007
+ {
1008
+ "type": "not",
1009
+ "value": {
1010
+ "field": "string",
1011
+ "type": "in",
1012
+ "value": [
1013
+ "a",
1014
+ "b",
1015
+ "c",
1016
+ ],
1017
+ },
1018
+ },
1019
+ ],
1020
+ }
1021
+ `);
1022
+ });
1023
+ it("should handle multiple regular properties with $not at top level", () => {
1024
+ const result = modernToLegacyWhereClause({
1025
+ integer: 5,
1026
+ boolean: true,
1027
+ $not: {
1028
+ string: {
1029
+ $eq: "excluded"
1030
+ }
1031
+ }
1032
+ }, objectTypeWithAllPropertyTypes);
1033
+ expect(result).toMatchInlineSnapshot(`
1034
+ {
1035
+ "type": "and",
1036
+ "value": [
1037
+ {
1038
+ "field": "integer",
1039
+ "type": "eq",
1040
+ "value": 5,
1041
+ },
1042
+ {
1043
+ "field": "boolean",
1044
+ "type": "eq",
1045
+ "value": true,
1046
+ },
1047
+ {
1048
+ "type": "not",
1049
+ "value": {
1050
+ "field": "string",
1051
+ "type": "eq",
1052
+ "value": "excluded",
1053
+ },
1054
+ },
1055
+ ],
1056
+ }
1057
+ `);
1058
+ });
1059
+ });
986
1060
  describe("RDP properties", () => {
987
1061
  const mockObjectType = {
988
1062
  type: "object",
@@ -1022,28 +1096,36 @@ describe(modernToLegacyWhereClause, () => {
1022
1096
  },
1023
1097
  managerName: "John"
1024
1098
  }, mockObjectType, rdpNames);
1025
- expect(result).toEqual({
1026
- type: "and",
1027
- value: [{
1028
- type: "eq",
1029
- field: "department",
1030
- value: "Engineering"
1031
- }, {
1032
- type: "gte",
1033
- propertyIdentifier: {
1034
- type: "property",
1035
- apiName: "reportCount"
1036
- },
1037
- value: 5
1038
- }, {
1039
- type: "eq",
1040
- propertyIdentifier: {
1041
- type: "property",
1042
- apiName: "managerName"
1043
- },
1044
- value: "John"
1045
- }]
1046
- });
1099
+ expect(result).toMatchInlineSnapshot(`
1100
+ {
1101
+ "type": "and",
1102
+ "value": [
1103
+ {
1104
+ "field": "department",
1105
+ "type": "eq",
1106
+ "value": "Engineering",
1107
+ },
1108
+ {
1109
+ "field": undefined,
1110
+ "propertyIdentifier": {
1111
+ "apiName": "reportCount",
1112
+ "type": "property",
1113
+ },
1114
+ "type": "gte",
1115
+ "value": 5,
1116
+ },
1117
+ {
1118
+ "field": undefined,
1119
+ "propertyIdentifier": {
1120
+ "apiName": "managerName",
1121
+ "type": "property",
1122
+ },
1123
+ "type": "eq",
1124
+ "value": "John",
1125
+ },
1126
+ ],
1127
+ }
1128
+ `);
1047
1129
  });
1048
1130
  it("should handle RDP properties in $and clauses", () => {
1049
1131
  const rdpNames = new Set(["reportCount"]);
@@ -1056,21 +1138,27 @@ describe(modernToLegacyWhereClause, () => {
1056
1138
  }
1057
1139
  }]
1058
1140
  }, mockObjectType, rdpNames);
1059
- expect(result).toEqual({
1060
- type: "and",
1061
- value: [{
1062
- type: "eq",
1063
- field: "department",
1064
- value: "Engineering"
1065
- }, {
1066
- type: "gte",
1067
- propertyIdentifier: {
1068
- type: "property",
1069
- apiName: "reportCount"
1070
- },
1071
- value: 5
1072
- }]
1073
- });
1141
+ expect(result).toMatchInlineSnapshot(`
1142
+ {
1143
+ "type": "and",
1144
+ "value": [
1145
+ {
1146
+ "field": "department",
1147
+ "type": "eq",
1148
+ "value": "Engineering",
1149
+ },
1150
+ {
1151
+ "field": undefined,
1152
+ "propertyIdentifier": {
1153
+ "apiName": "reportCount",
1154
+ "type": "property",
1155
+ },
1156
+ "type": "gte",
1157
+ "value": 5,
1158
+ },
1159
+ ],
1160
+ }
1161
+ `);
1074
1162
  });
1075
1163
  it("should handle complex nested structures with RDP", () => {
1076
1164
  const rdpNames = new Set(["reportCount", "managerName"]);
@@ -1092,34 +1180,54 @@ describe(modernToLegacyWhereClause, () => {
1092
1180
  }, mockObjectType, rdpNames);
1093
1181
 
1094
1182
  // The actual structure flattens the nested $and differently
1095
- expect(result).toEqual({
1096
- type: "and",
1097
- value: [{
1098
- type: "or",
1099
- value: [{
1100
- type: "eq",
1101
- field: "status",
1102
- value: "active"
1103
- }, {
1104
- type: "gte",
1105
- propertyIdentifier: {
1106
- type: "property",
1107
- apiName: "reportCount"
1183
+ expect(result).toMatchInlineSnapshot(`
1184
+ {
1185
+ "type": "and",
1186
+ "value": [
1187
+ {
1188
+ "field": "department",
1189
+ "type": "eq",
1190
+ "value": "Engineering",
1108
1191
  },
1109
- value: 10
1110
- }]
1111
- }, {
1112
- type: "not",
1113
- value: {
1114
- type: "eq",
1115
- propertyIdentifier: {
1116
- type: "property",
1117
- apiName: "managerName"
1192
+ {
1193
+ "type": "and",
1194
+ "value": [
1195
+ {
1196
+ "type": "or",
1197
+ "value": [
1198
+ {
1199
+ "field": "status",
1200
+ "type": "eq",
1201
+ "value": "active",
1202
+ },
1203
+ {
1204
+ "field": undefined,
1205
+ "propertyIdentifier": {
1206
+ "apiName": "reportCount",
1207
+ "type": "property",
1208
+ },
1209
+ "type": "gte",
1210
+ "value": 10,
1211
+ },
1212
+ ],
1213
+ },
1214
+ {
1215
+ "type": "not",
1216
+ "value": {
1217
+ "field": undefined,
1218
+ "propertyIdentifier": {
1219
+ "apiName": "managerName",
1220
+ "type": "property",
1221
+ },
1222
+ "type": "eq",
1223
+ "value": "Admin",
1224
+ },
1225
+ },
1226
+ ],
1118
1227
  },
1119
- value: "Admin"
1120
- }
1121
- }]
1122
- });
1228
+ ],
1229
+ }
1230
+ `);
1123
1231
  });
1124
1232
  });
1125
1233
  });