@osdk/client 2.0.2-rc.0 → 2.1.0-beta.0

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 (98) hide show
  1. package/CHANGELOG.md +17 -15
  2. package/build/browser/Client.d.ts +1 -1
  3. package/build/browser/Client.js +1 -1
  4. package/build/browser/Client.js.map +1 -1
  5. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
  6. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
  7. package/build/browser/createClient.d.ts.map +1 -1
  8. package/build/browser/createClient.js +11 -0
  9. package/build/browser/createClient.js.map +1 -1
  10. package/build/browser/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
  11. package/build/browser/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
  12. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +19 -7
  13. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  14. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +117 -14
  15. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  16. package/build/browser/object/aggregate.js +1 -1
  17. package/build/browser/object/aggregate.js.map +1 -1
  18. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -2
  19. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  20. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +27 -1
  21. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  22. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts +2 -0
  23. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts.map +1 -0
  24. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js +190 -0
  25. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -0
  26. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +1 -3
  27. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  28. package/build/browser/object/convertWireToOsdkObjects.test.js +25 -1
  29. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  30. package/build/browser/object/fetchSingle.js +1 -1
  31. package/build/browser/object/fetchSingle.js.map +1 -1
  32. package/build/browser/object/object.test.js +1 -1
  33. package/build/browser/object/object.test.js.map +1 -1
  34. package/build/browser/objectSet/ObjectSet.test.js +0 -1
  35. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  36. package/build/browser/objectSet/ObjectSetListenerWebsocket.d.ts +1 -6
  37. package/build/browser/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
  38. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +37 -156
  39. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  40. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +17 -16
  41. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  42. package/build/browser/objectSet/createObjectSet.js +3 -3
  43. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  44. package/build/browser/queries/applyQuery.js +3 -3
  45. package/build/browser/queries/applyQuery.js.map +1 -1
  46. package/build/browser/queries/queries.test.js +7 -1
  47. package/build/browser/queries/queries.test.js.map +1 -1
  48. package/build/browser/util/UserAgent.js +1 -1
  49. package/build/browser/util/UserAgent.js.map +1 -1
  50. package/build/esm/Client.d.ts +1 -1
  51. package/build/esm/Client.js +1 -1
  52. package/build/esm/Client.js.map +1 -1
  53. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
  54. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
  55. package/build/esm/createClient.d.ts.map +1 -1
  56. package/build/esm/createClient.js +11 -0
  57. package/build/esm/createClient.js.map +1 -1
  58. package/build/esm/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
  59. package/build/esm/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
  60. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +19 -7
  61. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  62. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +117 -14
  63. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  64. package/build/esm/object/aggregate.js +1 -1
  65. package/build/esm/object/aggregate.js.map +1 -1
  66. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -2
  67. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  68. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +27 -1
  69. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  70. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts +2 -0
  71. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts.map +1 -0
  72. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js +190 -0
  73. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -0
  74. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +1 -3
  75. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  76. package/build/esm/object/convertWireToOsdkObjects.test.js +25 -1
  77. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  78. package/build/esm/object/fetchSingle.js +1 -1
  79. package/build/esm/object/fetchSingle.js.map +1 -1
  80. package/build/esm/object/object.test.js +1 -1
  81. package/build/esm/object/object.test.js.map +1 -1
  82. package/build/esm/objectSet/ObjectSet.test.js +0 -1
  83. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  84. package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts +1 -6
  85. package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
  86. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +37 -156
  87. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  88. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +17 -16
  89. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  90. package/build/esm/objectSet/createObjectSet.js +3 -3
  91. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  92. package/build/esm/queries/applyQuery.js +3 -3
  93. package/build/esm/queries/applyQuery.js.map +1 -1
  94. package/build/esm/queries/queries.test.js +7 -1
  95. package/build/esm/queries/queries.test.js.map +1 -1
  96. package/build/esm/util/UserAgent.js +1 -1
  97. package/build/esm/util/UserAgent.js.map +1 -1
  98. package/package.json +9 -10
package/CHANGELOG.md CHANGED
@@ -1,25 +1,27 @@
1
1
  # @osdk/client
2
2
 
3
- ## 2.0.2-rc.0
3
+ ## 2.1.0-beta.0
4
4
 
5
- ### Patch Changes
6
-
7
- - @osdk/generator-converters@2.0.2-rc.0
8
- - @osdk/client.unstable@2.0.2-rc.0
9
- - @osdk/api@2.0.2-rc.0
5
+ ### Minor Changes
10
6
 
11
- ## 2.0.1
7
+ - 0dc40b0: Switch to OSDK.Instance
8
+ - d927a1d: Throws error in createClient when passed an invalid ontology RID
9
+ - d464009: improves interface api name mapping with api namespaces
10
+ - 8eb2378: Fixes where clauses when objects have an api namespace
11
+ - e548b9b: Updates subscribe to return object updates
12
+ - 5e78575: Fix queries that have response types with nested values, like arrays.
13
+ - 9af346e: Fixing proxy handlers.
14
+ - c682504: Locks dependency version of 3 internal libraries
12
15
 
13
16
  ### Patch Changes
14
17
 
15
- - Updated dependencies [a4343af]
16
- - @osdk/shared.client@1.0.1
17
- - @osdk/internal.foundry.core@0.2.1
18
- - @osdk/internal.foundry.ontologiesv2@0.2.1
19
- - @osdk/shared.client.impl@1.0.1
20
- - @osdk/generator-converters@2.0.1
21
- - @osdk/api@2.0.1
22
- - @osdk/client.unstable@2.0.1
18
+ - Updated dependencies [0dc40b0]
19
+ - Updated dependencies [03e1941]
20
+ - Updated dependencies [e548b9b]
21
+ - Updated dependencies [c682504]
22
+ - @osdk/api@2.1.0-beta.0
23
+ - @osdk/generator-converters@2.1.0-beta.0
24
+ - @osdk/client.unstable@2.1.0-beta.0
23
25
 
24
26
  ## 2.0.0
25
27
 
@@ -32,7 +32,7 @@ export interface Client extends SharedClient<MinimalClient> {
32
32
  */
33
33
  readonly [__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks]: <T extends ObjectOrInterfaceDefinition>(objs: Osdk<T>[], links: string[]) => AsyncGenerator<BulkLinkResult, void, undefined>;
34
34
  }
35
- declare const MaxOsdkVersion = "2.0.2";
35
+ declare const MaxOsdkVersion = "2.1.0";
36
36
  export type MaxOsdkVersion = typeof MaxOsdkVersion;
37
37
  declare const ErrorMessage: unique symbol;
38
38
  export {};
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
17
- const MaxOsdkVersion = "2.0.2";
17
+ const MaxOsdkVersion = "2.1.0";
18
18
  const ErrorMessage = Symbol("ErrorMessage");
19
19
  export {};
20
20
  //# sourceMappingURL=Client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","names":["MaxOsdkVersion","ErrorMessage","Symbol"],"sources":["Client.js"],"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// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.0.2\";\nconst ErrorMessage = Symbol(\"ErrorMessage\");\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,OAAO;AAC9B,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAC3C","ignoreList":[]}
1
+ {"version":3,"file":"Client.js","names":["MaxOsdkVersion","ErrorMessage","Symbol"],"sources":["Client.js"],"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// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.1.0\";\nconst ErrorMessage = Symbol(\"ErrorMessage\");\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,OAAO;AAC9B,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAC3C","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import type { OsdkObject } from "@osdk/api";
1
+ import type { OsdkBase } from "@osdk/api";
2
2
  import type { MinimalClient } from "../MinimalClientContext.js";
3
3
  export interface BulkLinkResult {
4
- object: OsdkObject<any>;
4
+ object: OsdkBase<any>;
5
5
  linkApiName: string;
6
6
  otherObjectApiName: string | undefined;
7
7
  otherObjectPk: unknown;
8
8
  }
9
- export declare function createBulkLinksAsyncIterFactory(ctx: MinimalClient): (objs: Array<OsdkObject<any>>, linkTypes: string[]) => AsyncGenerator<BulkLinkResult, void, unknown>;
9
+ export declare function createBulkLinksAsyncIterFactory(ctx: MinimalClient): (objs: Array<OsdkBase<any>>, linkTypes: string[]) => AsyncGenerator<BulkLinkResult, void, unknown>;
10
10
  //# sourceMappingURL=createBulkLinksAsyncIterFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createBulkLinksAsyncIterFactory.d.ts","sourceRoot":"","sources":["../../../src/__unstable/createBulkLinksAsyncIterFactory.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAS5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAUhE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,aAAa,UAExD,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,aACjB,MAAM,EAAE,KAClB,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CA8GjD"}
1
+ {"version":3,"file":"createBulkLinksAsyncIterFactory.d.ts","sourceRoot":"","sources":["../../../src/__unstable/createBulkLinksAsyncIterFactory.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAS1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAUhE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,aAAa,UAExD,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,aACf,MAAM,EAAE,KAClB,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CA8GjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../src/createClient.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyI1C,eAAO,MAAM,YAAY,gFA7FF,OAAO,CAAC,MAAM,CAAC;aAChB,MAAM;4DA+F3B,CAAC"}
1
+ {"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../src/createClient.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqJ1C,eAAO,MAAM,YAAY,gFAzGF,OAAO,CAAC,MAAM,CAAC;aAChB,MAAM;4DA2G3B,CAAC"}
@@ -43,6 +43,17 @@ class QueryInvoker {
43
43
  export function createClientInternal(objectSetFactory,
44
44
  // first so i can bind
45
45
  baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
46
+ if (typeof ontologyRid === "string") {
47
+ if (!ontologyRid.startsWith("ri.")) {
48
+ throw new Error("Invalid ontology RID");
49
+ }
50
+ } else {
51
+ ontologyRid.then(ontologyRid => {
52
+ if (!ontologyRid.startsWith("ri.")) {
53
+ throw new Error("Invalid ontology RID");
54
+ }
55
+ });
56
+ }
46
57
  const clientCtx = createMinimalClient({
47
58
  ontologyRid
48
59
  }, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet","symbolClientContext","createBulkLinksAsyncIterFactory","applyAction","createMinimalClient","fetchMetadataInternal","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","fetchMetadata","client","Object","defineProperties","o","type","Error","value","get","definition","rid","objectSets","objectType","apiName","reference","createClient"],"sources":["createClient.js"],"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 */\nimport { __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks, __EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet, } from \"@osdk/api/unstable\";\nimport { symbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nclass ActionInvoker {\n constructor(clientCtx, actionDef) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n applyAction;\n batchApplyAction;\n}\nclass QueryInvoker {\n constructor(clientCtx, queryDef) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n executeFunction;\n}\n/** @internal */\nexport function createClientInternal(objectSetFactory, // first so i can bind\nbaseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {\n const clientCtx = createMinimalClient({ ontologyRid }, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);\n function clientFn(o) {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx);\n }\n else if (o.type === \"action\") {\n return new ActionInvoker(clientCtx, o); // then as any for dealing with the conditional return value\n }\n else if (o.type === \"query\") {\n return new QueryInvoker(clientCtx, o);\n }\n else {\n throw new Error(\"not implemented\");\n }\n }\n const fetchMetadata = fetchMetadataInternal.bind(undefined, clientCtx);\n const client = Object.defineProperties(clientFn, {\n [symbolClientContext]: {\n value: clientCtx,\n },\n [__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks]: {\n get: () => createBulkLinksAsyncIterFactory(clientCtx),\n },\n [__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet]: {\n get: () => (definition, rid) => {\n return createObjectSet(definition, client[symbolClientContext], {\n type: \"intersect\",\n objectSets: [\n {\n type: \"base\",\n objectType: definition.apiName,\n },\n {\n type: \"reference\",\n reference: rid,\n },\n ],\n });\n },\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n });\n return client;\n}\nexport const createClient = createClientInternal.bind(undefined, createObjectSet);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,+CAA+C,EAAEC,uDAAuD,QAAS,oBAAoB;AAC9I,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,+BAA+B,QAAQ,iDAAiD;AACjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,UAAU,QAAQ,yBAAyB;AACpD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CAAC,MACI,IAAIA,CAAC,CAACC,IAAI,KAAK,OAAO,EAAE;MACzB,OAAO,IAAIhB,YAAY,CAACL,SAAS,EAAEoB,CAAC,CAAC;IACzC,CAAC,MACI;MACD,MAAM,IAAIE,KAAK,CAAC,iBAAiB,CAAC;IACtC;EACJ,CAAC,EAEgD;IAC7C,CAAC/B,mBAAmB,GAAG;MACnBgC,KAAK,EAAEvB;IACX,CAAC;IACD,CAACX,+CAA+C,GAAG;MAC/CmC,GAAG,EAAEA,CAAA,KAAMhC,+BAA+B,CAACQ,SAAS;IACxD,CAAC;IACD,CAACV,uDAAuD,GAAG;MACvDkC,GAAG,EAAEA,CAAA,KAAM,CAACC,UAAU,EAAEC,GAAG,KAAK;QAC5B,OAAO9B,eAAe,CAAC6B,UAAU,EAAER,MAAM,CAAC1B,mBAAmB,CAAC,EAAE;UAC5D8B,IAAI,EAAE,WAAW;UACjBM,UAAU,EAAE,CACR;YACIN,IAAI,EAAE,MAAM;YACZO,UAAU,EAAEH,UAAU,CAACI;UAC3B,CAAC,EACD;YACIR,IAAI,EAAE,WAAW;YACjBS,SAAS,EAAEJ;UACf,CAAC;QAET,CAAC,CAAC;MACN;IACJ,CAAC;IACDV,aAAa,EAAE;MACXO,KAAK,EAAEP;IACX;EACJ,CAAC,CAAC;EACF,OAAOC,MAAM;AACjB;AACA,OAAO,MAAMc,YAAY,GAAGvB,oBAAoB,CAACN,IAAI,CAACC,SAAS,EAAEP,eAAe,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet","symbolClientContext","createBulkLinksAsyncIterFactory","applyAction","createMinimalClient","fetchMetadataInternal","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","value","get","definition","rid","objectSets","objectType","apiName","reference","createClient"],"sources":["createClient.js"],"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 */\nimport { __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks, __EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet, } from \"@osdk/api/unstable\";\nimport { symbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nclass ActionInvoker {\n constructor(clientCtx, actionDef) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n applyAction;\n batchApplyAction;\n}\nclass QueryInvoker {\n constructor(clientCtx, queryDef) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n executeFunction;\n}\n/** @internal */\nexport function createClientInternal(objectSetFactory, // first so i can bind\nbaseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n }\n else {\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n const clientCtx = createMinimalClient({ ontologyRid }, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);\n function clientFn(o) {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx);\n }\n else if (o.type === \"action\") {\n return new ActionInvoker(clientCtx, o); // then as any for dealing with the conditional return value\n }\n else if (o.type === \"query\") {\n return new QueryInvoker(clientCtx, o);\n }\n else {\n throw new Error(\"not implemented\");\n }\n }\n const fetchMetadata = fetchMetadataInternal.bind(undefined, clientCtx);\n const client = Object.defineProperties(clientFn, {\n [symbolClientContext]: {\n value: clientCtx,\n },\n [__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks]: {\n get: () => createBulkLinksAsyncIterFactory(clientCtx),\n },\n [__EXPERIMENTAL__NOT_SUPPORTED_YET__preexistingObjectSet]: {\n get: () => (definition, rid) => {\n return createObjectSet(definition, client[symbolClientContext], {\n type: \"intersect\",\n objectSets: [\n {\n type: \"base\",\n objectType: definition.apiName,\n },\n {\n type: \"reference\",\n reference: rid,\n },\n ],\n });\n },\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n });\n return client;\n}\nexport const createClient = createClientInternal.bind(undefined, createObjectSet);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,+CAA+C,EAAEC,uDAAuD,QAAS,oBAAoB;AAC9I,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,+BAA+B,QAAQ,iDAAiD;AACjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,eAAe,QAAQ,gCA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AAO,MAAMa,YAAY,GAAGzB,oBAAoB,CAACN,IAAI,CAACC,SAAS,EAAEP,eAAe,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export declare function extractNamespace(fqApiName: string): [string | undefined, string];
2
2
  //# sourceMappingURL=modernToLegacyWhereClause.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modernToLegacyWhereClause.d.ts","sourceRoot":"","sources":["../../../../src/internal/conversions/modernToLegacyWhereClause.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"modernToLegacyWhereClause.d.ts","sourceRoot":"","sources":["../../../../src/internal/conversions/modernToLegacyWhereClause.ts"],"names":[],"mappings":"AA6BA,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,CAI9B"}
@@ -15,31 +15,36 @@
15
15
  */
16
16
  import { DistanceUnitMapping } from "@osdk/api";
17
17
  import invariant from "tiny-invariant";
18
+ export function extractNamespace(fqApiName) {
19
+ const last = fqApiName.lastIndexOf(".");
20
+ if (last === -1) return [undefined, fqApiName];
21
+ return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];
22
+ }
18
23
  /** @internal */
19
- export function modernToLegacyWhereClause(whereClause) {
24
+ export function modernToLegacyWhereClause(whereClause, objectOrInterface) {
20
25
  if ("$and" in whereClause) {
21
26
  return {
22
27
  type: "and",
23
- value: whereClause.$and.map(modernToLegacyWhereClause)
28
+ value: whereClause.$and.map(clause => modernToLegacyWhereClause(clause, objectOrInterface))
24
29
  };
25
30
  } else if ("$or" in whereClause) {
26
31
  return {
27
32
  type: "or",
28
- value: whereClause.$or.map(modernToLegacyWhereClause)
33
+ value: whereClause.$or.map(clause => modernToLegacyWhereClause(clause, objectOrInterface))
29
34
  };
30
35
  } else if ("$not" in whereClause) {
31
36
  return {
32
37
  type: "not",
33
- value: modernToLegacyWhereClause(whereClause.$not)
38
+ value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface)
34
39
  };
35
40
  }
36
41
  const parts = Object.entries(whereClause);
37
42
  if (parts.length === 1) {
38
- return handleWherePair(parts[0]);
43
+ return handleWherePair(parts[0], objectOrInterface);
39
44
  }
40
45
  return {
41
46
  type: "and",
42
- value: parts.map(handleWherePair)
47
+ value: parts.map(v => handleWherePair(v, objectOrInterface))
43
48
  };
44
49
  }
45
50
  function makeGeoFilterBbox(field, bbox, filterType) {
@@ -68,9 +73,16 @@ function makeGeoFilterPolygon(field, coordinates, filterType) {
68
73
  }
69
74
  };
70
75
  }
71
- function handleWherePair([field, filter]) {
76
+ function handleWherePair([field, filter], objectOrInterface) {
72
77
  !(filter != null) ? invariant(false, "Defined key values are only allowed when they are not undefined.") : void 0;
73
78
  if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
79
+ if (objectOrInterface.type === "interface") {
80
+ const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
81
+ const [fieldApiNamespace, fieldShortName] = extractNamespace(field);
82
+ if (fieldApiNamespace == null && objApiNamespace != null) {
83
+ field = `${objApiNamespace}.${fieldShortName}`;
84
+ }
85
+ }
74
86
  return {
75
87
  type: "eq",
76
88
  field,
@@ -1 +1 @@
1
- {"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","modernToLegacyWhereClause","whereClause","type","value","$and","map","$or","$not","parts","Object","entries","length","handleWherePair","makeGeoFilterBbox","field","bbox","filterType","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","filter","keysOfFilter","keys","hasDollarSign","some","key","startsWith","Error","JSON","stringify","firstKey","withinBody","Array","isArray","$bbox","$distance","$of","center","distance","unit","$polygon","intersectsBody","substring"],"sources":["modernToLegacyWhereClause.js"],"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 */\nimport { DistanceUnitMapping } from \"@osdk/api\";\nimport invariant from \"tiny-invariant\";\n/** @internal */\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause),\n };\n }\n else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause),\n };\n }\n else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not),\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0]);\n }\n return {\n type: \"and\",\n value: parts.map(handleWherePair),\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\"\n ? \"withinBoundingBox\"\n : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]],\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]],\n },\n },\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates,\n },\n };\n}\nfunction handleWherePair([field, filter]) {\n invariant(filter != null, \"Defined key values are only allowed when they are not undefined.\");\n if (typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\") {\n return {\n type: \"eq\",\n field,\n value: filter,\n };\n }\n const keysOfFilter = Object.keys(filter);\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(!hasDollarSign\n || keysOfFilter.length === 1, \"WhereClause Filter with multiple clauses isn't allowed\");\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(`Unsupported filter. Did you forget to use a $-prefixed filter? (${JSON.stringify(filter)})`);\n }\n const firstKey = keysOfFilter[0];\n invariant(filter[firstKey] != null);\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey],\n },\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n }\n else if (\"$bbox\" in withinBody && withinBody.$bbox != null) {\n return makeGeoFilterBbox(field, withinBody.$bbox, firstKey);\n }\n else if ((\"$distance\" in withinBody && \"$of\" in withinBody)\n && withinBody.$distance != null\n && withinBody.$of != null) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.$of)\n ? {\n type: \"Point\",\n coordinates: withinBody.$of,\n }\n : withinBody.$of,\n distance: {\n value: withinBody.$distance[0],\n unit: DistanceUnitMapping[withinBody.$distance[1]],\n },\n },\n };\n }\n else {\n const coordinates = (\"$polygon\" in withinBody)\n ? withinBody.$polygon\n : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n }\n else if (\"$bbox\" in intersectsBody && intersectsBody.$bbox != null) {\n return makeGeoFilterBbox(field, intersectsBody.$bbox, firstKey);\n }\n else {\n const coordinates = (\"$polygon\" in intersectsBody)\n ? intersectsBody.$polygon\n : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,m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a,EAAE;IAC5B,MAAMW,cAAc,GAAGrB,MAAM,CAACU,QAAQ,CAAC;IACvC,IAAIE,KAAK,CAACC,OAAO,CAACQ,cAAc,CAAC,EAAE;MAC/B,OAAO7B,iBAAiB,CAACC,KAAK,EAAE4B,cAAc,EAAEX,QAAQ,CAAC;IAC7D,CAAC,MACI,IAAI,OAAO,IAAIW,cAAc,IAAIA,cAAc,CAACP,KAAK,IAAI,IAAI,EAAE;MAChE,OAAOtB,iBAAiB,CAACC,KAAK,EAAE4B,cAAc,CAACP,KAAK,EAAEJ,QAAQ,CAAC;IACnE,CAAC,MACI;MACD,MAAMb,WAAW,GAAI,UAAU,IAAIwB,cAAc,GAC3CA,cAAc,CAACD,QAAQ,GACvBC,cAAc,CAACxB,WAAW;MAChC,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,mBAAmB,CAAC;IACxE;EACJ;EACA,OAAO;IACHhB,IAAI,EAAE6B,QAAQ,CAACY,SAAS,CAAC,CAAC,CAAC;IAC3B7B,KAAK;IACLX,KAAK,EAAEkB,MAAM,CAACU,QAAQ;EAC1B,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","extractNamespace","fqApiName","last","lastIndexOf","undefined","slice","modernToLegacyWhereClause","whereClause","objectOrInterface","type","value","$and","map","clause","$or","$not","parts","Object","entries","length","handleWherePair","v","makeGeoFilterBbox","field","bbox","filterType","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","filter","objApiNamespace","apiName","fieldApiNamespace","fieldShortName","keysOfFilter","keys","hasDollarSign","some","key","startsWith","Error","JSON","stringify","firstKey","withinBody","Array","isArray","$bbox","$distance","$of","center","distance","unit","$polygon","intersectsBody","substring"],"sources":["modernToLegacyWhereClause.js"],"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 */\nimport { DistanceUnitMapping } from \"@osdk/api\";\nimport invariant from \"tiny-invariant\";\nexport function extractNamespace(fqApiName) {\n const last = fqApiName.lastIndexOf(\".\");\n if (last === -1)\n return [undefined, fqApiName];\n return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];\n}\n/** @internal */\nexport function modernToLegacyWhereClause(whereClause, objectOrInterface) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface)),\n };\n }\n else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface)),\n };\n }\n else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface),\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0], objectOrInterface);\n }\n return {\n type: \"and\",\n value: parts.map(v => handleWherePair(v, objectOrInterface)),\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\"\n ? \"withinBoundingBox\"\n : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]],\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]],\n },\n },\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates,\n },\n };\n}\nfunction handleWherePair([field, filter], objectOrInterface) {\n invariant(filter != null, \"Defined key values are only allowed when they are not undefined.\");\n if (typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\") {\n if (objectOrInterface.type === \"interface\") {\n const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);\n const [fieldApiNamespace, fieldShortName] = extractNamespace(field);\n if (fieldApiNamespace == null && objApiNamespace != null) {\n field = `${objApiNamespace}.${fieldShortName}`;\n }\n }\n return {\n type: \"eq\",\n field,\n value: filter,\n };\n }\n const keysOfFilter = Object.keys(filter);\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(!hasDollarSign\n || keysOfFilter.length === 1, \"WhereClause Filter with multiple clauses isn't allowed\");\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(`Unsupported filter. Did you forget to use a $-prefixed filter? (${JSON.stringify(filter)})`);\n }\n const firstKey = keysOfFilter[0];\n invariant(filter[firstKey] != null);\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey],\n },\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n }\n else if (\"$bbox\" in withinBody && withinBody.$bbox != null) {\n return makeGeoFilterBbox(field, withinBody.$bbox, firstKey);\n }\n else if ((\"$distance\" in withinBody && \"$of\" in withinBody)\n && withinBody.$distance != null\n && withinBody.$of != null) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.$of)\n ? {\n type: \"Point\",\n coordinates: withinBody.$of,\n }\n : withinBody.$of,\n distance: {\n value: withinBody.$distance[0],\n unit: DistanceUnitMapping[withinBody.$distance[1]],\n },\n },\n };\n }\n else {\n const coordinates = (\"$polygon\" in withinBody)\n ? withinBody.$polygon\n : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n }\n else if (\"$bbox\" in intersectsBody && intersectsBody.$bbox != null) {\n return makeGeoFilterBbox(field, intersectsBody.$bbox, firstKey);\n }\n else {\n const coordinates = (\"$polygon\" in intersectsBody)\n ? intersectsBody.$polygon\n : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAmB,QAAQ,WAAW;AAC/C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,gBAAgBA,CAACC,SAAS,EAAE;EACxC,MAAMC,IAAI,GAAGD,SAAS,CAACE,WAAW,CAAC,GAAG,CAAC;EACvC,IAAID,IAAI,KAAK,CAAC,CAAC,EACX,OAAO,CAACE,SAAS,EAAEH,SAAS,CAAC;EACjC,OAAO,CAACA,SAAS,CAACI,KAAK,CAAC,CAAC,EAAEH,IAAI,CAAC,EAAED,SAAS,CAACI,KAAK,CAACH,IAAI,GAAG,CAAC,CAAC,CAAC;AAChE;AACA;AACA,OAAO,SAASI,yBAAyBA,CAACC,WAAW,EAAEC,iBAAiB,EAAE;EACtE,IAAI,MAAM,IAAID,WAAW,EAAE;IACvB,OAAO;MACHE,IAAI,EAAE,KAAK;MACXC,KAAK,EAAEH,WAAW,CAACI,IAAI,CAACC,GAAG,CAAEC,MAAM,IAAKP,yBAAyB,CAACO,MAAM,EAAEL,iBAAiB,CAAC;IAChG,CAAC;EACL,CAAC,MACI,IAAI,KAAK,IAAID,WAAW,EAAE;IAC3B,OAAO;MACHE,IAAI,EAAE,IAAI;MACVC,KAAK,EAAEH,WAAW,CAACO,GAAG,CAACF,GAAG,CAAEC,MAAM,IAAKP,yBAAyB,CAAC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AoB,CAACN,KAAK,EAAEI,WAAW,EAAE,eAAe,CAAC;IACpE;EACJ;EACA,IAAIiB,QAAQ,KAAK,aAAa,EAAE;IAC5B,MAAMW,cAAc,GAAGzB,MAAM,CAACc,QAAQ,CAAC;IACvC,IAAIE,KAAK,CAACC,OAAO,CAACQ,cAAc,CAAC,EAAE;MAC/B,OAAOjC,iBAAiB,CAACC,KAAK,EAAEgC,cAAc,EAAEX,QAAQ,CAAC;IAC7D,CAAC,MACI,IAAI,OAAO,IAAIW,cAAc,IAAIA,cAAc,CAACP,KAAK,IAAI,IAAI,EAAE;MAChE,OAAO1B,iBAAiB,CAACC,KAAK,EAAEgC,cAAc,CAACP,KAAK,EAAEJ,QAAQ,CAAC;IACnE,CAAC,MACI;MACD,MAAMjB,WAAW,GAAI,UAAU,IAAI4B,cAAc,GAC3CA,cAAc,CAACD,QAAQ,GACvBC,cAAc,CAAC5B,WAAW;MAChC,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,mBAAmB,CAAC;IACxE;EACJ;EACA,OAAO;IACHlB,IAAI,EAAEmC,QAAQ,CAACY,SAAS,CAAC,CAAC,CAAC;IAC3BjC,KAAK;IACLb,KAAK,EAAEoB,MAAM,CAACc,QAAQ;EAC1B,CAAC;AACL","ignoreList":[]}
@@ -13,10 +13,113 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { objectTypeWithAllPropertyTypes } from "@osdk/client.test.ontology";
16
17
  import { expectType } from "ts-expect";
17
18
  import { describe, expect, it } from "vitest";
18
19
  import { modernToLegacyWhereClause } from "./modernToLegacyWhereClause.js";
19
20
  describe(modernToLegacyWhereClause, () => {
21
+ describe("api namespaces", () => {
22
+ describe("interfaces", () => {
23
+ it("properly converts shortname to fqApiName", () => {
24
+ const r = modernToLegacyWhereClause({
25
+ prop: 5
26
+ }, {
27
+ type: "interface",
28
+ apiName: "a.Foo"
29
+ });
30
+ expect(r).toMatchInlineSnapshot(`
31
+ {
32
+ "field": "a.prop",
33
+ "type": "eq",
34
+ "value": 5,
35
+ }
36
+ `);
37
+ });
38
+ it("properly does not convert when interface has no apiNamespace", () => {
39
+ const r = modernToLegacyWhereClause({
40
+ "b.prop": 5,
41
+ foo: 6
42
+ }, {
43
+ type: "interface",
44
+ apiName: "Foo"
45
+ });
46
+ expect(r).toMatchInlineSnapshot(`
47
+ {
48
+ "type": "and",
49
+ "value": [
50
+ {
51
+ "field": "b.prop",
52
+ "type": "eq",
53
+ "value": 5,
54
+ },
55
+ {
56
+ "field": "foo",
57
+ "type": "eq",
58
+ "value": 6,
59
+ },
60
+ ],
61
+ }
62
+ `);
63
+ });
64
+ it("gracefully handles redundant apiNamespace in property", () => {
65
+ const r = modernToLegacyWhereClause({
66
+ "b.prop": 5,
67
+ "a.foo": 6
68
+ }, {
69
+ type: "interface",
70
+ apiName: "a.Foo"
71
+ });
72
+ expect(r).toMatchInlineSnapshot(`
73
+ {
74
+ "type": "and",
75
+ "value": [
76
+ {
77
+ "field": "b.prop",
78
+ "type": "eq",
79
+ "value": 5,
80
+ },
81
+ {
82
+ "field": "a.foo",
83
+ "type": "eq",
84
+ "value": 6,
85
+ },
86
+ ],
87
+ }
88
+ `);
89
+ });
90
+ it("properly does not convert different apiNamespaces", () => {
91
+ expect(modernToLegacyWhereClause({
92
+ "b.prop": 5
93
+ }, {
94
+ type: "interface",
95
+ apiName: "a.Foo"
96
+ })).toMatchInlineSnapshot(`
97
+ {
98
+ "field": "b.prop",
99
+ "type": "eq",
100
+ "value": 5,
101
+ }
102
+ `);
103
+ });
104
+ });
105
+ describe("objects", () => {
106
+ it("does not convert object short property names to fq", () => {
107
+ const r = modernToLegacyWhereClause({
108
+ prop: 5
109
+ }, {
110
+ type: "object",
111
+ apiName: "a.Foo"
112
+ });
113
+ expect(r).toMatchInlineSnapshot(`
114
+ {
115
+ "field": "prop",
116
+ "type": "eq",
117
+ "value": 5,
118
+ }
119
+ `);
120
+ });
121
+ });
122
+ });
20
123
  describe("single checks", () => {
21
124
  describe("$within", () => {
22
125
  it("properly generates bbox shortcut", async () => {
@@ -24,7 +127,7 @@ describe(modernToLegacyWhereClause, () => {
24
127
  geoPoint: {
25
128
  $within: [-5, 5, -10, 10]
26
129
  }
27
- })).toMatchInlineSnapshot(`
130
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
28
131
  {
29
132
  "field": "geoPoint",
30
133
  "type": "withinBoundingBox",
@@ -54,7 +157,7 @@ describe(modernToLegacyWhereClause, () => {
54
157
  $bbox: [-5, 5, -10, 10]
55
158
  }
56
159
  }
57
- })).toMatchInlineSnapshot(`
160
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
58
161
  {
59
162
  "field": "geoPoint",
60
163
  "type": "withinBoundingBox",
@@ -85,7 +188,7 @@ describe(modernToLegacyWhereClause, () => {
85
188
  $of: [-5, 5]
86
189
  }
87
190
  }
88
- })).toMatchInlineSnapshot(`
191
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
89
192
  {
90
193
  "field": "geoPoint",
91
194
  "type": "withinDistanceOf",
@@ -119,7 +222,7 @@ describe(modernToLegacyWhereClause, () => {
119
222
  }
120
223
  }
121
224
  }
122
- })).toMatchInlineSnapshot(`
225
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
123
226
  {
124
227
  "field": "geoPoint",
125
228
  "type": "withinDistanceOf",
@@ -146,7 +249,7 @@ describe(modernToLegacyWhereClause, () => {
146
249
  $polygon: [[[0, 1], [3, 2], [0, 1]]]
147
250
  }
148
251
  }
149
- })).toMatchInlineSnapshot(`
252
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
150
253
  {
151
254
  "field": "geoPoint",
152
255
  "type": "withinPolygon",
@@ -180,7 +283,7 @@ describe(modernToLegacyWhereClause, () => {
180
283
  coordinates: [[[0, 1], [3, 2], [0, 1]]]
181
284
  }
182
285
  }
183
- })).toMatchInlineSnapshot(`
286
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
184
287
  {
185
288
  "field": "geoPoint",
186
289
  "type": "withinPolygon",
@@ -269,7 +372,7 @@ describe(modernToLegacyWhereClause, () => {
269
372
  geoShape: {
270
373
  $intersects: [-5, 5, -10, 10]
271
374
  }
272
- })).toMatchInlineSnapshot(`
375
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
273
376
  {
274
377
  "field": "geoShape",
275
378
  "type": "intersectsBoundingBox",
@@ -299,7 +402,7 @@ describe(modernToLegacyWhereClause, () => {
299
402
  $bbox: [-5, 5, -10, 10]
300
403
  }
301
404
  }
302
- })).toMatchInlineSnapshot(`
405
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
303
406
  {
304
407
  "field": "geoShape",
305
408
  "type": "intersectsBoundingBox",
@@ -329,7 +432,7 @@ describe(modernToLegacyWhereClause, () => {
329
432
  $polygon: [[[0, 1], [3, 2], [0, 1]]]
330
433
  }
331
434
  }
332
- })).toMatchInlineSnapshot(`
435
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
333
436
  {
334
437
  "field": "geoShape",
335
438
  "type": "intersectsPolygon",
@@ -363,7 +466,7 @@ describe(modernToLegacyWhereClause, () => {
363
466
  coordinates: [[[0, 1], [3, 2], [0, 1]]]
364
467
  }
365
468
  }
366
- })).toMatchInlineSnapshot(`
469
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
367
470
  {
368
471
  "field": "geoShape",
369
472
  "type": "intersectsPolygon",
@@ -395,7 +498,7 @@ describe(modernToLegacyWhereClause, () => {
395
498
  integer: {
396
499
  $ne: 5
397
500
  }
398
- })).toMatchInlineSnapshot(`
501
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
399
502
  {
400
503
  "type": "not",
401
504
  "value": {
@@ -412,7 +515,7 @@ describe(modernToLegacyWhereClause, () => {
412
515
  expect(modernToLegacyWhereClause({
413
516
  decimal: 5,
414
517
  integer: 10
415
- })).toMatchInlineSnapshot(`
518
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
416
519
  {
417
520
  "type": "and",
418
521
  "value": [
@@ -437,7 +540,7 @@ describe(modernToLegacyWhereClause, () => {
437
540
  }, {
438
541
  integer: 10
439
542
  }]
440
- })).toMatchInlineSnapshot(`
543
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
441
544
  {
442
545
  "type": "and",
443
546
  "value": [
@@ -462,7 +565,7 @@ describe(modernToLegacyWhereClause, () => {
462
565
  }, {
463
566
  integer: 10
464
567
  }]
465
- })).toMatchInlineSnapshot(`
568
+ }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`
466
569
  {
467
570
  "type": "or",
468
571
  "value": [