@osdk/client 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/build/js/{chunk-TJNTUGSE.mjs → chunk-BQNFWSLL.mjs} +48 -22
  2. package/build/js/chunk-BQNFWSLL.mjs.map +1 -0
  3. package/build/js/{chunk-V77HHGVZ.cjs → chunk-KAL57TC5.cjs} +47 -21
  4. package/build/js/chunk-KAL57TC5.cjs.map +1 -0
  5. package/build/js/index.cjs +32 -14
  6. package/build/js/index.cjs.map +1 -1
  7. package/build/js/index.mjs +28 -10
  8. package/build/js/index.mjs.map +1 -1
  9. package/build/js/public/objects.cjs +3 -3
  10. package/build/js/public/objects.mjs +1 -1
  11. package/build/types/Client.d.ts +3 -3
  12. package/build/types/ObjectSetCreator.d.ts +3 -3
  13. package/build/types/OsdkObjectFrom.d.ts +11 -17
  14. package/build/types/actions/Actions.d.ts +17 -13
  15. package/build/types/actions/applyAction.d.ts +3 -10
  16. package/build/types/actions/createActionInvoker.d.ts +2 -1
  17. package/build/types/definitions/LinkDefinitions.d.ts +12 -13
  18. package/build/types/generatedNoCheck/Ontology.d.ts +13 -477
  19. package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts +22 -10
  20. package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +23 -13
  21. package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +40 -28
  22. package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +46 -34
  23. package/build/types/generatedNoCheck/ontology/actions/index.d.ts +7 -7
  24. package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +40 -28
  25. package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +32 -20
  26. package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +33 -23
  27. package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +20 -25
  28. package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +10 -7
  29. package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +16 -15
  30. package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +10 -7
  31. package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +38 -35
  32. package/build/types/index.d.ts +3 -1
  33. package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts +1 -1
  34. package/build/types/internal/conversions/modernToLegacyAggregationClause.d.ts +1 -2
  35. package/build/types/internal/conversions/modernToLegacyGroupByClause.d.ts +1 -2
  36. package/build/types/object/aggregateOrThrow.d.ts +3 -2
  37. package/build/types/object/fetchPageOrThrow.d.ts +4 -4
  38. package/build/types/object/followLinkOrThrow.d.ts +1 -1
  39. package/build/types/object/getLinkedObjectByPkOrThrow.d.ts +1 -1
  40. package/build/types/object/getLinkedObjectOrThrow.d.ts +5 -2
  41. package/build/types/object/pageLinkedObjectsOrThrow.d.ts +4 -6
  42. package/build/types/objectSet/LinkTypesFrom.d.ts +2 -2
  43. package/build/types/objectSet/ObjectSet.d.ts +13 -11
  44. package/build/types/objectSet/ObjectSet.test.d.ts +1 -0
  45. package/build/types/objectSet/ObjectSetListener.d.ts +7 -7
  46. package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts +2 -2
  47. package/build/types/objectSet/createObjectSet.d.ts +2 -2
  48. package/build/types/query/WhereClause.d.ts +12 -5
  49. package/build/types/query/aggregations/AggregatableKeys.d.ts +3 -3
  50. package/build/types/query/aggregations/AggregateOpts.d.ts +4 -4
  51. package/build/types/query/aggregations/AggregationResultsWithGroups.d.ts +4 -4
  52. package/build/types/query/aggregations/AggregationResultsWithoutGroups.d.ts +5 -5
  53. package/build/types/query/aggregations/AggregationsClause.d.ts +5 -5
  54. package/build/types/query/aggregations/AggregationsClause.test.d.ts +4 -2
  55. package/build/types/query/aggregations/AggregationsResults.d.ts +2 -2
  56. package/build/types/query/aggregations/GroupByClause.d.ts +4 -4
  57. package/build/types/query/aggregations/GroupByClause.test.d.ts +2 -1
  58. package/build/types/util/test/mockOntology.d.ts +50 -48
  59. package/changelog/0.6.0/pr-9.v2.yml +5 -0
  60. package/changelog/0.7.0/pr-20.v2.yml +5 -0
  61. package/changelog/0.7.0/pr-24.v2.yml +5 -0
  62. package/changelog/0.7.0/pr-28.v2.yml +5 -0
  63. package/changelog/0.8.0/pr-30.v2.yml +5 -0
  64. package/changelog/0.9.0/pr-43.v2.yml +5 -0
  65. package/changelog/0.9.0/pr-45.v2.yml +5 -0
  66. package/changelog/0.9.0/pr-48.v2.yml +5 -0
  67. package/changelog/0.9.0/pr-59.v2.yml +5 -0
  68. package/changelog/0.9.0/pr-65.v2.yml +5 -0
  69. package/changelog/0.9.0/pr-72.v2.yml +5 -0
  70. package/changelog/0.9.0/pr-75.v2.yml +5 -0
  71. package/changelog/@unreleased/.gitkeep +0 -0
  72. package/package.json +11 -6
  73. package/build/js/chunk-TJNTUGSE.mjs.map +0 -1
  74. package/build/js/chunk-V77HHGVZ.cjs.map +0 -1
  75. /package/{CHANGELOG.md → CHANGELOG_OLD.md} +0 -0
@@ -1,4 +1,4 @@
1
- import { aggregateObjectsV2, loadObjectSetV2, getLinkedObjectV2, listLinkedObjectsV2 } from '@osdk/gateway/requests';
1
+ import { aggregateObjectSetV2, loadObjectSetV2, getLinkedObjectV2, listLinkedObjectsV2 } from '@osdk/gateway/requests';
2
2
  import { createOpenApiRequest, PalantirApiError } from '@osdk/shared.net';
3
3
  import invariant2 from 'tiny-invariant';
4
4
 
@@ -10,7 +10,7 @@ var __export = (target, all) => {
10
10
  function legacyToModernSingleAggregationResult(entry) {
11
11
  return entry.metrics.reduce((accumulator, curValue) => {
12
12
  const parts = curValue.name.split(".");
13
- !(parts.length == 2) ? process.env.NODE_ENV !== "production" ? invariant2(false, "assumed we were getting a `${key}.${type}`") : invariant2(false) : void 0;
13
+ !(parts.length === 2) ? process.env.NODE_ENV !== "production" ? invariant2(false, "assumed we were getting a `${key}.${type}`") : invariant2(false) : void 0;
14
14
  if (!(parts[0] in accumulator)) {
15
15
  accumulator[parts[0]] = {};
16
16
  }
@@ -114,9 +114,9 @@ function modernToLegacyWhereClause(whereClause) {
114
114
  value: parts.map(handleWherePair)
115
115
  };
116
116
  }
117
- function makeWithinBbox(field, bbox) {
117
+ function makeGeoFilterBbox(field, bbox, filterType) {
118
118
  return {
119
- type: "withinBoundingBox",
119
+ type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
120
120
  field,
121
121
  value: {
122
122
  topLeft: {
@@ -130,6 +130,16 @@ function makeWithinBbox(field, bbox) {
130
130
  }
131
131
  };
132
132
  }
133
+ function makeGeoFilterPolygon(field, coordinates, filterType) {
134
+ return {
135
+ type: filterType,
136
+ field,
137
+ value: {
138
+ type: "Polygon",
139
+ coordinates
140
+ }
141
+ };
142
+ }
133
143
  function handleWherePair([field, filter]) {
134
144
  !(filter != null) ? process.env.NODE_ENV !== "production" ? invariant2(false, "Defined key values are only allowed when they are not undefined.") : invariant2(false) : void 0;
135
145
  if (typeof filter === "string" || typeof filter === "number") {
@@ -139,10 +149,15 @@ function handleWherePair([field, filter]) {
139
149
  value: filter
140
150
  };
141
151
  }
142
- !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2(false, "WhereClause Filter with multiple properties isn't allowed") : invariant2(false) : void 0;
143
- const firstKey = Object.keys(filter)[0];
152
+ const keysOfFilter = Object.keys(filter);
153
+ const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
154
+ !(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2(false, "WhereClause Filter with multiple clauses isn't allowed") : invariant2(false) : void 0;
155
+ if (!hasDollarSign) {
156
+ throw new Error("Unsupported filter. Did you forget to use a $-prefixed filter?");
157
+ }
158
+ const firstKey = keysOfFilter[0];
144
159
  !(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant2(false) : invariant2(false) : void 0;
145
- if (firstKey === "ne") {
160
+ if (firstKey === "$ne") {
146
161
  return {
147
162
  type: "not",
148
163
  value: {
@@ -155,9 +170,9 @@ function handleWherePair([field, filter]) {
155
170
  if (firstKey === "$within") {
156
171
  const withinBody = filter[firstKey];
157
172
  if (Array.isArray(withinBody)) {
158
- return makeWithinBbox(field, withinBody);
173
+ return makeGeoFilterBbox(field, withinBody, firstKey);
159
174
  } else if ("bbox" in withinBody && !("type" in withinBody)) {
160
- return makeWithinBbox(field, withinBody.bbox);
175
+ return makeGeoFilterBbox(field, withinBody.bbox, firstKey);
161
176
  } else if ("distance" in withinBody && "of" in withinBody) {
162
177
  return {
163
178
  type: "withinDistanceOf",
@@ -175,25 +190,32 @@ function handleWherePair([field, filter]) {
175
190
  };
176
191
  } else {
177
192
  const coordinates = "polygon" in withinBody ? withinBody.polygon : withinBody.coordinates;
178
- return {
179
- type: "withinPolygon",
180
- field,
181
- value: {
182
- type: "Polygon",
183
- coordinates
184
- }
185
- };
193
+ return makeGeoFilterPolygon(field, coordinates, "withinPolygon");
194
+ }
195
+ }
196
+ if (firstKey === "$intersects") {
197
+ const intersectsBody = filter[firstKey];
198
+ if (Array.isArray(intersectsBody)) {
199
+ return makeGeoFilterBbox(field, intersectsBody, firstKey);
200
+ } else if ("bbox" in intersectsBody && !("type" in intersectsBody)) {
201
+ return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);
202
+ } else {
203
+ const coordinates = "polygon" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;
204
+ return makeGeoFilterPolygon(field, coordinates, "intersectsPolygon");
186
205
  }
187
206
  }
188
207
  return {
189
- type: firstKey,
208
+ type: firstKey.substring(1),
190
209
  field,
191
210
  value: filter[firstKey]
192
211
  };
193
212
  }
194
213
 
195
214
  // src/object/aggregateOrThrow.ts
196
- async function aggregateOrThrow(clientCtx, objectType, req) {
215
+ async function aggregateOrThrow(clientCtx, objectType, objectSet = {
216
+ type: "base",
217
+ objectType: objectType["apiName"]
218
+ }, req) {
197
219
  const body = {
198
220
  aggregation: modernToLegacyAggregationClause(req.select),
199
221
  groupBy: [],
@@ -205,7 +227,11 @@ async function aggregateOrThrow(clientCtx, objectType, req) {
205
227
  if (req.where) {
206
228
  body.where = modernToLegacyWhereClause(req.where);
207
229
  }
208
- const result = await aggregateObjectsV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, objectType, body);
230
+ const result = await aggregateObjectSetV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {
231
+ objectSet,
232
+ groupBy: body.groupBy,
233
+ aggregation: body.aggregation
234
+ });
209
235
  if (!req.groupBy) {
210
236
  !(result.data.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2(false, "no group by clause should mean only one data result") : invariant2(false) : void 0;
211
237
  return legacyToModernSingleAggregationResult(result.data[0]);
@@ -362,7 +388,7 @@ function convertWireToOsdkObjects(client, objs) {
362
388
  // src/object/fetchPageOrThrow.ts
363
389
  async function fetchPageOrThrow(client, objectType, args, objectSet = {
364
390
  type: "base",
365
- objectType
391
+ objectType: objectType["apiName"]
366
392
  }) {
367
393
  const body = {
368
394
  objectSet,
@@ -390,4 +416,4 @@ __export(object_exports, {
390
416
 
391
417
  export { aggregateOrThrow, convertWireToOsdkObjects, fetchPageOrThrow, isAttachment, modernToLegacyWhereClause, object_exports };
392
418
  //# sourceMappingURL=out.js.map
393
- //# sourceMappingURL=chunk-TJNTUGSE.mjs.map
419
+ //# sourceMappingURL=chunk-BQNFWSLL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/object/aggregateOrThrow.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/query/WhereClause.ts","../../src/object/fetchPageOrThrow.ts","../../src/createCachedOntologyTransform.ts","../../src/object/Attachment.ts","../../src/object/getLinkedObjectByPkOrThrow.ts","../../src/object/getLinkedObjectOrThrow.ts","../../src/object/pageLinkedObjectsOrThrow.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/object/index.ts"],"names":["invariant","createOpenApiRequest"],"mappings":";;;;;;;AAgBA,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,OAAOA,gBAAe;;;ACFtB,OAAO,eAAe;AACf,SAAS,sCAAsC,OAAO;AAC3D,SAAO,MAAM,QAAQ,OAAO,CAAC,aAAa,aAAa;AACrD,UAAM,QAAQ,SAAS,KAAK,MAAM,GAAG;AACrC,MAAE,MAAM,WAAW,KAAK,QAAQ,IAAI,aAAa,eAAe,UAAU,OAAO,4CAA4C,IAAI,UAAU,KAAK,IAAI;AACpJ,QAAI,EAAE,MAAM,CAAC,KAAK,cAAc;AAC9B,kBAAY,MAAM,CAAC,CAAC,IAAI,CAAC;AAAA,IAC3B;AACA,gBAAY,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,SAAS;AAC3C,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;;;ACXO,SAAS,gCAAgC,QAAQ;AACtD,SAAO,OAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM;AAChD,QAAI,MAAM,QAAQ,CAAC,GAAG;AACpB,aAAO,EAAE,IAAI,QAAM;AACjB,eAAO;AAAA,UACL,MAAM;AAAA,UACN,MAAM,GAAG,CAAC,IAAI,EAAE;AAAA,UAChB,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,aAAO,CAAC;AAAA,QACN,MAAM;AAAA;AAAA,QAEN,MAAM,GAAG,CAAC,IAAI,CAAC;AAAA,QACf,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;;;ACnBO,SAAS,4BAA4B,eAAe;AACzD,MAAI,CAAC;AAAe,WAAO,CAAC;AAC5B,SAAO,O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,IACX;AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,EAC3B;AACA,MAAI,MAAM,eAAe;AACvB,SAAK,YAAY,KAAK;AAAA,EACxB;AACA,MAAI,MAAM,YAAY,MAAM;AAC1B,SAAK,WAAW,KAAK;AAAA,EACvB;AACA,QAAM,IAAI,MAAM,gBAAgBA,sBAAqB,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOxCA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { aggregateObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions/index.js\";\nexport async function aggregateOrThrow(clientCtx, objectType, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select),\n groupBy: [],\n where: undefined\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = modernToLegacyWhereClause(req.where);\n }\n const result = await aggregateObjectSetV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation\n });\n if (!req.groupBy) {\n !(result.data.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"no group by clause should mean only one data result\") : invariant(false) : void 0;\n return legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length === 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\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 function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\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 function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { DistanceUnitMapping } from \"../../query/WhereClause.js\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0]);\n }\n return {\n type: \"and\",\n value: parts.map(handleWherePair)\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\" ? \"withinBoundingBox\" : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]]\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]]\n }\n }\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates\n }\n };\n}\nfunction handleWherePair([field, filter]) {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some(key => key.startsWith(\"$\"));\n !(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple clauses isn't allowed\") : invariant(false) : void 0;\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(\"Unsupported filter. Did you forget to use a $-prefixed filter?\");\n }\n const firstKey = keysOfFilter[0];\n !(filter[firstKey] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey]\n }\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n } else if (\"bbox\" in withinBody && !(\"type\" in withinBody)) {\n return makeGeoFilterBbox(field, withinBody.bbox, firstKey);\n } else if (\"distance\" in withinBody && \"of\" in withinBody) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.of) ? {\n type: \"Point\",\n coordinates: withinBody.of\n } : withinBody.of,\n distance: {\n value: withinBody.distance[0],\n unit: DistanceUnitMapping[withinBody.distance[1]]\n }\n }\n };\n } else {\n const coordinates = \"polygon\" in withinBody ? withinBody.polygon : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n } else if (\"bbox\" in intersectsBody && !(\"type\" in intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);\n } else {\n const coordinates = \"polygon\" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey]\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// We need to conditional here to force the union to be distributed\n\nexport const DistanceUnitMapping = {\n \"centimeter\": \"CENTIMETERS\",\n \"centimeters\": \"CENTIMETERS\",\n \"cm\": \"CENTIMETERS\",\n \"meter\": \"METERS\",\n \"meters\": \"METERS\",\n \"m\": \"METERS\",\n \"kilometer\": \"KILOMETERS\",\n \"kilometers\": \"KILOMETERS\",\n \"km\": \"KILOMETERS\",\n \"inch\": \"INCHES\",\n \"inches\": \"INCHES\",\n \"foot\": \"FEET\",\n \"feet\": \"FEET\",\n \"yard\": \"YARDS\",\n \"yards\": \"YARDS\",\n \"mile\": \"MILES\",\n \"miles\": \"MILES\",\n \"nautical_mile\": \"NAUTICAL_MILES\",\n \"nauticalMile\": \"NAUTICAL_MILES\",\n \"nautical miles\": \"NAUTICAL_MILES\"\n};\n\n// FIXME we need to represent all types","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectTypeDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\n };\n}","/*\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 class Attachment {\n constructor(rid) {\n this.rid = rid;\n }\n}\nexport function isAttachment(o) {\n return o instanceof Attachment;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getLinkedObjectV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: select ?? []\n });\n const objects = [object];\n convertWireToOsdkObjects(client, objects);\n return objects[0];\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PalantirApiError } from \"@osdk/shared.net\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nexport async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {\n const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: 1,\n select\n });\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 * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { listLinkedObjectsV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {\n const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: options?.pageSize,\n pageToken: options?.nextPageToken,\n select: options?.select ?? []\n });\n convertWireToOsdkObjects(client, page.data);\n return {\n nextPageToken: page.nextPageToken,\n data: page.data\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createCachedOntologyTransform } from \"../createCachedOntologyTransform.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { getLinkedObjectByPkOrThrow } from \"./getLinkedObjectByPkOrThrow.js\";\nimport { getLinkedObjectOrThrow } from \"./getLinkedObjectOrThrow.js\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nconst getConverter = createCachedOntologyTransform(createConverter);\nconst OriginClient = Symbol();\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n if (!objDef) {\n return proto;\n }\n Object.defineProperty(proto, \"$link\", {\n get: function () {\n const client = this[OriginClient];\n const primaryKey = this[\"__primaryKey\"];\n return new Proxy({}, {\n get(_target, p, _receiver) {\n const linkDef = objDef.links[p];\n if (linkDef == null) {\n return;\n }\n if (!linkDef.multiplicity) {\n return {\n get: options => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)\n };\n } else {\n return {\n get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),\n fetchPageOrThrow: options => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {\n nextPageToken: options?.nextPageToken,\n pageSize: options?.pageSize,\n select: options?.select\n })\n };\n }\n }\n });\n },\n enumerable: false,\n configurable: false\n });\n return proto;\n}\n\n// preprocess the ontology definition to more quickly apply object conversions when needed\nfunction createConverter(ontology, type) {\n const objDef = ontology.objects[type];\n if (!objDef) {\n return false;\n }\n const steps = [];\n for (const [key, value] of Object.entries(objDef.properties)) {\n // attachments need a wrapper to provide functionality and to identify them at serialization time\n if (value.type === \"attachment\") {\n steps.push(o => {\n if (o[key] != null) {\n if (Array.isArray(o[key])) {\n o[key] = o[key].map(a => new Attachment(a.rid));\n } else {\n o[key] = new Attachment(o[key].rid);\n }\n }\n });\n }\n }\n return steps.length > 0 ? o => {\n for (const step of steps) {\n step(o);\n }\n } : false;\n}\n\n/**\n * @param objs the objects to be converted, the contents of this array will be mutated\n */\nexport function convertWireToOsdkObjects(client, objs) {\n for (const obj of objs) {\n const proto = getPrototype(client.ontology, obj.__apiName);\n const converter = getConverter(client.ontology, obj.__apiName);\n Object.setPrototypeOf(obj, proto);\n Object.defineProperty(obj, OriginClient, {\n value: client,\n enumerable: false,\n configurable: false,\n writable: false\n });\n if (converter) {\n converter(obj);\n }\n }\n}","/*\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 { aggregateOrThrow } from \"./aggregateOrThrow.js\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow.js\";"]}
@@ -16,7 +16,7 @@ var __export = (target, all) => {
16
16
  function legacyToModernSingleAggregationResult(entry) {
17
17
  return entry.metrics.reduce((accumulator, curValue) => {
18
18
  const parts = curValue.name.split(".");
19
- !(parts.length == 2) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "assumed we were getting a `${key}.${type}`") : invariant2__default.default(false) : void 0;
19
+ !(parts.length === 2) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "assumed we were getting a `${key}.${type}`") : invariant2__default.default(false) : void 0;
20
20
  if (!(parts[0] in accumulator)) {
21
21
  accumulator[parts[0]] = {};
22
22
  }
@@ -120,9 +120,9 @@ function modernToLegacyWhereClause(whereClause) {
120
120
  value: parts.map(handleWherePair)
121
121
  };
122
122
  }
123
- function makeWithinBbox(field, bbox) {
123
+ function makeGeoFilterBbox(field, bbox, filterType) {
124
124
  return {
125
- type: "withinBoundingBox",
125
+ type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
126
126
  field,
127
127
  value: {
128
128
  topLeft: {
@@ -136,6 +136,16 @@ function makeWithinBbox(field, bbox) {
136
136
  }
137
137
  };
138
138
  }
139
+ function makeGeoFilterPolygon(field, coordinates, filterType) {
140
+ return {
141
+ type: filterType,
142
+ field,
143
+ value: {
144
+ type: "Polygon",
145
+ coordinates
146
+ }
147
+ };
148
+ }
139
149
  function handleWherePair([field, filter]) {
140
150
  !(filter != null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Defined key values are only allowed when they are not undefined.") : invariant2__default.default(false) : void 0;
141
151
  if (typeof filter === "string" || typeof filter === "number") {
@@ -145,10 +155,15 @@ function handleWherePair([field, filter]) {
145
155
  value: filter
146
156
  };
147
157
  }
148
- !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "WhereClause Filter with multiple properties isn't allowed") : invariant2__default.default(false) : void 0;
149
- const firstKey = Object.keys(filter)[0];
158
+ const keysOfFilter = Object.keys(filter);
159
+ const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
160
+ !(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "WhereClause Filter with multiple clauses isn't allowed") : invariant2__default.default(false) : void 0;
161
+ if (!hasDollarSign) {
162
+ throw new Error("Unsupported filter. Did you forget to use a $-prefixed filter?");
163
+ }
164
+ const firstKey = keysOfFilter[0];
150
165
  !(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : void 0;
151
- if (firstKey === "ne") {
166
+ if (firstKey === "$ne") {
152
167
  return {
153
168
  type: "not",
154
169
  value: {
@@ -161,9 +176,9 @@ function handleWherePair([field, filter]) {
161
176
  if (firstKey === "$within") {
162
177
  const withinBody = filter[firstKey];
163
178
  if (Array.isArray(withinBody)) {
164
- return makeWithinBbox(field, withinBody);
179
+ return makeGeoFilterBbox(field, withinBody, firstKey);
165
180
  } else if ("bbox" in withinBody && !("type" in withinBody)) {
166
- return makeWithinBbox(field, withinBody.bbox);
181
+ return makeGeoFilterBbox(field, withinBody.bbox, firstKey);
167
182
  } else if ("distance" in withinBody && "of" in withinBody) {
168
183
  return {
169
184
  type: "withinDistanceOf",
@@ -181,25 +196,32 @@ function handleWherePair([field, filter]) {
181
196
  };
182
197
  } else {
183
198
  const coordinates = "polygon" in withinBody ? withinBody.polygon : withinBody.coordinates;
184
- return {
185
- type: "withinPolygon",
186
- field,
187
- value: {
188
- type: "Polygon",
189
- coordinates
190
- }
191
- };
199
+ return makeGeoFilterPolygon(field, coordinates, "withinPolygon");
200
+ }
201
+ }
202
+ if (firstKey === "$intersects") {
203
+ const intersectsBody = filter[firstKey];
204
+ if (Array.isArray(intersectsBody)) {
205
+ return makeGeoFilterBbox(field, intersectsBody, firstKey);
206
+ } else if ("bbox" in intersectsBody && !("type" in intersectsBody)) {
207
+ return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);
208
+ } else {
209
+ const coordinates = "polygon" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;
210
+ return makeGeoFilterPolygon(field, coordinates, "intersectsPolygon");
192
211
  }
193
212
  }
194
213
  return {
195
- type: firstKey,
214
+ type: firstKey.substring(1),
196
215
  field,
197
216
  value: filter[firstKey]
198
217
  };
199
218
  }
200
219
 
201
220
  // src/object/aggregateOrThrow.ts
202
- async function aggregateOrThrow(clientCtx, objectType, req) {
221
+ async function aggregateOrThrow(clientCtx, objectType, objectSet = {
222
+ type: "base",
223
+ objectType: objectType["apiName"]
224
+ }, req) {
203
225
  const body = {
204
226
  aggregation: modernToLegacyAggregationClause(req.select),
205
227
  groupBy: [],
@@ -211,7 +233,11 @@ async function aggregateOrThrow(clientCtx, objectType, req) {
211
233
  if (req.where) {
212
234
  body.where = modernToLegacyWhereClause(req.where);
213
235
  }
214
- const result = await requests.aggregateObjectsV2(shared_net.createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, objectType, body);
236
+ const result = await requests.aggregateObjectSetV2(shared_net.createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {
237
+ objectSet,
238
+ groupBy: body.groupBy,
239
+ aggregation: body.aggregation
240
+ });
215
241
  if (!req.groupBy) {
216
242
  !(result.data.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "no group by clause should mean only one data result") : invariant2__default.default(false) : void 0;
217
243
  return legacyToModernSingleAggregationResult(result.data[0]);
@@ -368,7 +394,7 @@ function convertWireToOsdkObjects(client, objs) {
368
394
  // src/object/fetchPageOrThrow.ts
369
395
  async function fetchPageOrThrow(client, objectType, args, objectSet = {
370
396
  type: "base",
371
- objectType
397
+ objectType: objectType["apiName"]
372
398
  }) {
373
399
  const body = {
374
400
  objectSet,
@@ -401,4 +427,4 @@ exports.isAttachment = isAttachment;
401
427
  exports.modernToLegacyWhereClause = modernToLegacyWhereClause;
402
428
  exports.object_exports = object_exports;
403
429
  //# sourceMappingURL=out.js.map
404
- //# sourceMappingURL=chunk-V77HHGVZ.cjs.map
430
+ //# sourceMappingURL=chunk-KAL57TC5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/object/aggregateOrThrow.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/query/WhereClause.ts","../../src/object/fetchPageOrThrow.ts","../../src/createCachedOntologyTransform.ts","../../src/object/Attachment.ts","../../src/object/getLinkedObjectByPkOrThrow.ts","../../src/object/getLinkedObjectOrThrow.ts","../../src/object/pageLinkedObjectsOrThrow.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/object/index.ts"],"names":["invariant","createOpenApiRequest"],"mappings":";;;;;;;AAgBA,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,OAAOA,gBAAe;;;ACFtB,OAAO,eAAe;AACf,SAAS,sCAAsC,OAAO;AAC3D,SAAO,MAAM,QAAQ,OAAO,CAAC,aAAa,aAAa;AACrD,UAAM,QAAQ,SAAS,KAAK,MAAM,GAAG;AACrC,MAAE,MAAM,WAAW,KAAK,QAAQ,IAAI,aAAa,eAAe,UAAU,OAAO,4CAA4C,IAAI,UAAU,KAAK,IAAI;AACpJ,QAAI,EAAE,MAAM,CAAC,KAAK,cAAc;AAC9B,kBAAY,MAAM,CAAC,CAAC,IAAI,CAAC;AAAA,IAC3B;AACA,gBAAY,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,SAAS;AAC3C,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;;;ACXO,SAAS,gCAAgC,QAAQ;AACtD,SAAO,OAAO,Q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AAyB,QAAQ,MAAM;AACrD,aAAW,OAAO,MAAM;AACtB,UAAM,QAAQ,aAAa,OAAO,UAAU,IAAI,SAAS;AACzD,UAAM,YAAY,aAAa,OAAO,UAAU,IAAI,SAAS;AAC7D,WAAO,eAAe,KAAK,KAAK;AAChC,WAAO,eAAe,KAAK,cAAc;AAAA,MACvC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AACD,QAAI,WAAW;AACb,gBAAU,GAAG;AAAA,IACf;AAAA,EACF;AACF;;;AN1FA,eAAsB,iBAAiB,QAAQ,YAAY,MAAM,YAAY;AAAA,EAC3E,MAAM;AAAA,EACN,YAAY,WAAW,SAAS;AAClC,GAAG;AACD,QAAM,OAAO;AAAA,IACX;AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,EAC3B;AACA,MAAI,MAAM,eAAe;AACvB,SAAK,YAAY,KAAK;AAAA,EACxB;AACA,MAAI,MAAM,YAAY,MAAM;AAC1B,SAAK,WAAW,KAAK;AAAA,EACvB;AACA,QAAM,IAAI,MAAM,gBAAgBA,sBAAqB,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOxCA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { aggregateObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions/index.js\";\nexport async function aggregateOrThrow(clientCtx, objectType, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select),\n groupBy: [],\n where: undefined\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = modernToLegacyWhereClause(req.where);\n }\n const result = await aggregateObjectSetV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation\n });\n if (!req.groupBy) {\n !(result.data.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"no group by clause should mean only one data result\") : invariant(false) : void 0;\n return legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length === 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\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 function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\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 function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { DistanceUnitMapping } from \"../../query/WhereClause.js\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0]);\n }\n return {\n type: \"and\",\n value: parts.map(handleWherePair)\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\" ? \"withinBoundingBox\" : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]]\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]]\n }\n }\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates\n }\n };\n}\nfunction handleWherePair([field, filter]) {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some(key => key.startsWith(\"$\"));\n !(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple clauses isn't allowed\") : invariant(false) : void 0;\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(\"Unsupported filter. Did you forget to use a $-prefixed filter?\");\n }\n const firstKey = keysOfFilter[0];\n !(filter[firstKey] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey]\n }\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n } else if (\"bbox\" in withinBody && !(\"type\" in withinBody)) {\n return makeGeoFilterBbox(field, withinBody.bbox, firstKey);\n } else if (\"distance\" in withinBody && \"of\" in withinBody) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.of) ? {\n type: \"Point\",\n coordinates: withinBody.of\n } : withinBody.of,\n distance: {\n value: withinBody.distance[0],\n unit: DistanceUnitMapping[withinBody.distance[1]]\n }\n }\n };\n } else {\n const coordinates = \"polygon\" in withinBody ? withinBody.polygon : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n } else if (\"bbox\" in intersectsBody && !(\"type\" in intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);\n } else {\n const coordinates = \"polygon\" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey]\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// We need to conditional here to force the union to be distributed\n\nexport const DistanceUnitMapping = {\n \"centimeter\": \"CENTIMETERS\",\n \"centimeters\": \"CENTIMETERS\",\n \"cm\": \"CENTIMETERS\",\n \"meter\": \"METERS\",\n \"meters\": \"METERS\",\n \"m\": \"METERS\",\n \"kilometer\": \"KILOMETERS\",\n \"kilometers\": \"KILOMETERS\",\n \"km\": \"KILOMETERS\",\n \"inch\": \"INCHES\",\n \"inches\": \"INCHES\",\n \"foot\": \"FEET\",\n \"feet\": \"FEET\",\n \"yard\": \"YARDS\",\n \"yards\": \"YARDS\",\n \"mile\": \"MILES\",\n \"miles\": \"MILES\",\n \"nautical_mile\": \"NAUTICAL_MILES\",\n \"nauticalMile\": \"NAUTICAL_MILES\",\n \"nautical miles\": \"NAUTICAL_MILES\"\n};\n\n// FIXME we need to represent all types","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectTypeDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\n };\n}","/*\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 class Attachment {\n constructor(rid) {\n this.rid = rid;\n }\n}\nexport function isAttachment(o) {\n return o instanceof Attachment;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getLinkedObjectV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: select ?? []\n });\n const objects = [object];\n convertWireToOsdkObjects(client, objects);\n return objects[0];\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PalantirApiError } from \"@osdk/shared.net\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nexport async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {\n const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: 1,\n select\n });\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 * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { listLinkedObjectsV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {\n const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: options?.pageSize,\n pageToken: options?.nextPageToken,\n select: options?.select ?? []\n });\n convertWireToOsdkObjects(client, page.data);\n return {\n nextPageToken: page.nextPageToken,\n data: page.data\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createCachedOntologyTransform } from \"../createCachedOntologyTransform.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { getLinkedObjectByPkOrThrow } from \"./getLinkedObjectByPkOrThrow.js\";\nimport { getLinkedObjectOrThrow } from \"./getLinkedObjectOrThrow.js\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nconst getConverter = createCachedOntologyTransform(createConverter);\nconst OriginClient = Symbol();\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n if (!objDef) {\n return proto;\n }\n Object.defineProperty(proto, \"$link\", {\n get: function () {\n const client = this[OriginClient];\n const primaryKey = this[\"__primaryKey\"];\n return new Proxy({}, {\n get(_target, p, _receiver) {\n const linkDef = objDef.links[p];\n if (linkDef == null) {\n return;\n }\n if (!linkDef.multiplicity) {\n return {\n get: options => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)\n };\n } else {\n return {\n get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),\n fetchPageOrThrow: options => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {\n nextPageToken: options?.nextPageToken,\n pageSize: options?.pageSize,\n select: options?.select\n })\n };\n }\n }\n });\n },\n enumerable: false,\n configurable: false\n });\n return proto;\n}\n\n// preprocess the ontology definition to more quickly apply object conversions when needed\nfunction createConverter(ontology, type) {\n const objDef = ontology.objects[type];\n if (!objDef) {\n return false;\n }\n const steps = [];\n for (const [key, value] of Object.entries(objDef.properties)) {\n // attachments need a wrapper to provide functionality and to identify them at serialization time\n if (value.type === \"attachment\") {\n steps.push(o => {\n if (o[key] != null) {\n if (Array.isArray(o[key])) {\n o[key] = o[key].map(a => new Attachment(a.rid));\n } else {\n o[key] = new Attachment(o[key].rid);\n }\n }\n });\n }\n }\n return steps.length > 0 ? o => {\n for (const step of steps) {\n step(o);\n }\n } : false;\n}\n\n/**\n * @param objs the objects to be converted, the contents of this array will be mutated\n */\nexport function convertWireToOsdkObjects(client, objs) {\n for (const obj of objs) {\n const proto = getPrototype(client.ontology, obj.__apiName);\n const converter = getConverter(client.ontology, obj.__apiName);\n Object.setPrototypeOf(obj, proto);\n Object.defineProperty(obj, OriginClient, {\n value: client,\n enumerable: false,\n configurable: false,\n writable: false\n });\n if (converter) {\n converter(obj);\n }\n }\n}","/*\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 { aggregateOrThrow } from \"./aggregateOrThrow.js\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow.js\";"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkV77HHGVZ_cjs = require('./chunk-V77HHGVZ.cjs');
3
+ var chunkKAL57TC5_cjs = require('./chunk-KAL57TC5.cjs');
4
4
  var shared_net = require('@osdk/shared.net');
5
5
  var requests = require('@osdk/gateway/requests');
6
6
  var WebSocket = require('isomorphic-ws');
@@ -31,7 +31,7 @@ function toDataValue(value) {
31
31
  if (Array.isArray(value) || value instanceof Set) {
32
32
  return Array.from(value, toDataValue);
33
33
  }
34
- if (chunkV77HHGVZ_cjs.isAttachment(value)) {
34
+ if (chunkKAL57TC5_cjs.isAttachment(value)) {
35
35
  return value.rid;
36
36
  }
37
37
  if (isOntologyObjectV2(value)) {
@@ -64,8 +64,8 @@ var ActionValidationError = class extends Error {
64
64
  };
65
65
 
66
66
  // src/actions/applyAction.ts
67
- async function applyAction(client, actionApiName, parameters, options = {}) {
68
- const response = await requests.applyActionV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, actionApiName, {
67
+ async function applyAction(client, action, parameters, options = {}) {
68
+ const response = await requests.applyActionV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, action.apiName, {
69
69
  parameters: remapActionParams(parameters),
70
70
  options: {
71
71
  mode: options?.validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
@@ -98,7 +98,7 @@ function createActionInvoker(client) {
98
98
  get: (_target, p, _receiver) => {
99
99
  if (typeof p === "string") {
100
100
  return function(...args) {
101
- return applyAction(client, p, ...args);
101
+ return applyAction(client, client.ontology.actions[p], ...args);
102
102
  };
103
103
  }
104
104
  return void 0;
@@ -598,7 +598,7 @@ async function convertFoundryToOsdkObjects(client, ctx, objects) {
598
598
  }), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName]]);
599
599
  return convertedObject;
600
600
  }));
601
- chunkV77HHGVZ_cjs.convertWireToOsdkObjects(client, osdkObjects);
601
+ chunkKAL57TC5_cjs.convertWireToOsdkObjects(client, osdkObjects);
602
602
  return osdkObjects;
603
603
  }
604
604
  var objectTypeMapping = /* @__PURE__ */ new WeakMap();
@@ -654,7 +654,7 @@ async function getOntologyPropertyMappingForRid(ctx, ontologyRid, objectRid) {
654
654
  var searchAroundPrefix = "searchAround_";
655
655
  function createObjectSet2(objectType, clientCtx, objectSet = {
656
656
  type: "base",
657
- objectType
657
+ objectType: objectType["apiName"]
658
658
  }) {
659
659
  const base = {
660
660
  definition: objectSet,
@@ -669,13 +669,13 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
669
669
  // throw "TODO";
670
670
  // },
671
671
  aggregateOrThrow: async (req) => {
672
- return chunkV77HHGVZ_cjs.aggregateOrThrow(clientCtx, objectType, req);
672
+ return chunkKAL57TC5_cjs.aggregateOrThrow(clientCtx, objectType, objectSet, req);
673
673
  },
674
674
  // fetchPage: async (args?: { nextPageToken?: string }) => {
675
675
  // throw "TODO";
676
676
  // },
677
677
  fetchPageOrThrow: async (args) => {
678
- return chunkV77HHGVZ_cjs.fetchPageOrThrow(clientCtx, objectType, args ?? {}, objectSet);
678
+ return chunkKAL57TC5_cjs.fetchPageOrThrow(clientCtx, objectType, args ?? {}, objectSet);
679
679
  },
680
680
  // asyncIter: () => {
681
681
  // throw "";
@@ -684,7 +684,7 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
684
684
  return createObjectSet2(objectType, clientCtx, {
685
685
  type: "filter",
686
686
  objectSet,
687
- where: chunkV77HHGVZ_cjs.modernToLegacyWhereClause(clause)
687
+ where: chunkKAL57TC5_cjs.modernToLegacyWhereClause(clause)
688
688
  });
689
689
  },
690
690
  // [Symbol.asyncIterator]: () => {
@@ -693,6 +693,24 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
693
693
  pivotTo: function(type) {
694
694
  return createSearchAround(type)();
695
695
  },
696
+ union: (...objectSets) => {
697
+ return createObjectSet2(objectType, clientCtx, {
698
+ type: "union",
699
+ objectSets: [objectSet, ...objectSets.map((os) => os.definition)]
700
+ });
701
+ },
702
+ intersect: (...objectSets) => {
703
+ return createObjectSet2(objectType, clientCtx, {
704
+ type: "intersect",
705
+ objectSets: [objectSet, ...objectSets.map((os) => os.definition)]
706
+ });
707
+ },
708
+ subtract: (...objectSets) => {
709
+ return createObjectSet2(objectType, clientCtx, {
710
+ type: "subtract",
711
+ objectSets: [objectSet, ...objectSets.map((os) => os.definition)]
712
+ });
713
+ },
696
714
  subscribe(listener) {
697
715
  const instance = ObjectSetListenerWebsocket.getInstance(clientCtx);
698
716
  return instance.subscribe(objectSet, listener);
@@ -741,12 +759,12 @@ function createObjectSetCreator(client, clientContext) {
741
759
  }
742
760
 
743
761
  // src/util/UserAgent.ts
744
- var USER_AGENT = `osdk-client/${"0.8.0"}`;
762
+ var USER_AGENT = `osdk-client/${"0.9.0"}`;
745
763
 
746
764
  // src/createClient.ts
747
765
  function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
748
766
  const clientCtx = shared_net.createClientContext(ontology, stack, tokenProvider, USER_AGENT, fetchFn);
749
- const objectSetFactory = (type) => createObjectSet2(type, clientCtx);
767
+ const objectSetFactory = (type) => createObjectSet2(ontology["objects"][type] ?? ontology["interfaces"]?.[type], clientCtx);
750
768
  const client = Object.defineProperties({}, {
751
769
  objectSet: {
752
770
  get: () => objectSetFactory
@@ -759,7 +777,7 @@ function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
759
777
  },
760
778
  __UNSTABLE_preexistingObjectSet: {
761
779
  get: () => (objectType, rid) => {
762
- return createObjectSet2(objectType, clientCtx, {
780
+ return createObjectSet2(ontology["interfaces"]?.[objectType] ?? ontology["objects"][objectType], clientCtx, {
763
781
  type: "intersect",
764
782
  objectSets: [{
765
783
  type: "base",
@@ -777,7 +795,7 @@ function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
777
795
 
778
796
  Object.defineProperty(exports, 'Objects', {
779
797
  enumerable: true,
780
- get: function () { return chunkV77HHGVZ_cjs.object_exports; }
798
+ get: function () { return chunkKAL57TC5_cjs.object_exports; }
781
799
  });
782
800
  Object.defineProperty(exports, 'createClientContext', {
783
801
  enumerable: true,