@osdk/client 2.3.0-beta.4 → 2.3.0-beta.6

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 (103) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/build/browser/createClient.js +8 -1
  3. package/build/browser/createClient.js.map +1 -1
  4. package/build/browser/logger/BaseLogger.js +1 -1
  5. package/build/browser/logger/BaseLogger.js.map +1 -1
  6. package/build/browser/observable/ObservableClient.js +17 -1
  7. package/build/browser/observable/ObservableClient.js.map +1 -1
  8. package/build/browser/observable/OptimisticBuilder.js.map +1 -1
  9. package/build/browser/observable/internal/ActionApplication.js +31 -30
  10. package/build/browser/observable/internal/ActionApplication.js.map +1 -1
  11. package/build/browser/observable/internal/Changes.js +5 -1
  12. package/build/browser/observable/internal/Changes.js.map +1 -1
  13. package/build/browser/observable/internal/ListQuery.js +24 -22
  14. package/build/browser/observable/internal/ListQuery.js.map +1 -1
  15. package/build/browser/observable/internal/ObjectQuery.js +30 -1
  16. package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
  17. package/build/browser/observable/internal/ObservableClientImpl.js +1 -2
  18. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  19. package/build/browser/observable/internal/OptimisticJob.js +8 -0
  20. package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
  21. package/build/browser/observable/internal/Query.js +2 -2
  22. package/build/browser/observable/internal/Query.js.map +1 -1
  23. package/build/browser/observable/internal/Store.js +4 -0
  24. package/build/browser/observable/internal/Store.js.map +1 -1
  25. package/build/browser/observable/internal/Store.test.js +45 -5
  26. package/build/browser/observable/internal/Store.test.js.map +1 -1
  27. package/build/browser/observable/internal/testUtils.js.map +1 -1
  28. package/build/browser/observable/internal/tombstone.js +18 -0
  29. package/build/browser/observable/internal/tombstone.js.map +1 -0
  30. package/build/browser/util/UserAgent.js +2 -1
  31. package/build/browser/util/UserAgent.js.map +1 -1
  32. package/build/browser/util/toDataValue.js +1 -1
  33. package/build/browser/util/toDataValue.js.map +1 -1
  34. package/build/cjs/chunk-DHPFI5ZJ.cjs +1793 -0
  35. package/build/cjs/chunk-DHPFI5ZJ.cjs.map +1 -0
  36. package/build/cjs/{chunk-MZ4JZQUU.cjs → chunk-N4KFUVWG.cjs} +642 -42
  37. package/build/cjs/chunk-N4KFUVWG.cjs.map +1 -0
  38. package/build/cjs/index.cjs +16 -1769
  39. package/build/cjs/index.cjs.map +1 -1
  40. package/build/cjs/public/internal.cjs +7 -8
  41. package/build/cjs/public/internal.cjs.map +1 -1
  42. package/build/cjs/public/unstable-do-not-use.cjs +182 -123
  43. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  44. package/build/cjs/public/unstable-do-not-use.d.cts +2 -1
  45. package/build/esm/createClient.js +8 -1
  46. package/build/esm/createClient.js.map +1 -1
  47. package/build/esm/logger/BaseLogger.js +1 -1
  48. package/build/esm/logger/BaseLogger.js.map +1 -1
  49. package/build/esm/observable/ObservableClient.js +17 -1
  50. package/build/esm/observable/ObservableClient.js.map +1 -1
  51. package/build/esm/observable/OptimisticBuilder.js.map +1 -1
  52. package/build/esm/observable/internal/ActionApplication.js +31 -30
  53. package/build/esm/observable/internal/ActionApplication.js.map +1 -1
  54. package/build/esm/observable/internal/Changes.js +5 -1
  55. package/build/esm/observable/internal/Changes.js.map +1 -1
  56. package/build/esm/observable/internal/ListQuery.js +24 -22
  57. package/build/esm/observable/internal/ListQuery.js.map +1 -1
  58. package/build/esm/observable/internal/ObjectQuery.js +30 -1
  59. package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
  60. package/build/esm/observable/internal/ObservableClientImpl.js +1 -2
  61. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  62. package/build/esm/observable/internal/OptimisticJob.js +8 -0
  63. package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
  64. package/build/esm/observable/internal/Query.js +2 -2
  65. package/build/esm/observable/internal/Query.js.map +1 -1
  66. package/build/esm/observable/internal/Store.js +4 -0
  67. package/build/esm/observable/internal/Store.js.map +1 -1
  68. package/build/esm/observable/internal/Store.test.js +45 -5
  69. package/build/esm/observable/internal/Store.test.js.map +1 -1
  70. package/build/esm/observable/internal/testUtils.js.map +1 -1
  71. package/build/esm/observable/internal/tombstone.js +18 -0
  72. package/build/esm/observable/internal/tombstone.js.map +1 -0
  73. package/build/esm/util/UserAgent.js +2 -1
  74. package/build/esm/util/UserAgent.js.map +1 -1
  75. package/build/esm/util/toDataValue.js +1 -1
  76. package/build/esm/util/toDataValue.js.map +1 -1
  77. package/build/types/createClient.d.ts.map +1 -1
  78. package/build/types/observable/ObservableClient.d.ts +2 -2
  79. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  80. package/build/types/observable/OptimisticBuilder.d.ts +1 -0
  81. package/build/types/observable/OptimisticBuilder.d.ts.map +1 -1
  82. package/build/types/observable/internal/ActionApplication.d.ts +1 -1
  83. package/build/types/observable/internal/ActionApplication.d.ts.map +1 -1
  84. package/build/types/observable/internal/Changes.d.ts +2 -0
  85. package/build/types/observable/internal/Changes.d.ts.map +1 -1
  86. package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
  87. package/build/types/observable/internal/ObjectQuery.d.ts +1 -0
  88. package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
  89. package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
  90. package/build/types/observable/internal/Store.d.ts +2 -1
  91. package/build/types/observable/internal/Store.d.ts.map +1 -1
  92. package/build/types/observable/internal/testUtils.d.ts +1 -1
  93. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  94. package/build/types/observable/internal/tombstone.d.ts +1 -0
  95. package/build/types/observable/internal/tombstone.d.ts.map +1 -0
  96. package/build/types/util/UserAgent.d.ts +1 -0
  97. package/build/types/util/UserAgent.d.ts.map +1 -1
  98. package/package.json +8 -8
  99. package/build/cjs/chunk-C5D7744G.cjs +0 -615
  100. package/build/cjs/chunk-C5D7744G.cjs.map +0 -1
  101. package/build/cjs/chunk-MZ4JZQUU.cjs.map +0 -1
  102. package/build/cjs/chunk-T4NIFYZS.cjs +0 -14
  103. package/build/cjs/chunk-T4NIFYZS.cjs.map +0 -1
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2025 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
+
17
+ export const tombstone = undefined;
18
+ //# sourceMappingURL=tombstone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tombstone.js","names":["tombstone","undefined"],"sources":["tombstone.ts"],"sourcesContent":["/*\n * Copyright 2025 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\nexport const tombstone: undefined = undefined;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,SAAoB,GAAGC,SAAS","ignoreList":[]}
@@ -14,5 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export const USER_AGENT = `osdk-client/${"2.3.0-beta.4"}`;
17
+ export const USER_AGENT = `osdk-client/${"2.3.0-beta.6"}`;
18
+ export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.3.0-beta.6"}`;
18
19
  //# sourceMappingURL=UserAgent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserAgent.js","names":["USER_AGENT"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT: string = `osdk-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAkB,GAAG,+BAA4C","ignoreList":[]}
1
+ {"version":3,"file":"UserAgent.js","names":["USER_AGENT","OBSERVABLE_USER_AGENT"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT: string = `osdk-client/${process.env.PACKAGE_VERSION}`;\nexport const OBSERVABLE_USER_AGENT: string =\n `osdk-observable-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAkB,GAAG,+BAA4C;AAC9E,OAAO,MAAMC,qBAA6B,GACxC,0CAAuD","ignoreList":[]}
@@ -72,7 +72,7 @@ export async function toDataValue(value, client) {
72
72
  return await toDataValue(value.$primaryKey, client);
73
73
  }
74
74
  if (isPoint(value)) {
75
- return await toDataValue(value.coordinates.join(), client);
75
+ return await toDataValue(`${value.coordinates[1]},${value.coordinates[0]}`, client);
76
76
  }
77
77
 
78
78
  // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)
@@ -1 +1 @@
1
- {"version":3,"file":"toDataValue.js","names":["OntologiesV2","isAttachmentFile","isAttachmentUpload","isMediaReference","getWireObjectSet","isObjectSet","isInterfaceActionParam","isObjectSpecifiersObject","isOntologyObjectV2","isPoint","isWireObjectSet","toDataValue","value","client","Array","isArray","Set","values","from","some","dataValue","converted","push","promiseArray","innerValue","Promise","all","attachment","Attachments","upload","data","filename","name","rid","__primaryKey","$primaryKey","coordinates","join","objectTypeApiName","$objectType","primaryKeyValue","Object","entries","reduce","promisedAcc","key","structValue","acc","resolve"],"sources":["toDataValue.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type DataValue } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n isAttachmentFile,\n isAttachmentUpload,\n} from \"../object/AttachmentUpload.js\";\nimport { isMediaReference } from \"../object/mediaUpload.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isInterfaceActionParam } from \"./interfaceUtils.js\";\nimport { isObjectSpecifiersObject } from \"./isObjectSpecifiersObject.js\";\nimport { isOntologyObjectV2 } from \"./isOntologyObjectV2.js\";\nimport { isPoint } from \"./isPoint.js\";\nimport { isWireObjectSet } from \"./WireObjectSet.js\";\n\n/**\n * Marshall user-facing data into the wire DataValue type\n *\n * @see DataValue for the expected payloads\n * @internal\n */\nexport async function toDataValue(\n value: unknown,\n client: MinimalClient,\n): Promise<DataValue> {\n if (value == null) {\n // typeof null is 'object' so do this first\n return value;\n }\n\n // arrays and sets are both sent over the wire as arrays\n if (Array.isArray(value) || value instanceof Set) {\n const values = Array.from(value);\n if (\n values.some((dataValue) =>\n isAttachmentUpload(dataValue) || isAttachmentFile(dataValue)\n )\n ) {\n const converted = [];\n for (const value of values) {\n converted.push(await toDataValue(value, client));\n }\n return converted;\n }\n const promiseArray = Array.from(\n value,\n async (innerValue) => await toDataValue(innerValue, client),\n );\n return Promise.all(promiseArray);\n }\n\n // For uploads, we need to upload ourselves first to get the RID of the attachment\n if (isAttachmentUpload(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value.data,\n {\n filename: value.name,\n },\n );\n return await toDataValue(attachment.rid, client);\n }\n\n if (isAttachmentFile(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value,\n {\n filename: value.name as string,\n },\n );\n return await toDataValue(attachment.rid, client);\n }\n\n // objects just send the JSON'd primaryKey\n if (isOntologyObjectV2(value)) {\n return await toDataValue(value.__primaryKey, client);\n }\n\n if (isObjectSpecifiersObject(value)) {\n return await toDataValue(value.$primaryKey, client);\n }\n\n if (isPoint(value)) {\n return await toDataValue(value.coordinates.join(), client);\n }\n\n // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)\n if (isWireObjectSet(value)) {\n return value;\n }\n if (isObjectSet(value)) {\n return getWireObjectSet(value);\n }\n\n if (isMediaReference(value)) {\n return value;\n }\n\n if (isInterfaceActionParam(value)) {\n return {\n objectTypeApiName: value.$objectType,\n primaryKeyValue: value.$primaryKey,\n };\n }\n\n // TODO (during queries implementation)\n // two dimensional aggregation\n // three dimensional aggregation\n\n // struct\n if (typeof value === \"object\") {\n return Object.entries(value).reduce(\n async (promisedAcc, [key, structValue]) => {\n const acc = await promisedAcc;\n acc[key] = await toDataValue(structValue, client);\n return acc;\n },\n Promise.resolve({} as { [key: string]: DataValue }),\n );\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAExD,SACEC,gBAAgB,EAChBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iCAAiC;AAC/E,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,eAAe,QAAQ,oBAAoB;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,WAAWA,CAC/BC,KAAc,EACdC,MAAqB,EACD;EACpB,IAAID,KAAK,IAAI,IAAI,EAAE;IACjB;IACA,OAAOA,KAAK;EACd;;EAEA;EACA,IAAIE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,YAAYI,GAAG,EAAE;IAChD,MAAMC,MAAM,GAAGH,KAAK,CAACI,IAAI,CAACN,KAAK,CAAC;IAChC,IACEK,MAAM,CAACE,IAAI,CAAEC,SAAS,IACpBlB,kBAAkB,CAACkB,SAAS,CAAC,IAAInB,gBAAgB,CAACmB,SAAS,CAC7D,CAAC,EACD;MACA,M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IAClB,OAAO,MAAMD,WAAW,CAACC,KAAK,CAACwB,WAAW,CAACC,IAAI,CAAC,CAAC,EAAExB,MAAM,CAAC;EAC5D;;EAEA;EACA,IAAIH,eAAe,CAACE,KAAK,CAAC,EAAE;IAC1B,OAAOA,KAAK;EACd;EACA,IAAIP,WAAW,CAACO,KAAK,CAAC,EAAE;IACtB,OAAOR,gBAAgB,CAACQ,KAAK,CAAC;EAChC;EAEA,IAAIT,gBAAgB,CAACS,KAAK,CAAC,EAAE;IAC3B,OAAOA,KAAK;EACd;EAEA,IAAIN,sBAAsB,CAACM,KAAK,CAAC,EAAE;IACjC,OAAO;MACL0B,iBAAiB,EAAE1B,KAAK,CAAC2B,WAAW;MACpCC,eAAe,EAAE5B,KAAK,CAACuB;IACzB,CAAC;EACH;;EAEA;EACA;EACA;;EAEA;EACA,IAAI,OAAOvB,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO6B,MAAM,CAACC,OAAO,CAAC9B,KAAK,CAAC,CAAC+B,MAAM,CACjC,OAAOC,WAAW,EAAE,CAACC,GAAG,EAAEC,WAAW,CAAC,KAAK;MACzC,MAAMC,GAAG,GAAG,MAAMH,WAAW;MAC7BG,GAAG,CAACF,GAAG,CAAC,GAAG,MAAMlC,WAAW,CAACmC,WAAW,EAAEjC,MAAM,CAAC;MACjD,OAAOkC,GAAG;IACZ,CAAC,EACDtB,OAAO,CAACuB,OAAO,CAAC,CAAC,CAAiC,CACpD,CAAC;EACH;;EAEA;EACA,OAAOpC,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"file":"toDataValue.js","names":["OntologiesV2","isAttachmentFile","isAttachmentUpload","isMediaReference","getWireObjectSet","isObjectSet","isInterfaceActionParam","isObjectSpecifiersObject","isOntologyObjectV2","isPoint","isWireObjectSet","toDataValue","value","client","Array","isArray","Set","values","from","some","dataValue","converted","push","promiseArray","innerValue","Promise","all","attachment","Attachments","upload","data","filename","name","rid","__primaryKey","$primaryKey","coordinates","objectTypeApiName","$objectType","primaryKeyValue","Object","entries","reduce","promisedAcc","key","structValue","acc","resolve"],"sources":["toDataValue.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type DataValue } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n isAttachmentFile,\n isAttachmentUpload,\n} from \"../object/AttachmentUpload.js\";\nimport { isMediaReference } from \"../object/mediaUpload.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isInterfaceActionParam } from \"./interfaceUtils.js\";\nimport { isObjectSpecifiersObject } from \"./isObjectSpecifiersObject.js\";\nimport { isOntologyObjectV2 } from \"./isOntologyObjectV2.js\";\nimport { isPoint } from \"./isPoint.js\";\nimport { isWireObjectSet } from \"./WireObjectSet.js\";\n\n/**\n * Marshall user-facing data into the wire DataValue type\n *\n * @see DataValue for the expected payloads\n * @internal\n */\nexport async function toDataValue(\n value: unknown,\n client: MinimalClient,\n): Promise<DataValue> {\n if (value == null) {\n // typeof null is 'object' so do this first\n return value;\n }\n\n // arrays and sets are both sent over the wire as arrays\n if (Array.isArray(value) || value instanceof Set) {\n const values = Array.from(value);\n if (\n values.some((dataValue) =>\n isAttachmentUpload(dataValue) || isAttachmentFile(dataValue)\n )\n ) {\n const converted = [];\n for (const value of values) {\n converted.push(await toDataValue(value, client));\n }\n return converted;\n }\n const promiseArray = Array.from(\n value,\n async (innerValue) => await toDataValue(innerValue, client),\n );\n return Promise.all(promiseArray);\n }\n\n // For uploads, we need to upload ourselves first to get the RID of the attachment\n if (isAttachmentUpload(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value.data,\n {\n filename: value.name,\n },\n );\n return await toDataValue(attachment.rid, client);\n }\n\n if (isAttachmentFile(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value,\n {\n filename: value.name as string,\n },\n );\n return await toDataValue(attachment.rid, client);\n }\n\n // objects just send the JSON'd primaryKey\n if (isOntologyObjectV2(value)) {\n return await toDataValue(value.__primaryKey, client);\n }\n\n if (isObjectSpecifiersObject(value)) {\n return await toDataValue(value.$primaryKey, client);\n }\n\n if (isPoint(value)) {\n return await toDataValue(\n `${value.coordinates[1]},${value.coordinates[0]}`,\n client,\n );\n }\n\n // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)\n if (isWireObjectSet(value)) {\n return value;\n }\n if (isObjectSet(value)) {\n return getWireObjectSet(value);\n }\n\n if (isMediaReference(value)) {\n return value;\n }\n\n if (isInterfaceActionParam(value)) {\n return {\n objectTypeApiName: value.$objectType,\n primaryKeyValue: value.$primaryKey,\n };\n }\n\n // TODO (during queries implementation)\n // two dimensional aggregation\n // three dimensional aggregation\n\n // struct\n if (typeof value === \"object\") {\n return Object.entries(value).reduce(\n async (promisedAcc, [key, structValue]) => {\n const acc = await promisedAcc;\n acc[key] = await toDataValue(structValue, client);\n return acc;\n },\n Promise.resolve({} as { [key: string]: DataValue }),\n );\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAExD,SACEC,gBAAgB,EAChBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iC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