@osdk/client 2.0.2-rc.0 → 2.0.2

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 (74) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
  3. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
  4. package/build/browser/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
  5. package/build/browser/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
  6. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +19 -7
  7. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  8. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +117 -14
  9. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  10. package/build/browser/object/aggregate.js +1 -1
  11. package/build/browser/object/aggregate.js.map +1 -1
  12. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -2
  13. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  14. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +27 -1
  15. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  16. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts +2 -0
  17. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts.map +1 -0
  18. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js +190 -0
  19. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -0
  20. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +1 -3
  21. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  22. package/build/browser/object/convertWireToOsdkObjects.test.js +25 -1
  23. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  24. package/build/browser/object/fetchSingle.js +1 -1
  25. package/build/browser/object/fetchSingle.js.map +1 -1
  26. package/build/browser/object/object.test.js +1 -1
  27. package/build/browser/object/object.test.js.map +1 -1
  28. package/build/browser/objectSet/ObjectSet.test.js +0 -1
  29. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  30. package/build/browser/objectSet/createObjectSet.js +1 -1
  31. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  32. package/build/browser/queries/applyQuery.js +3 -3
  33. package/build/browser/queries/applyQuery.js.map +1 -1
  34. package/build/browser/queries/queries.test.js +7 -1
  35. package/build/browser/queries/queries.test.js.map +1 -1
  36. package/build/browser/util/UserAgent.js +1 -1
  37. package/build/browser/util/UserAgent.js.map +1 -1
  38. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
  39. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
  40. package/build/esm/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
  41. package/build/esm/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
  42. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +19 -7
  43. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  44. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +117 -14
  45. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  46. package/build/esm/object/aggregate.js +1 -1
  47. package/build/esm/object/aggregate.js.map +1 -1
  48. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -2
  49. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  50. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +27 -1
  51. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  52. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts +2 -0
  53. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts.map +1 -0
  54. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js +190 -0
  55. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -0
  56. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +1 -3
  57. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  58. package/build/esm/object/convertWireToOsdkObjects.test.js +25 -1
  59. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  60. package/build/esm/object/fetchSingle.js +1 -1
  61. package/build/esm/object/fetchSingle.js.map +1 -1
  62. package/build/esm/object/object.test.js +1 -1
  63. package/build/esm/object/object.test.js.map +1 -1
  64. package/build/esm/objectSet/ObjectSet.test.js +0 -1
  65. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  66. package/build/esm/objectSet/createObjectSet.js +1 -1
  67. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  68. package/build/esm/queries/applyQuery.js +3 -3
  69. package/build/esm/queries/applyQuery.js.map +1 -1
  70. package/build/esm/queries/queries.test.js +7 -1
  71. package/build/esm/queries/queries.test.js.map +1 -1
  72. package/build/esm/util/UserAgent.js +1 -1
  73. package/build/esm/util/UserAgent.js.map +1 -1
  74. package/package.json +9 -9
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { extractNamespace } from "../../internal/conversions/modernToLegacyWhereClause.js";
16
17
  import { createSimpleCache } from "../SimpleCache.js";
17
18
  import { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
18
19
  const handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);
@@ -45,6 +46,13 @@ function createInterfaceProxyHandler(newDef) {
45
46
  value: target[InterfaceDefRef].apiName
46
47
  };
47
48
  }
49
+ const [objApiNamespace] = extractNamespace(newDef.apiName);
50
+ if (objApiNamespace != null) {
51
+ const [apiNamespace, apiName] = extractNamespace(p);
52
+ if (apiNamespace == null) {
53
+ p = `${objApiNamespace}.${apiName}`;
54
+ }
55
+ }
48
56
  if (newDef.properties[p] != null) {
49
57
  return {
50
58
  enumerable: true,
@@ -55,7 +63,18 @@ function createInterfaceProxyHandler(newDef) {
55
63
  },
56
64
  ownKeys(target) {
57
65
  const underlying = target[UnderlyingOsdkObject];
58
- return ["$apiName", "$objectType", "$primaryKey", ...(underlying["$rid"] ? ["$rid"] : []), "$title", ...Object.keys(newDef.properties)];
66
+ const [objApiNamespace] = extractNamespace(newDef.apiName);
67
+ let propNames = Object.keys(newDef.properties);
68
+ if (objApiNamespace != null) {
69
+ propNames = propNames.map(p => {
70
+ const [apiNamespace, apiName] = extractNamespace(p);
71
+ if (apiNamespace === objApiNamespace) {
72
+ p = apiName;
73
+ }
74
+ return p;
75
+ });
76
+ }
77
+ return ["$apiName", "$objectType", "$primaryKey", ...(underlying["$rid"] ? ["$rid"] : []), "$title", ...propNames];
59
78
  },
60
79
  get(target, p) {
61
80
  const underlying = target[UnderlyingOsdkObject];
@@ -72,6 +91,13 @@ function createInterfaceProxyHandler(newDef) {
72
91
  case "$rid":
73
92
  return underlying[p];
74
93
  }
94
+ const [objApiNamespace] = extractNamespace(newDef.apiName);
95
+ if (objApiNamespace != null) {
96
+ const [apiNamespace, apiName] = extractNamespace(p);
97
+ if (apiNamespace == null) {
98
+ p = `${objApiNamespace}.${apiName}`;
99
+ }
100
+ }
75
101
  if (newDef.properties[p] != null) {
76
102
  const objDef = target[UnderlyingOsdkObject][ObjectDefRef];
77
103
  return underlying[objDef.interfaceMap[newDef.apiName][p]];
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkInterface.js","names":["createSimpleCache","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","handlerCache","WeakMap","createInterfaceProxyHandler","createOsdkInterface","underlying","interfaceDef","handler","get","proxy","Proxy","newDef","getOwnPropertyDescriptor","target","p","objDef","Reflect","undefined","enumerable","configurable","value","apiName","properties","interfaceMap","ownKeys","Object","keys"],"sources":["createOsdkInterface.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 { createSimpleCache } from \"../SimpleCache.js\";\nimport { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);\n/** @internal */\nexport function createOsdkInterface(underlying, interfaceDef) {\n const interfaceHolder = {\n [UnderlyingOsdkObject]: underlying,\n [InterfaceDefRef]: interfaceDef,\n };\n const handler = handlerCache.get(interfaceDef);\n const proxy = new Proxy(interfaceHolder, // the wrapper doesn't contain everything obviously. we proxy\n handler);\n return proxy;\n}\nfunction createInterfaceProxyHandler(newDef) {\n return {\n getOwnPropertyDescriptor(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n const objDef = underlying[ObjectDefRef];\n switch (p) {\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p] != null\n ? Reflect.getOwnPropertyDescriptor(underlying, p)\n : undefined;\n case \"$apiName\":\n return {\n enumerable: true,\n configurable: true,\n value: target[InterfaceDefRef].apiName,\n };\n }\n if (newDef.properties[p] != null) {\n return {\n enumerable: true,\n configurable: true,\n value: underlying[objDef.interfaceMap[newDef.apiName][p]],\n };\n }\n },\n ownKeys(target) {\n const underlying = target[UnderlyingOsdkObject];\n return [\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n ...(underlying[\"$rid\"] ? [\"$rid\"] : []),\n \"$title\",\n ...Object.keys(newDef.properties),\n ];\n },\n get(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n switch (p) {\n case InterfaceDefRef:\n return newDef;\n case \"$apiName\":\n return newDef.apiName;\n case \"$as\":\n case UnderlyingOsdkObject:\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p];\n }\n if (newDef.properties[p] != null) {\n const objDef = target[UnderlyingOsdkObject][ObjectDefRef];\n return underlying[objDef.interfaceMap[newDef.apiName][p]];\n }\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,EAAEC,YAAY,EAAEC,oBAAoB,QAAS,sBAAsB;AAC3F,MAAMC,YAAY,GAAGJ,iBAAiB,CAAC,IAAIK,OAAO,CAAC,CAAC,EAAEC,2BAA2B,CAAC;AAClF;AACA,OAAO,SAASC,mBAAmBA,CAACC,UAAU,EAAEC,YAAY,EAAE;EAK1D,MAAMC,OAAO,GAAGN,YAAY,CAACO,GAAG,CAACF,YAAY,CAAC;EAC9C,MAAMG,KAAK,GAAG,IAAIC,KAAK,CALC;IACpB,CAACV,oBAAoB,GAAGK,UAAU;IAClC,CAACP,eAAe,GAAGQ;EACvB,CAAC;EAEwC;EACzCC,OAAO,CAAC;EACR,OAAOE,KAAK;AAChB;AACA,SAASN,2BAA2BA,CAACQ,MAAM,EAAE;EACzC,OAAO;IACHC,wBAAwBA,CAACC,MAAM,EAAEC,CAAC,EAAE;MAChC,MAAMT,UAAU,GAAGQ,MAAM,CAACb,oBAAoB,CAAC;MAC/C,MAAMe,MAAM,GAAGV,UAAU,CAACN,YAAY,CAAC;MACvC,QAAQe,CAAC;QACL,KAAK,aAAa;QAClB,KAAK,QAAQ;QACb,KAAK,aAAa;QAClB,KAAK,MAAM;UACP,OAAOT,UAAU,CAACS,CAAC,CAAC,IAAI,IAAI,GACtBE,OAAO,CAACJ,wBAAwB,CAACP,UAAU,EAAES,CAAC,CAA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OM,UAAU,CAACU,MAAM,CAACQ,YAAY,CAACZ,MAAM,CAACU,OAAO,CAAC,CAACP,CAAC,CAAC,CAAC;MAC7D;IACJ;EACJ,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","createSimpleCache","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","handlerCache","WeakMap","createInterfaceProxyHandler","createOsdkInterface","underlying","interfaceDef","handler","get","proxy","Proxy","newDef","getOwnPropertyDescriptor","target","p","objDef","Reflect","undefined","enumerable","configurable","value","apiName","objApiNamespace","apiNamespace","properties","interfaceMap","ownKeys","propNames","Object","keys","map"],"sources":["createOsdkInterface.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 { extractNamespace } from \"../../internal/conversions/modernToLegacyWhereClause.js\";\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);\n/** @internal */\nexport function createOsdkInterface(underlying, interfaceDef) {\n const interfaceHolder = {\n [UnderlyingOsdkObject]: underlying,\n [InterfaceDefRef]: interfaceDef,\n };\n const handler = handlerCache.get(interfaceDef);\n const proxy = new Proxy(interfaceHolder, // the wrapper doesn't contain everything obviously. we proxy\n handler);\n return proxy;\n}\nfunction createInterfaceProxyHandler(newDef) {\n return {\n getOwnPropertyDescriptor(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n const objDef = underlying[ObjectDefRef];\n switch (p) {\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p] != null\n ? Reflect.getOwnPropertyDescriptor(underlying, p)\n : undefined;\n case \"$apiName\":\n return {\n enumerable: true,\n configurable: true,\n value: target[InterfaceDefRef].apiName,\n };\n }\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n if (objApiNamespace != null) {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace == null) {\n p = `${objApiNamespace}.${apiName}`;\n }\n }\n if (newDef.properties[p] != null) {\n return {\n enumerable: true,\n configurable: true,\n value: underlying[objDef.interfaceMap[newDef.apiName][p]],\n };\n }\n },\n ownKeys(target) {\n const underlying = target[UnderlyingOsdkObject];\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n let propNames = Object.keys(newDef.properties);\n if (objApiNamespace != null) {\n propNames = propNames.map(p => {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace === objApiNamespace) {\n p = apiName;\n }\n return p;\n });\n }\n return [\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n ...(underlying[\"$rid\"] ? [\"$rid\"] : []),\n \"$title\",\n ...propNames,\n ];\n },\n get(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n switch (p) {\n case InterfaceDefRef:\n return newDef;\n case \"$apiName\":\n return newDef.apiName;\n case \"$as\":\n case UnderlyingOsdkObject:\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p];\n }\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n if (objApiNamespace != null) {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace == null) {\n p = `${objApiNamespace}.${apiName}`;\n }\n }\n if (newDef.properties[p] != null) {\n const objDef = target[UnderlyingOsdkObject][ObjectDefRef];\n return underlying[objDef.interfaceMap[newDef.apiName][p]];\n }\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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C/C,QAAQc,CAAC;QACL,KAAKhB,eAAe;UAChB,OAAOa,MAAM;QACjB,KAAK,UAAU;UACX,OAAOA,MAAM,CAACU,OAAO;QACzB,KAAK,KAAK;QACV,KAAKrB,oBAAoB;QACzB,KAAK,aAAa;QAClB,KAAK,QAAQ;QACb,KAAK,aAAa;QAClB,KAAK,MAAM;UACP,OAAOK,UAAU,CAACS,CAAC,CAAC;MAC5B;MACA,MAAM,CAACQ,eAAe,CAAC,GAAG1B,gBAAgB,CAACe,MAAM,CAACU,OAAO,CAAC;MAC1D,IAAIC,eAAe,IAAI,IAAI,EAAE;QACzB,MAAM,CAACC,YAAY,EAAEF,OAAO,CAAC,GAAGzB,gBAAgB,CAACkB,CAAC,CAAC;QACnD,IAAIS,YAAY,IAAI,IAAI,EAAE;UACtBT,CAAC,GAAG,GAAGQ,eAAe,IAAID,OAAO,EAAE;QACvC;MACJ;MACA,IAAIV,MAAM,CAACa,UAAU,CAACV,CAAC,CAAC,IAAI,IAAI,EAAE;QAC9B,MAAMC,MAAM,GAAGF,MAAM,CAACb,oBAAoB,CAAC,CAACD,YAAY,CAAC;QACzD,OAAOM,UAAU,CAACU,MAAM,CAACU,YAAY,CAACd,MAAM,CAACU,OAAO,CAAC,CAACP,CAAC,CAAC,CAAC;MAC7D;IACJ;EACJ,CAAC;AACL","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=createOsdkInterface.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOsdkInterface.test.d.ts","sourceRoot":"","sources":["../../../../src/object/convertWireToOsdkObjects/createOsdkInterface.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,190 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { describe, expect, it } from "vitest";
17
+ import { InterfaceDefinitions } from "../../ontology/OntologyProvider.js";
18
+ import { createOsdkInterface } from "./createOsdkInterface.js";
19
+ import { ObjectDefRef } from "./InternalSymbols.js";
20
+ describe(createOsdkInterface, () => {
21
+ it("works in the normal case", () => {
22
+ // underlying: Osdk<Q> & ObjectHolder<Q>,
23
+ // interfaceDef: InterfaceMetadata,
24
+ const iface = createOsdkInterface({
25
+ "foo": "hi mom",
26
+ [ObjectDefRef]: {
27
+ [InterfaceDefinitions]: {},
28
+ apiName: "Obj",
29
+ displayName: "",
30
+ interfaceMap: {
31
+ "IFoo": {
32
+ "asdf": "foo"
33
+ }
34
+ },
35
+ inverseInterfaceMap: {},
36
+ links: {},
37
+ pluralDisplayName: "",
38
+ primaryKeyApiName: "",
39
+ primaryKeyType: "string",
40
+ properties: {
41
+ "foo": {
42
+ type: "string"
43
+ }
44
+ },
45
+ type: "object",
46
+ titleProperty: "foo",
47
+ rid: "",
48
+ status: "ACTIVE"
49
+ }
50
+ }, {
51
+ "apiName": "IFoo",
52
+ displayName: "",
53
+ links: {},
54
+ properties: {
55
+ "asdf": {
56
+ type: "string"
57
+ }
58
+ },
59
+ rid: "",
60
+ type: "interface",
61
+ implements: []
62
+ });
63
+ expect(Object.keys(iface)).toMatchInlineSnapshot(`
64
+ [
65
+ "$apiName",
66
+ "asdf",
67
+ ]
68
+ `);
69
+ expect(iface.asdf).toBe("hi mom");
70
+ expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`
71
+ "{
72
+ "$apiName": "IFoo",
73
+ "asdf": "hi mom"
74
+ }"
75
+ `);
76
+ });
77
+ it("properly maps apiNamespace", () => {
78
+ // underlying: Osdk<Q> & ObjectHolder<Q>,
79
+ // interfaceDef: InterfaceMetadata,
80
+ const iface = createOsdkInterface({
81
+ "foo": "hi mom",
82
+ [ObjectDefRef]: {
83
+ [InterfaceDefinitions]: {},
84
+ apiName: "Obj",
85
+ displayName: "",
86
+ interfaceMap: {
87
+ "a.IFoo": {
88
+ "a.asdf": "foo"
89
+ }
90
+ },
91
+ inverseInterfaceMap: {},
92
+ links: {},
93
+ pluralDisplayName: "",
94
+ primaryKeyApiName: "",
95
+ primaryKeyType: "string",
96
+ properties: {
97
+ "foo": {
98
+ type: "string"
99
+ }
100
+ },
101
+ type: "object",
102
+ titleProperty: "foo",
103
+ rid: "",
104
+ status: "ACTIVE"
105
+ }
106
+ }, {
107
+ "apiName": "a.IFoo",
108
+ displayName: "",
109
+ links: {},
110
+ properties: {
111
+ "a.asdf": {
112
+ type: "string"
113
+ }
114
+ },
115
+ rid: "",
116
+ type: "interface",
117
+ implements: []
118
+ });
119
+ expect(Object.keys(iface)).toMatchInlineSnapshot(`
120
+ [
121
+ "$apiName",
122
+ "asdf",
123
+ ]
124
+ `);
125
+ expect(iface.asdf).toBe("hi mom");
126
+ expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`
127
+ "{
128
+ "$apiName": "a.IFoo",
129
+ "asdf": "hi mom"
130
+ }"
131
+ `);
132
+ });
133
+ it("works with mixed namespaces", () => {
134
+ // underlying: Osdk<Q> & ObjectHolder<Q>,
135
+ // interfaceDef: InterfaceMetadata,
136
+ const iface = createOsdkInterface({
137
+ "foo": "hi mom",
138
+ [ObjectDefRef]: {
139
+ [InterfaceDefinitions]: {},
140
+ apiName: "Obj",
141
+ displayName: "",
142
+ interfaceMap: {
143
+ "a.IFoo": {
144
+ "b.asdf": "foo"
145
+ }
146
+ },
147
+ inverseInterfaceMap: {},
148
+ links: {},
149
+ pluralDisplayName: "",
150
+ primaryKeyApiName: "",
151
+ primaryKeyType: "string",
152
+ properties: {
153
+ "foo": {
154
+ type: "string"
155
+ }
156
+ },
157
+ type: "object",
158
+ titleProperty: "foo",
159
+ rid: "",
160
+ status: "ACTIVE"
161
+ }
162
+ }, {
163
+ "apiName": "a.IFoo",
164
+ displayName: "",
165
+ links: {},
166
+ properties: {
167
+ "b.asdf": {
168
+ type: "string"
169
+ }
170
+ },
171
+ rid: "",
172
+ type: "interface",
173
+ implements: []
174
+ });
175
+ expect(Object.keys(iface)).toMatchInlineSnapshot(`
176
+ [
177
+ "$apiName",
178
+ "b.asdf",
179
+ ]
180
+ `);
181
+ expect(iface["b.asdf"]).toBe("hi mom");
182
+ expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`
183
+ "{
184
+ "$apiName": "a.IFoo",
185
+ "b.asdf": "hi mom"
186
+ }"
187
+ `);
188
+ });
189
+ });
190
+ //# sourceMappingURL=createOsdkInterface.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOsdkInterface.test.js","names":["describe","expect","it","InterfaceDefinitions","createOsdkInterface","ObjectDefRef","iface","apiName","displayName","interfaceMap","inverseInterfaceMap","links","pluralDisplayName","primaryKeyApiName","primaryKeyType","properties","type","titleProperty","rid","status","implements","Object","keys","toMatchInlineSnapshot","asdf","toBe","JSON","stringify","undefined"],"sources":["createOsdkInterface.test.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 { describe, expect, it } from \"vitest\";\nimport { InterfaceDefinitions, } from \"../../ontology/OntologyProvider.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport { ObjectDefRef } from \"./InternalSymbols.js\";\ndescribe(createOsdkInterface, () => {\n it(\"works in the normal case\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"IFoo\": {\n \"asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"properly maps apiNamespace\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"a.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"a.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"works with mixed namespaces\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"b.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"b.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"b.asdf\",\n ]\n `);\n expect(iface[\"b.asdf\"]).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"b.asdf\": \"hi mom\"\n }\"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,oB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,MAAM,CAACyB,IAAI,CAACC,SAAS,CAACrB,KAAK,EAAEsB,SAAS,EAAE,CAAC,CAAC,CAAC,CAACL,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -104,9 +104,7 @@ export function createOsdkObject(client, objectDef, rawObj) {
104
104
  enumerable: true
105
105
  };
106
106
  }
107
- return {
108
- enumerable: false
109
- };
107
+ return undefined;
110
108
  }
111
109
  });
112
110
  return osdkObject;
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkObject.js","names":["createAttachmentFromRid","TimeSeriesPropertyImpl","createClientCache","get$as","get$link","ClientRef","ObjectDefRef","RawObject","UnderlyingOsdkObject","objectPrototypeCache","client","objectDef","Object","create","value","get","newValues","assign","createOsdkObject","rawObj","objectHolderPrototype","writable","holder","osdkObject","Proxy","ownKeys","target","Reflect","p","receiver","rawValue","propDef","properties","type","Array","isArray","map","a","rid","apiName","primaryKeyApiName","set","newValue","getOwnPropertyDescriptor","configurable","enumerable"],"sources":["createOsdkObject.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 { createAttachmentFromRid } from \"../../createAttachmentFromRid.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport { createClientCache } from \"../Cache.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport { ClientRef, ObjectDefRef, RawObject, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst objectPrototypeCache = createClientCache(function (client, objectDef) {\n return Object.create(null, {\n [ObjectDefRef]: { value: objectDef },\n [ClientRef]: { value: client },\n \"$as\": { value: get$as(objectDef) },\n \"$link\": {\n get: function () {\n return get$link(this);\n },\n },\n \"$updateInternalValues\": {\n value: function (newValues) {\n this[RawObject] = Object.assign({}, this[RawObject], newValues);\n },\n },\n });\n});\n/** @internal */\nexport function createOsdkObject(client, objectDef, rawObj) {\n // We use multiple layers of prototypes to maximize reuse and also to keep\n // [RawObject] out of `ownKeys`. This keeps the code in the proxy below simpler.\n const objectHolderPrototype = Object.create(objectPrototypeCache.get(client, objectDef), {\n [RawObject]: {\n value: rawObj,\n writable: true, // so we can allow updates\n },\n });\n // we separate the holder out so we can update\n // the underlying data without having to return a new object\n // we also need the holder so we can customize the console.log output\n const holder = Object.create(objectHolderPrototype);\n const osdkObject = new Proxy(holder, {\n ownKeys(target) {\n return Reflect.ownKeys(target[RawObject]);\n },\n get(target, p, receiver) {\n switch (p) {\n case UnderlyingOsdkObject:\n // effectively point back to the proxy\n return receiver;\n }\n if (p in target)\n return target[p];\n if (p in rawObj) {\n const rawValue = target[RawObject][p];\n const propDef = objectDef.properties[p];\n if (propDef) {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => createAttachmentFromRid(client, a.rid));\n }\n return createAttachmentFromRid(client, rawValue.rid);\n }\n if (propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\") {\n return new TimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);\n }\n }\n return rawValue;\n }\n // we do not do any fall through to avoid unexpected behavior\n },\n set(target, p, newValue) {\n // allow the prototype to update this value\n if (p === RawObject) {\n // symbol only exists internally so no one else can hit this\n target[p] = newValue;\n return true;\n }\n return false;\n },\n getOwnPropertyDescriptor(target, p) {\n if (p === RawObject) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n if (target[RawObject][p] != null) {\n return { configurable: true, enumerable: true };\n }\n return { enumerable: false };\n },\n });\n return osdkObject;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAuB,QAAQ,kCAAkC;AAC1E,SAASC,sBAAsB,QAAQ,mCAAmC;AAC1E,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,QAAS,sBAAsB;AAChG,MAAMC,oBAAoB,GAAGP,iBAAiB,CAAC,UAAUQ,MAAM,EAAEC,SAAS,EAAE;EACxE,OAAOC,MAAM,CAACC,MAAM,CAAC,IAAI,EAAE;IACvB,CAACP,YAAY,GAAG;MAAEQ,KAAK,EAAEH;IAAU,CAAC;IACpC,CAACN,SAAS,GAAG;MAAES,KAAK,EAAEJ;IAAO,CAAC;IAC9B,KAAK,EAAE;MAAEI,KAAK,EAAEX,MAAM,CAACQ,SAAS;IAAE,CAAC;IACnC,OAAO,EAAE;MACLI,GAAG,EAAE,SAAAA,CAAA,EAAY;QACb,OAAOX,QAAQ,CAAC,IAAI,CAAC;MACzB;IACJ,CAAC;IACD,uBAAuB,EAAE;MACrBU,KAAK,EAAE,SAAAA,CAAUE,SAAS,EAAE;QACxB,IAAI,CAACT,SAAS,CAAC,GAAGK,MAAM,CAACK,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAACV,SAAS,CAAC,EAAES,SAAS,CAAC;MACnE;IACJ;EACJ,CAAC,CAAC;AACN,CAAC,CAAC;AACF;AACA,OAAO,SAASE,gBAAgBA,CAACR,MAAM,EAAEC,SAAS,EAAEQ,MAAM,EAAE;EACxD;EACA;EACA,MAAMC,qBAAqB,GAAGR,MAAM,CAACC,MAAM,CAACJ,oBAAoB,CAACM,GAAG,CAACL,MAAM,EAAEC,S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AAEb,MAAM,CAACnB,SAAS,CAAC,CAACI,SAAS,CAAC6B,iBAAiB,CAAC,EAAEZ,CAAC,CAAC;UACnH;QACJ;QACA,OAAOE,QAAQ;MACnB;MACA;IACJ,CAAC;IACDW,GAAGA,CAACf,MAAM,EAAEE,CAAC,EAAEc,QAAQ,EAAE;MACrB;MACA,IAAId,CAAC,KAAKrB,SAAS,EAAE;QACjB;QACAmB,MAAM,CAACE,CAAC,CAAC,GAAGc,QAAQ;QACpB,OAAO,IAAI;MACf;MACA,OAAO,KAAK;IAChB,CAAC;IACDC,wBAAwBA,CAACjB,MAAM,EAAEE,CAAC,EAAE;MAChC,IAAIA,CAAC,KAAKrB,SAAS,EAAE;QACjB,OAAOoB,OAAO,CAACgB,wBAAwB,CAACjB,MAAM,EAAEE,CAAC,CAAC;MACtD;MACA,IAAIF,MAAM,CAACnB,SAAS,CAAC,CAACqB,CAAC,CAAC,IAAI,IAAI,EAAE;QAC9B,OAAO;UAAEgB,YAAY,EAAE,IAAI;UAAEC,UAAU,EAAE;QAAK,CAAC;MACnD;MACA,OAAO;QAAEA,UAAU,EAAE;MAAM,CAAC;IAChC;EACJ,CAAC,CAAC;EACF,OAAOtB,UAAU;AACrB","ignoreList":[]}
1
+ {"version":3,"file":"createOsdkObject.js","names":["createAttachmentFromRid","TimeSeriesPropertyImpl","createClientCache","get$as","get$link","ClientRef","ObjectDefRef","RawObject","UnderlyingOsdkObject","objectPrototypeCache","client","objectDef","Object","create","value","get","newValues","assign","createOsdkObject","rawObj","objectHolderPrototype","writable","holder","osdkObject","Proxy","ownKeys","target","Reflect","p","receiver","rawValue","propDef","properties","type","Array","isArray","map","a","rid","apiName","primaryKeyApiName","set","newValue","getOwnPropertyDescriptor","configurable","enumerable","undefined"],"sources":["createOsdkObject.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 { createAttachmentFromRid } from \"../../createAttachmentFromRid.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport { createClientCache } from \"../Cache.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport { ClientRef, ObjectDefRef, RawObject, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst objectPrototypeCache = createClientCache(function (client, objectDef) {\n return Object.create(null, {\n [ObjectDefRef]: { value: objectDef },\n [ClientRef]: { value: client },\n \"$as\": { value: get$as(objectDef) },\n \"$link\": {\n get: function () {\n return get$link(this);\n },\n },\n \"$updateInternalValues\": {\n value: function (newValues) {\n this[RawObject] = Object.assign({}, this[RawObject], newValues);\n },\n },\n });\n});\n/** @internal */\nexport function createOsdkObject(client, objectDef, rawObj) {\n // We use multiple layers of prototypes to maximize reuse and also to keep\n // [RawObject] out of `ownKeys`. This keeps the code in the proxy below simpler.\n const objectHolderPrototype = Object.create(objectPrototypeCache.get(client, objectDef), {\n [RawObject]: {\n value: rawObj,\n writable: true, // so we can allow updates\n },\n });\n // we separate the holder out so we can update\n // the underlying data without having to return a new object\n // we also need the holder so we can customize the console.log output\n const holder = Object.create(objectHolderPrototype);\n const osdkObject = new Proxy(holder, {\n ownKeys(target) {\n return Reflect.ownKeys(target[RawObject]);\n },\n get(target, p, receiver) {\n switch (p) {\n case UnderlyingOsdkObject:\n // effectively point back to the proxy\n return receiver;\n }\n if (p in target)\n return target[p];\n if (p in rawObj) {\n const rawValue = target[RawObject][p];\n const propDef = objectDef.properties[p];\n if (propDef) {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => createAttachmentFromRid(client, a.rid));\n }\n return createAttachmentFromRid(client, rawValue.rid);\n }\n if (propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\") {\n return new TimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);\n }\n }\n return rawValue;\n }\n // we do not do any fall through to avoid unexpected behavior\n },\n set(target, p, newValue) {\n // allow the prototype to update this value\n if (p === RawObject) {\n // symbol only exists internally so no one else can hit this\n target[p] = newValue;\n return true;\n }\n return false;\n },\n getOwnPropertyDescriptor(target, p) {\n if (p === RawObject) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n if (target[RawObject][p] != null) {\n return { configurable: true, enumerable: true };\n }\n return undefined;\n },\n });\n return osdkObject;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAuB,QAAQ,kCAAkC;AAC1E,SAASC,sBAAsB,QAAQ,mCAAmC;AAC1E,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,QAAS,sBAAsB;AAChG,MAAMC,oBAAoB,GAAGP,iBAAiB,CAAC,UAAUQ,MAAM,EAAEC,SAAS,EAAE;EACxE,OAAOC,MAAM,CAACC,MAAM,CAAC,IAAI,EAAE;IACvB,CAACP,YAAY,GAAG;MAAEQ,KAAK,EAAEH;IAAU,CAAC;IACpC,CAACN,SAAS,GAAG;MAAES,KAAK,EAAEJ;IAAO,CAAC;IAC9B,KAAK,EAAE;MAAEI,KAAK,EAAEX,MAAM,CAACQ,SAAS;IAAE,CAAC;IACnC,OAAO,EAAE;MACLI,GAAG,EAAE,SAAAA,CAAA,EAAY;QACb,OAAOX,QAAQ,CAAC,IAAI,CAAC;MACzB;IACJ,CAAC;IAC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E;YAC/B,IAAIC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAAC,EAAE;cACzB,OAAOA,QAAQ,CAACM,GAAG,CAACC,CAAC,IAAIrC,uBAAuB,CAACU,MAAM,EAAE2B,CAAC,CAACC,GAAG,CAAC,CAAC;YACpE;YACA,OAAOtC,uBAAuB,CAACU,MAAM,EAAEoB,QAAQ,CAACQ,GAAG,CAAC;UACxD;UACA,IAAIP,OAAO,CAACE,IAAI,KAAK,mBAAmB,IACjCF,OAAO,CAACE,IAAI,KAAK,kBAAkB,EAAE;YACxC,OAAO,IAAIhC,sBAAsB,CAACS,MAAM,EAAEC,SAAS,CAAC4B,OAAO,EAAEb,MAAM,CAACnB,SAAS,CAAC,CAACI,SAAS,CAAC6B,iBAAiB,CAAC,EAAEZ,CAAC,CAAC;UACnH;QACJ;QACA,OAAOE,QAAQ;MACnB;MACA;IACJ,CAAC;IACDW,GAAGA,CAACf,MAAM,EAAEE,CAAC,EAAEc,QAAQ,EAAE;MACrB;MACA,IAAId,CAAC,KAAKrB,SAAS,EAAE;QACjB;QACAmB,MAAM,CAACE,CAAC,CAAC,GAAGc,QAAQ;QACpB,OAAO,IAAI;MACf;MACA,OAAO,KAAK;IAChB,CAAC;IACDC,wBAAwBA,CAACjB,MAAM,EAAEE,CAAC,EAAE;MAChC,IAAIA,CAAC,KAAKrB,SAAS,EAAE;QACjB,OAAOoB,OAAO,CAACgB,wBAAwB,CAACjB,MAAM,EAAEE,CAAC,CAAC;MACtD;MACA,IAAIF,MAAM,CAACnB,SAAS,CAAC,CAACqB,CAAC,CAAC,IAAI,IAAI,EAAE;QAC9B,OAAO;UAAEgB,YAAY,EAAE,IAAI;UAAEC,UAAU,EAAE;QAAK,CAAC;MACnD;MACA,OAAOC,SAAS;IACpB;EACJ,CAAC,CAAC;EACF,OAAOvB,UAAU;AACrB","ignoreList":[]}
@@ -34,10 +34,34 @@ describe("convertWireToOsdkObjects", () => {
34
34
  const {
35
35
  data: [employee]
36
36
  } = await client(Employee).fetchPage();
37
- expect(Object.keys(employee).sort()).toEqual(["employeeId", "fullName", "office", "class", "startDate", "employeeStatus", "$apiName", "$objectType", "$primaryKey", "$title"].sort());
37
+ expect(Object.keys(employee).sort()).toEqual(["employeeId", "fullName", "office", "class", "startDate", "employeeStatus", "$apiName", "$objectType", "$primaryKey"].sort());
38
38
  expect(Object.keys(employee.$as)).toEqual([]);
39
39
  expect(Object.keys(employee.$link)).toEqual(["peeps", "lead", "officeLink"]);
40
40
  });
41
+ it("stringifies properties on objects and interfaces correctly", async () => {
42
+ const {
43
+ data: [employee]
44
+ } = await client(Employee).fetchPage();
45
+ const {
46
+ data: [employee2]
47
+ } = await client(Employee).where({
48
+ $and: [{
49
+ employeeId: {
50
+ $gt: 50030
51
+ }
52
+ }, {
53
+ employeeId: {
54
+ $lt: 50032
55
+ }
56
+ }]
57
+ }).fetchPage();
58
+ // Should not have $title
59
+ expect(JSON.stringify(employee)).toMatchInlineSnapshot(`"{"employeeId":50030,"fullName":"John Doe","office":"NYC","class":"Red","startDate":"2019-01-01","employeeStatus":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50030}"`);
60
+ expect(JSON.stringify(employee.$as(FooInterface))).toMatchInlineSnapshot(`"{"$apiName":"FooInterface","$objectType":"Employee","$primaryKey":50030,"fooSpt":"John Doe"}"`);
61
+ // Should have $title
62
+ expect(JSON.stringify(employee2)).toMatchInlineSnapshot(`"{"employeeId":50031,"fullName":"Jane Doe","office":"SEA","class":"Blue","startDate":"2012-02-12","employeeStatus":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe"}"`);
63
+ expect(JSON.stringify(employee2.$as(FooInterface))).toMatchInlineSnapshot(`"{"$apiName":"FooInterface","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe","fooSpt":"Jane Doe"}"`);
64
+ });
41
65
  it("reuses the object prototype across objects", async () => {
42
66
  const employees = await client(Employee).fetchPage();
43
67
  expect(employees.data.length).toBeGreaterThanOrEqual(2);
@@ -1 +1 @@
1
- {"version":3,"file":"convertWireToOsdkObjects.test.js","names":["$ontologyRid","Employee","FooInterface","objectTypeWithAllPropertyTypes","symbolClientContext","createSharedClientContext","apiServer","afterAll","beforeAll","describe","expect","expectTypeOf","it","createClient","createMinimalClient","convertWireToOsdkObjects","client","listen","close","data","employee","fetchPage","Object","keys","sort","toEqual","$as","$link","employees","length","toBeGreaterThanOrEqual","a","b","getPrototypeOf","toBe","withValues","where","id","attachment","attachmentArray","toMatchTypeOf","rid","Array","isArray","toBeTruthy","withoutValues","emptyAttachment","emptyAttachmentArray","toBeUndefined","clientCtx","ontologyRid","object","__apiName","apiName","__primaryKey","prototypeBefore","object2","undefined","prototypeAfter","not","obj","__title","fullName","employeeId","objAsFoo","toMatchObject","fooSpt","$apiName","$primaryKey","$objectType","$title","console","log","$updateInternalValues","toMatchInlineSnapshot","__rid","$rid","rejects","toThrowErrorMatchingInlineSnapshot","resolves","to","result"],"sources":["convertWireToOsdkObjects.test.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 { $ontologyRid, Employee, FooInterface, objectTypeWithAllPropertyTypes, } from \"@osdk/client.test.ontology\";\nimport { symbolClientContext } from \"@osdk/shared.client\";\nimport { createSharedClientContext } from \"@osdk/shared.client.impl\";\nimport { apiServer } from \"@osdk/shared.test\";\nimport { afterAll, beforeAll, describe, expect, expectTypeOf, it, } from \"vitest\";\nimport { createClient } from \"../createClient.js\";\nimport { createMinimalClient } from \"../createMinimalClient.js\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\ndescribe(\"convertWireToOsdkObjects\", () => {\n let client;\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\"https://stack.palantir.com\", $ontologyRid, async () => \"myAccessToken\");\n });\n afterAll(() => {\n apiServer.close();\n });\n it(\"configures properties correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n expect(Object.keys(employee).sort()).toEqual([\n \"employeeId\",\n \"fullName\",\n \"office\",\n \"class\",\n \"startDate\",\n \"employeeStatus\",\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"$title\",\n ].sort());\n expect(Object.keys(employee.$as)).toEqual([]);\n expect(Object.keys(employee.$link)).toEqual([\n \"peeps\",\n \"lead\",\n \"officeLink\",\n ]);\n });\n it(\"reuses the object prototype across objects\", async () => {\n const employees = await client(Employee).fetchPage();\n expect(employees.data.length).toBeGreaterThanOrEqual(2);\n const [a, b] = employees.data;\n expect(Object.getPrototypeOf(Object.getPrototypeOf(a))).toBe(Object.getPrototypeOf(Object.getPrototypeOf(b)));\n });\n it(\"converts attachments as expected\", async () => {\n const withValues = await client(objectTypeWithAllPropertyTypes)\n .where({ id: 1 })\n .fetchPage();\n expect(withValues.data.length).toBeGreaterThanOrEqual(1);\n const { attachment, attachmentArray } = withValues.data[0];\n expectTypeOf(attachment).toMatchTypeOf;\n expect(attachment?.rid).toEqual(\"ri.attachments.main.attachment.86016861-707f-4292-b258-6a7108915a75\");\n expect(Array.isArray(attachmentArray)).toBeTruthy();\n expectTypeOf(attachmentArray[0]).toMatchTypeOf;\n const withoutValues = await client(objectTypeWithAllPropertyTypes).where({ id: 2 }).fetchPage();\n const { attachment: emptyAttachment, attachmentArray: emptyAttachmentArray, } = withoutValues.data[0];\n expect(emptyAttachment).toBeUndefined();\n expect(emptyAttachmentArray).toBeUndefined();\n });\n it(\"works even with unknown apiNames\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n createSharedClientContext(\"https://stack.palantir.com\", async () => \"myAccessToken\", \"userAgent\");\n let object = {\n __apiName: Employee.apiName,\n __primaryKey: 0,\n };\n const prototypeBefore = Object.getPrototypeOf(object);\n let object2 = await convertWireToOsdkObjects(clientCtx, [object], undefined, undefined, undefined, false);\n const prototypeAfter = Object.getPrototypeOf(object2);\n expect(prototypeBefore).not.toBe(prototypeAfter);\n });\n it(\"updates interface when underlying changes\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n let objectFromWire = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n __title: \"Steve\",\n fullName: \"Steve\",\n employeeId: \"5\",\n };\n const [obj] = (await convertWireToOsdkObjects(clientCtx, [objectFromWire], undefined));\n expect(obj.fullName).toEqual(\"Steve\");\n expect(Object.keys(obj).sort()).toEqual([\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"$title\",\n \"employeeId\",\n \"fullName\",\n ].sort());\n const objAsFoo = obj.$as(FooInterface);\n expect(objAsFoo).toMatchObject({\n fooSpt: obj.fullName,\n $apiName: FooInterface.apiName,\n $primaryKey: obj.$primaryKey,\n $objectType: obj.$objectType,\n $title: obj.$title,\n });\n console.log(obj);\n console.log(objAsFoo);\n obj.$updateInternalValues({\n fullName: \"Bob\",\n });\n expect(obj.fullName).toEqual(\"Bob\");\n expect(objAsFoo.fooSpt).toEqual(obj.fullName);\n expect(Object.keys(objAsFoo).sort()).toEqual([\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"$title\",\n \"fooSpt\",\n ].sort());\n expect(obj).toBe(objAsFoo.$as(Employee));\n expect(objAsFoo).toBe(obj.$as(FooInterface));\n });\n it(\"reconstitutes interfaces properly without rid\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n let objectFromWire = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n __title: \"Steve\",\n fooSpt: \"Steve\",\n };\n const [objAsFoo] = (await convertWireToOsdkObjects(clientCtx, [objectFromWire], FooInterface.apiName));\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n });\n it(\"reconstitutes interfaces properly with rid\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n let objectFromWire = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n __title: \"Steve\",\n __rid: \"hiMom\",\n fooSpt: \"Steve\",\n };\n const [objAsFoo] = (await convertWireToOsdkObjects(clientCtx, [objectFromWire], FooInterface.apiName));\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n expect(objAsFoo.$rid).toEqual(\"hiMom\");\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n expect(obj.$rid).toEqual(\"hiMom\");\n });\n describe(\"selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n await expect(() => convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"employeeId\"], \"throw\")).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Unable to safely convert objects as some non nullable properties are null]`);\n });\n it(\"does not throw when optional is missing\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n await expect(convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"fullName\"], \"throw\")).resolves.to.not.toBeUndefined();\n });\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"employeeId\"], \"drop\");\n expect(result.length).toBe(0);\n });\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"fullName\"], \"drop\");\n expect(result.length).toBe(1);\n });\n });\n describe(\"without selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n await expect(() => convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"throw\")).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Unable to safely convert objects as some non nullable properties are null]`);\n });\n it(\"does not throw when required is present\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n };\n await expect(convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"throw\")).resolves.to.not.toBeUndefined();\n });\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"drop\");\n expect(result.length).toBe(0);\n });\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"drop\");\n expect(result.length).toBe(1);\n });\n });\n it(\"behaves correctly when converting\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n fooSpt: \"hi\",\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], \"FooInterface\", undefined, [\"fooSpt\"], \"drop\");\n expect(result.length).toBe(1);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,8BAA8B,QAAS,4BAA4B;AAClH,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,yBAAyB,QAAQ,0BAA0B;AACpE,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAEC,EAAE,QAAS,QAAQ;AACjF,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,wBAAwB,QAAQ,+BAA+B;AACxEN,QAAQ,CAAC,0BAA0B,EAAE,MAAM;EACvC,IAAIO,MAAM;EACVR,SAAS,CAAC,YAAY;IAClBF,SAAS,CAACW,MAAM,CAAC,CAAC;IAClBD,MAAM,GAAGH,YAAY,CAAC,4BAA4B,EAAEb,YAAY,EAAE,YAAY,eAAe,CAAC;EAClG,CAAC,CAAC;EACFO,QAAQ,CAAC,MAAM;IACXD,SAAS,CAACY,KAAK,CAAC,CAAC;EACrB,CAAC,CAAC;EACFN,EAAE,CAAC,iCAAiC,EAAE,YAAY;IAC9C,MAAM;MAAEO,IAAI,EAAE,CAACC,QAAQ;IAAE,CAAC,GAAG,MAAMJ,MAAM,CAACf,QAAQ,CAAC,CAACoB,SAAS,CAAC,CAAC;IAC/DX,MAAM,CAACY,MAAM,CAACC,IA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EAAEG,SAAS,EAAEA,SAAS,EAAEA,SAAS,EAAE,MAAM,CAAC;MAC7H/C,MAAM,CAACuE,MAAM,CAACpD,MAAM,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC;IACFtB,EAAE,CAAC,mCAAmC,EAAE,YAAY;MAMhD,MAAMqE,MAAM,GAAG,MAAMlE,wBAAwB,CAACC,MAAM,CAACZ,mBAAmB,CAAC,EAAE,CAL5D;QACXgD,SAAS,EAAE,UAAU;QACrBE,YAAY,EAAE,CAAC;QACf,YAAY,EAAE;MAClB,CAAC,CACkF,EAAEG,SAAS,EAAEA,SAAS,EAAEA,SAAS,EAAE,MAAM,CAAC;MAC7H/C,MAAM,CAACuE,MAAM,CAACpD,MAAM,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC;EACN,CAAC,CAAC;EACFtB,EAAE,CAAC,mCAAmC,EAAE,YAAY;IAMhD,MAAMqE,MAAM,GAAG,MAAMlE,wBAAwB,CAACC,MAAM,CAACZ,mBAAmB,CAAC,EAAE,CAL5D;MACXgD,SAAS,EAAE,UAAU;MACrBE,YAAY,EAAE,CAAC;MACfY,MAAM,EAAE;IACZ,CAAC,CACkF,EAAE,cAAc,EAAET,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACnI/C,MAAM,CAACuE,MAAM,CAACpD,MAAM,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;EACjC,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"convertWireToOsdkObjects.test.js","names":["$ontologyRid","Employee","FooInterface","objectTypeWithAllPropertyTypes","symbolClientContext","createSharedClientContext","apiServer","afterAll","beforeAll","describe","expect","expectTypeOf","it","createClient","createMinimalClient","convertWireToOsdkObjects","client","listen","close","data","employee","fetchPage","Object","keys","sort","toEqual","$as","$link","employee2","where","$and","employeeId","$gt","$lt","JSON","stringify","toMatchInlineSnapshot","employees","length","toBeGreaterThanOrEqual","a","b","getPrototypeOf","toBe","withValues","id","attachment","attachmentArray","toMatchTypeOf","rid","Array","isArray","toBeTruthy","withoutValues","emptyAttachment","emptyAttachmentArray","toBeUndefined","clientCtx","ontologyRid","object","__apiName","apiName","__primaryKey","prototypeBefore","object2","undefined","prototypeAfter","not","obj","__title","fullName","objAsFoo","toMatchObject","fooSpt","$apiName","$primaryKey","$objectType","$title","console","log","$updateInternalValues","__rid","$rid","rejects","toThrowErrorMatchingInlineSnapshot","resolves","to","result"],"sources":["convertWireToOsdkObjects.test.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 { $ontologyRid, Employee, FooInterface, objectTypeWithAllPropertyTypes, } from \"@osdk/client.test.ontology\";\nimport { symbolClientContext } from \"@osdk/shared.client\";\nimport { createSharedClientContext } from \"@osdk/shared.client.impl\";\nimport { apiServer } from \"@osdk/shared.test\";\nimport { afterAll, beforeAll, describe, expect, expectTypeOf, it, } from \"vitest\";\nimport { createClient } from \"../createClient.js\";\nimport { createMinimalClient } from \"../createMinimalClient.js\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\ndescribe(\"convertWireToOsdkObjects\", () => {\n let client;\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\"https://stack.palantir.com\", $ontologyRid, async () => \"myAccessToken\");\n });\n afterAll(() => {\n apiServer.close();\n });\n it(\"configures properties correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n expect(Object.keys(employee).sort()).toEqual([\n \"employeeId\",\n \"fullName\",\n \"office\",\n \"class\",\n \"startDate\",\n \"employeeStatus\",\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n ].sort());\n expect(Object.keys(employee.$as)).toEqual([]);\n expect(Object.keys(employee.$link)).toEqual([\n \"peeps\",\n \"lead\",\n \"officeLink\",\n ]);\n });\n it(\"stringifies properties on objects and interfaces correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n const { data: [employee2] } = await client(Employee).where({\n $and: [{ employeeId: { $gt: 50030 } }, { employeeId: { $lt: 50032 } }],\n }).fetchPage();\n // Should not have $title\n expect(JSON.stringify(employee)).toMatchInlineSnapshot(`\"{\"employeeId\":50030,\"fullName\":\"John Doe\",\"office\":\"NYC\",\"class\":\"Red\",\"startDate\":\"2019-01-01\",\"employeeStatus\":{},\"$apiName\":\"Employee\",\"$objectType\":\"Employee\",\"$primaryKey\":50030}\"`);\n expect(JSON.stringify(employee.$as(FooInterface))).toMatchInlineSnapshot(`\"{\"$apiName\":\"FooInterface\",\"$objectType\":\"Employee\",\"$primaryKey\":50030,\"fooSpt\":\"John Doe\"}\"`);\n // Should have $title\n expect(JSON.stringify(employee2)).toMatchInlineSnapshot(`\"{\"employeeId\":50031,\"fullName\":\"Jane Doe\",\"office\":\"SEA\",\"class\":\"Blue\",\"startDate\":\"2012-02-12\",\"employeeStatus\":{},\"$apiName\":\"Employee\",\"$objectType\":\"Employee\",\"$primaryKey\":50031,\"$title\":\"Jane Doe\"}\"`);\n expect(JSON.stringify(employee2.$as(FooInterface))).toMatchInlineSnapshot(`\"{\"$apiName\":\"FooInterface\",\"$objectType\":\"Employee\",\"$primaryKey\":50031,\"$title\":\"Jane Doe\",\"fooSpt\":\"Jane Doe\"}\"`);\n });\n it(\"reuses the object prototype across objects\", async () => {\n const employees = await client(Employee).fetchPage();\n expect(employees.data.length).toBeGreaterThanOrEqual(2);\n const [a, b] = employees.data;\n expect(Object.getPrototypeOf(Object.getPrototypeOf(a))).toBe(Object.getPrototypeOf(Object.getPrototypeOf(b)));\n });\n it(\"converts attachments as expected\", async () => {\n const withValues = await client(objectTypeWithAllPropertyTypes)\n .where({ id: 1 })\n .fetchPage();\n expect(withValues.data.length).toBeGreaterThanOrEqual(1);\n const { attachment, attachmentArray } = withValues.data[0];\n expectTypeOf(attachment).toMatchTypeOf;\n expect(attachment?.rid).toEqual(\"ri.attachments.main.attachment.86016861-707f-4292-b258-6a7108915a75\");\n expect(Array.isArray(attachmentArray)).toBeTruthy();\n expectTypeOf(attachmentArray[0]).toMatchTypeOf;\n const withoutValues = await client(objectTypeWithAllPropertyTypes).where({ id: 2 }).fetchPage();\n const { attachment: emptyAttachment, attachmentArray: emptyAttachmentArray, } = withoutValues.data[0];\n expect(emptyAttachment).toBeUndefined();\n expect(emptyAttachmentArray).toBeUndefined();\n });\n it(\"works even with unknown apiNames\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n createSharedClientContext(\"https://stack.palantir.com\", async () => \"myAccessToken\", \"userAgent\");\n let object = {\n __apiName: Employee.apiName,\n __primaryKey: 0,\n };\n const prototypeBefore = Object.getPrototypeOf(object);\n let object2 = await convertWireToOsdkObjects(clientCtx, [object], undefined, undefined, undefined, false);\n const prototypeAfter = Object.getPrototypeOf(object2);\n expect(prototypeBefore).not.toBe(prototypeAfter);\n });\n it(\"updates interface when underlying changes\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n let objectFromWire = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n __title: \"Steve\",\n fullName: \"Steve\",\n employeeId: \"5\",\n };\n const [obj] = (await convertWireToOsdkObjects(clientCtx, [objectFromWire], undefined));\n expect(obj.fullName).toEqual(\"Steve\");\n expect(Object.keys(obj).sort()).toEqual([\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"$title\",\n \"employeeId\",\n \"fullName\",\n ].sort());\n const objAsFoo = obj.$as(FooInterface);\n expect(objAsFoo).toMatchObject({\n fooSpt: obj.fullName,\n $apiName: FooInterface.apiName,\n $primaryKey: obj.$primaryKey,\n $objectType: obj.$objectType,\n $title: obj.$title,\n });\n console.log(obj);\n console.log(objAsFoo);\n obj.$updateInternalValues({\n fullName: \"Bob\",\n });\n expect(obj.fullName).toEqual(\"Bob\");\n expect(objAsFoo.fooSpt).toEqual(obj.fullName);\n expect(Object.keys(objAsFoo).sort()).toEqual([\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"$title\",\n \"fooSpt\",\n ].sort());\n expect(obj).toBe(objAsFoo.$as(Employee));\n expect(objAsFoo).toBe(obj.$as(FooInterface));\n });\n it(\"reconstitutes interfaces properly without rid\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n let objectFromWire = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n __title: \"Steve\",\n fooSpt: \"Steve\",\n };\n const [objAsFoo] = (await convertWireToOsdkObjects(clientCtx, [objectFromWire], FooInterface.apiName));\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n });\n it(\"reconstitutes interfaces properly with rid\", async () => {\n const clientCtx = createMinimalClient({ ontologyRid: $ontologyRid }, \"https://stack.palantir.com\", async () => \"myAccessToken\");\n let objectFromWire = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n __title: \"Steve\",\n __rid: \"hiMom\",\n fooSpt: \"Steve\",\n };\n const [objAsFoo] = (await convertWireToOsdkObjects(clientCtx, [objectFromWire], FooInterface.apiName));\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n expect(objAsFoo.$rid).toEqual(\"hiMom\");\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n expect(obj.$rid).toEqual(\"hiMom\");\n });\n describe(\"selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n await expect(() => convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"employeeId\"], \"throw\")).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Unable to safely convert objects as some non nullable properties are null]`);\n });\n it(\"does not throw when optional is missing\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n await expect(convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"fullName\"], \"throw\")).resolves.to.not.toBeUndefined();\n });\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"employeeId\"], \"drop\");\n expect(result.length).toBe(0);\n });\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, [\"fullName\"], \"drop\");\n expect(result.length).toBe(1);\n });\n });\n describe(\"without selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n await expect(() => convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"throw\")).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Unable to safely convert objects as some non nullable properties are null]`);\n });\n it(\"does not throw when required is present\", async () => {\n let object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n };\n await expect(convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"throw\")).resolves.to.not.toBeUndefined();\n });\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"drop\");\n expect(result.length).toBe(0);\n });\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], undefined, undefined, undefined, \"drop\");\n expect(result.length).toBe(1);\n });\n });\n it(\"behaves correctly when converting\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n fooSpt: \"hi\",\n };\n const result = await convertWireToOsdkObjects(client[symbolClientContext], [object], \"FooInterface\", undefined, [\"fooSpt\"], \"drop\");\n expect(result.length).toBe(1);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,8BAA8B,QAAS,4BAA4B;AAClH,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,yBAAyB,QAAQ,0BAA0B;AACpE,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAEC,EAAE,QAAS,QAAQ;AACjF,SAAS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AM,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;EACjC,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -19,7 +19,7 @@ import { fetchPage } from "./fetchPage.js";
19
19
  export async function fetchSingle(client, objectType, args, objectSet) {
20
20
  const result = await fetchPage(client, objectType, {
21
21
  ...args,
22
- pageSize: 1
22
+ $pageSize: 1
23
23
  }, objectSet);
24
24
  if (result.data.length !== 1 || result.nextPageToken != null) {
25
25
  throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? " with nextPageToken set" : ""}`);
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSingle.js","names":["PalantirApiError","fetchPage","fetchSingle","client","objectType","args","objectSet","result","pageSize","data","length","nextPageToken","fetchSingleWithErrors","value","e","Error","error"],"sources":["fetchSingle.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 { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { fetchPage } from \"./fetchPage.js\";\n/** @internal */\nexport async function fetchSingle(client, objectType, args, objectSet) {\n const result = await fetchPage(client, objectType, { ...args, pageSize: 1 }, objectSet);\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\n}\n/** @internal */\nexport async function fetchSingleWithErrors(client, objectType, args, objectSet) {\n try {\n const result = await fetchSingle(client, objectType, args, objectSet);\n return { value: result };\n }\n catch (e) {\n if (e instanceof Error) {\n return { error: e };\n }\n return { error: e };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,SAAS,QAAQ,gBAAgB;AAC1C;AACA,OAAO,eAAeC,WAAWA,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EACnE,MAAMC,MAAM,GAAG,MAAMN,SAAS,CAACE,MAAM,EAAEC,UAAU,EAAE;IAAE,GAAGC,IAAI;IAAEG,QAAQ,EAAE;EAAE,CAAC,EAAEF,SAAS,CAAC;EACvF,IAAIC,MAAM,CAACE,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIH,MAAM,CAACI,aAAa,IAAI,IAAI,EAAE;IAC1D,MAAM,IAAIX,gBAAgB,CAAC,oCAAoCO,MAAM,CAACE,IAAI,CAACC,MAAM,WAAWH,MAAM,CAACI,aAAa,IAAI,IAAI,GAAG,yBAAyB,GAAG,EAAE,EAAE,CAAC;EAChK;EACA,OAAOJ,MAAM,CAACE,IAAI,CAAC,CAAC,CAAC;AACzB;AACA;AACA,OAAO,eAAeG,qBAAqBA,CAACT,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EAC7E,IAAI;IACA,MAAMC,MAAM,GAAG,MAAML,WAAW,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,CAAC;IACrE,OAAO;MAAEO,KAAK,EAAEN;IAAO,CAAC;EAC5B,CAAC,CACD,OAAOO,CAAC,EAAE;IACN,IAAIA,CAAC,YAAYC,KAAK,EAAE;MACpB,OAAO;QAAEC,KAAK,EAAEF;MAAE,CAAC;IACvB;IACA,OAAO;MAAEE,KAAK,EAAEF;IAAE,CAAC;EACvB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"fetchSingle.js","names":["PalantirApiError","fetchPage","fetchSingle","client","objectType","args","objectSet","result","$pageSize","data","length","nextPageToken","fetchSingleWithErrors","value","e","Error","error"],"sources":["fetchSingle.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 { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { fetchPage } from \"./fetchPage.js\";\n/** @internal */\nexport async function fetchSingle(client, objectType, args, objectSet) {\n const result = await fetchPage(client, objectType, { ...args, $pageSize: 1 }, objectSet);\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\n}\n/** @internal */\nexport async function fetchSingleWithErrors(client, objectType, args, objectSet) {\n try {\n const result = await fetchSingle(client, objectType, args, objectSet);\n return { value: result };\n }\n catch (e) {\n if (e instanceof Error) {\n return { error: e };\n }\n return { error: e };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,SAAS,QAAQ,gBAAgB;AAC1C;AACA,OAAO,eAAeC,WAAWA,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EACnE,MAAMC,MAAM,GAAG,MAAMN,SAAS,CAACE,MAAM,EAAEC,UAAU,EAAE;IAAE,GAAGC,IAAI;IAAEG,SAAS,EAAE;EAAE,CAAC,EAAEF,SAAS,CAAC;EACxF,IAAIC,MAAM,CAACE,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIH,MAAM,CAACI,aAAa,IAAI,IAAI,EAAE;IAC1D,MAAM,IAAIX,gBAAgB,CAAC,oCAAoCO,MAAM,CAACE,IAAI,CAACC,MAAM,WAAWH,MAAM,CAACI,aAAa,IAAI,IAAI,GAAG,yBAAyB,GAAG,EAAE,EAAE,CAAC;EAChK;EACA,OAAOJ,MAAM,CAACE,IAAI,CAAC,CAAC,CAAC;AACzB;AACA;AACA,OAAO,eAAeG,qBAAqBA,CAACT,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAE;EAC7E,IAAI;IACA,MAAMC,MAAM,GAAG,MAAML,WAAW,CAACC,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,CAAC;IACrE,OAAO;MAAEO,KAAK,EAAEN;IAAO,CAAC;EAC5B,CAAC,CACD,OAAOO,CAAC,EAAE;IACN,IAAIA,CAAC,YAAYC,KAAK,EAAE;MACpB,OAAO;QAAEC,KAAK,EAAEF;MAAE,CAAC;IACvB;IACA,OAAO;MAAEE,KAAK,EAAEF;IAAE,CAAC;EACvB;AACJ","ignoreList":[]}
@@ -46,11 +46,11 @@ describe("OsdkObject", () => {
46
46
  }).fetchPage();
47
47
  // we should get the employee we requested
48
48
  const employee = result.data[0];
49
+ expect(JSON.stringify(employee)).toBeDefined();
49
50
  expect(employee).toMatchObject({
50
51
  "$apiName": "Employee",
51
52
  "$objectType": "Employee",
52
53
  "$primaryKey": 50030,
53
- "$title": "John Doe",
54
54
  "class": "Red",
55
55
  "employeeId": 50030,
56
56
  "employeeStatus": expect.anything(),