@osdk/client 0.8.0 → 0.10.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 (79) hide show
  1. package/build/js/{chunk-V77HHGVZ.cjs → chunk-MVO52VHK.cjs} +82 -28
  2. package/build/js/chunk-MVO52VHK.cjs.map +1 -0
  3. package/build/js/{chunk-TJNTUGSE.mjs → chunk-XI2O777X.mjs} +83 -29
  4. package/build/js/chunk-XI2O777X.mjs.map +1 -0
  5. package/build/js/index.cjs +33 -15
  6. package/build/js/index.cjs.map +1 -1
  7. package/build/js/index.mjs +29 -11
  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/OsdkObject.d.ts +1 -1
  14. package/build/types/OsdkObjectFrom.d.ts +18 -23
  15. package/build/types/actions/Actions.d.ts +17 -13
  16. package/build/types/actions/applyAction.d.ts +3 -10
  17. package/build/types/actions/createActionInvoker.d.ts +2 -1
  18. package/build/types/definitions/LinkDefinitions.d.ts +12 -13
  19. package/build/types/generatedNoCheck/Ontology.d.ts +13 -477
  20. package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts +22 -10
  21. package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +23 -13
  22. package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +40 -28
  23. package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +46 -34
  24. package/build/types/generatedNoCheck/ontology/actions/index.d.ts +7 -7
  25. package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +40 -28
  26. package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +32 -20
  27. package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +33 -23
  28. package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +20 -25
  29. package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +10 -7
  30. package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +16 -15
  31. package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +10 -7
  32. package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +38 -35
  33. package/build/types/index.d.ts +3 -1
  34. package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts +1 -1
  35. package/build/types/internal/conversions/modernToLegacyAggregationClause.d.ts +1 -2
  36. package/build/types/internal/conversions/modernToLegacyGroupByClause.d.ts +1 -2
  37. package/build/types/object/aggregateOrThrow.d.ts +3 -2
  38. package/build/types/object/fetchPageOrThrow.d.ts +10 -4
  39. package/build/types/object/getLinkedObjectByPkOrThrow.d.ts +3 -2
  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 +5 -6
  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.10.0/pr-74.v2.yml +5 -0
  60. package/changelog/0.10.0/pr-78.v2.yml +5 -0
  61. package/changelog/0.10.0/pr-79.v2.yml +5 -0
  62. package/changelog/0.6.0/pr-9.v2.yml +5 -0
  63. package/changelog/0.7.0/pr-20.v2.yml +5 -0
  64. package/changelog/0.7.0/pr-24.v2.yml +5 -0
  65. package/changelog/0.7.0/pr-28.v2.yml +5 -0
  66. package/changelog/0.8.0/pr-30.v2.yml +5 -0
  67. package/changelog/0.9.0/pr-43.v2.yml +5 -0
  68. package/changelog/0.9.0/pr-45.v2.yml +5 -0
  69. package/changelog/0.9.0/pr-48.v2.yml +5 -0
  70. package/changelog/0.9.0/pr-59.v2.yml +5 -0
  71. package/changelog/0.9.0/pr-65.v2.yml +5 -0
  72. package/changelog/0.9.0/pr-72.v2.yml +5 -0
  73. package/changelog/0.9.0/pr-75.v2.yml +5 -0
  74. package/changelog/@unreleased/.gitkeep +0 -0
  75. package/package.json +11 -6
  76. package/build/js/chunk-TJNTUGSE.mjs.map +0 -1
  77. package/build/js/chunk-V77HHGVZ.cjs.map +0 -1
  78. package/build/types/object/followLinkOrThrow.d.ts +0 -5
  79. /package/{CHANGELOG.md → CHANGELOG_OLD.md} +0 -0
@@ -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,15 +233,19 @@ 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]);
218
244
  }
219
245
  const ret = result.data.map((entry) => {
220
246
  return {
221
- group: entry.group,
222
- values: legacyToModernSingleAggregationResult(entry)
247
+ $group: entry.group,
248
+ ...legacyToModernSingleAggregationResult(entry)
223
249
  };
224
250
  });
225
251
  return ret;
@@ -248,9 +274,10 @@ var Attachment = class {
248
274
  function isAttachment(o) {
249
275
  return o instanceof Attachment;
250
276
  }
251
- async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {
277
+ async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, options) {
252
278
  const object = await requests.getLinkedObjectV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {
253
- select: select ?? []
279
+ select: options?.select ?? [],
280
+ excludeRid: !options?.includeRid
254
281
  });
255
282
  const objects = [object];
256
283
  convertWireToOsdkObjects(client, objects);
@@ -260,7 +287,8 @@ async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkT
260
287
  const page = await requests.listLinkedObjectsV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {
261
288
  pageSize: options?.pageSize,
262
289
  pageToken: options?.nextPageToken,
263
- select: options?.select ?? []
290
+ select: options?.select ?? [],
291
+ excludeRid: !options?.includeRid
264
292
  });
265
293
  convertWireToOsdkObjects(client, page.data);
266
294
  return {
@@ -307,7 +335,7 @@ function createPrototype(ontology, type) {
307
335
  };
308
336
  } else {
309
337
  return {
310
- get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),
338
+ get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options),
311
339
  fetchPageOrThrow: (options) => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {
312
340
  nextPageToken: options?.nextPageToken,
313
341
  pageSize: options?.pageSize,
@@ -350,6 +378,23 @@ function createConverter(ontology, type) {
350
378
  }
351
379
  function convertWireToOsdkObjects(client, objs) {
352
380
  for (const obj of objs) {
381
+ if (obj.__rid) {
382
+ obj.$rid = obj.__rid;
383
+ delete obj.__rid;
384
+ }
385
+ obj.$apiName = obj.__apiName;
386
+ obj.$objectType = obj.__apiName;
387
+ obj.$primaryKey = obj.__primaryKey;
388
+ {
389
+ Object.defineProperties(obj, {
390
+ "__apiName": {
391
+ enumerable: false
392
+ },
393
+ "__primaryKey": {
394
+ enumerable: false
395
+ }
396
+ });
397
+ }
353
398
  const proto = getPrototype(client.ontology, obj.__apiName);
354
399
  const converter = getConverter(client.ontology, obj.__apiName);
355
400
  Object.setPrototypeOf(obj, proto);
@@ -368,13 +413,14 @@ function convertWireToOsdkObjects(client, objs) {
368
413
  // src/object/fetchPageOrThrow.ts
369
414
  async function fetchPageOrThrow(client, objectType, args, objectSet = {
370
415
  type: "base",
371
- objectType
416
+ objectType: objectType["apiName"]
372
417
  }) {
373
418
  const body = {
374
419
  objectSet,
375
420
  // We have to do the following case because LoadObjectSetRequestV2 isnt readonly
376
- select: args?.select ?? []
421
+ select: args?.select ?? [],
377
422
  // FIXME?
423
+ excludeRid: !args?.includeRid
378
424
  };
379
425
  if (args?.nextPageToken) {
380
426
  body.pageToken = args.nextPageToken;
@@ -382,6 +428,14 @@ async function fetchPageOrThrow(client, objectType, args, objectSet = {
382
428
  if (args?.pageSize != null) {
383
429
  body.pageSize = args.pageSize;
384
430
  }
431
+ if (args?.orderBy != null) {
432
+ body.orderBy = {
433
+ fields: Object.entries(args.orderBy).map(([field, direction]) => ({
434
+ field,
435
+ direction
436
+ }))
437
+ };
438
+ }
385
439
  const r = await requests.loadObjectSetV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);
386
440
  convertWireToOsdkObjects(client, r.data);
387
441
  return r;
@@ -401,4 +455,4 @@ exports.isAttachment = isAttachment;
401
455
  exports.modernToLegacyWhereClause = modernToLegacyWhereClause;
402
456
  exports.object_exports = object_exports;
403
457
  //# sourceMappingURL=out.js.map
404
- //# sourceMappingURL=chunk-V77HHGVZ.cjs.map
458
+ //# sourceMappingURL=chunk-MVO52VHK.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;;;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,CAAC;AACD,QAAI,WAAW;AACb,gBAAU,GAAG;AAAA,IACf;AAAA,EACF;AACF;;;AN1HA,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,IAEzB,YAAY,CAAC,MAAM;AAAA,EACrB;AACA,MAAI,MAAM,eAAe;AACvB,SAAK,YAAY,KAAK;AAAA,EACxB;AACA,MAAI,MAAM,YAAY,MAAM;AAC1B,SAAK,WAAW,KAAK;AAAA,EACvB;AACA,MAAI,MAAM,WAAW,MAAM;AACzB,SAAK,UAAU;AAAA,MACb,QAAQ,OAAO,QAAQ,KAAK,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,SAAS,OAAO;AAAA,QAChE;AAAA,QACA;AAAA,MACF,EAAE;AAAA,IACJ;AAAA,EACF;AACA,QAAM,IAAI,MAAM,gBAAgBA,sBAAqB,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOlDA;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 ...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 ?? [],\n // FIXME?\n excludeRid: !args?.includeRid\n };\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n if (args?.orderBy != null) {\n body.orderBy = {\n fields: Object.entries(args.orderBy).map(([field, direction]) => ({\n field,\n direction\n }))\n };\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, options) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: options?.select ?? [],\n excludeRid: !options?.includeRid\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 excludeRid: !options?.includeRid\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),\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}\nconst isAfterFeb2024OrNewApis = false;\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 if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName = obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.__apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey = obj.__primaryKey;\n\n // After Feb 2024 (unless we have new apis):\n if (isAfterFeb2024OrNewApis) {\n delete obj.__apiName;\n delete obj.__primaryKey;\n } else {\n // Hide these from things like `console.log` so that people\n // don't think to use them.\n Object.defineProperties(obj, {\n \"__apiName\": {\n enumerable: false\n },\n \"__primaryKey\": {\n enumerable: false\n }\n });\n }\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,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,15 +227,19 @@ 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]);
212
238
  }
213
239
  const ret = result.data.map((entry) => {
214
240
  return {
215
- group: entry.group,
216
- values: legacyToModernSingleAggregationResult(entry)
241
+ $group: entry.group,
242
+ ...legacyToModernSingleAggregationResult(entry)
217
243
  };
218
244
  });
219
245
  return ret;
@@ -242,9 +268,10 @@ var Attachment = class {
242
268
  function isAttachment(o) {
243
269
  return o instanceof Attachment;
244
270
  }
245
- async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {
271
+ async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, options) {
246
272
  const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {
247
- select: select ?? []
273
+ select: options?.select ?? [],
274
+ excludeRid: !options?.includeRid
248
275
  });
249
276
  const objects = [object];
250
277
  convertWireToOsdkObjects(client, objects);
@@ -254,7 +281,8 @@ async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkT
254
281
  const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {
255
282
  pageSize: options?.pageSize,
256
283
  pageToken: options?.nextPageToken,
257
- select: options?.select ?? []
284
+ select: options?.select ?? [],
285
+ excludeRid: !options?.includeRid
258
286
  });
259
287
  convertWireToOsdkObjects(client, page.data);
260
288
  return {
@@ -301,7 +329,7 @@ function createPrototype(ontology, type) {
301
329
  };
302
330
  } else {
303
331
  return {
304
- get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),
332
+ get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options),
305
333
  fetchPageOrThrow: (options) => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {
306
334
  nextPageToken: options?.nextPageToken,
307
335
  pageSize: options?.pageSize,
@@ -344,6 +372,23 @@ function createConverter(ontology, type) {
344
372
  }
345
373
  function convertWireToOsdkObjects(client, objs) {
346
374
  for (const obj of objs) {
375
+ if (obj.__rid) {
376
+ obj.$rid = obj.__rid;
377
+ delete obj.__rid;
378
+ }
379
+ obj.$apiName = obj.__apiName;
380
+ obj.$objectType = obj.__apiName;
381
+ obj.$primaryKey = obj.__primaryKey;
382
+ {
383
+ Object.defineProperties(obj, {
384
+ "__apiName": {
385
+ enumerable: false
386
+ },
387
+ "__primaryKey": {
388
+ enumerable: false
389
+ }
390
+ });
391
+ }
347
392
  const proto = getPrototype(client.ontology, obj.__apiName);
348
393
  const converter = getConverter(client.ontology, obj.__apiName);
349
394
  Object.setPrototypeOf(obj, proto);
@@ -362,13 +407,14 @@ function convertWireToOsdkObjects(client, objs) {
362
407
  // src/object/fetchPageOrThrow.ts
363
408
  async function fetchPageOrThrow(client, objectType, args, objectSet = {
364
409
  type: "base",
365
- objectType
410
+ objectType: objectType["apiName"]
366
411
  }) {
367
412
  const body = {
368
413
  objectSet,
369
414
  // We have to do the following case because LoadObjectSetRequestV2 isnt readonly
370
- select: args?.select ?? []
415
+ select: args?.select ?? [],
371
416
  // FIXME?
417
+ excludeRid: !args?.includeRid
372
418
  };
373
419
  if (args?.nextPageToken) {
374
420
  body.pageToken = args.nextPageToken;
@@ -376,6 +422,14 @@ async function fetchPageOrThrow(client, objectType, args, objectSet = {
376
422
  if (args?.pageSize != null) {
377
423
  body.pageSize = args.pageSize;
378
424
  }
425
+ if (args?.orderBy != null) {
426
+ body.orderBy = {
427
+ fields: Object.entries(args.orderBy).map(([field, direction]) => ({
428
+ field,
429
+ direction
430
+ }))
431
+ };
432
+ }
379
433
  const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);
380
434
  convertWireToOsdkObjects(client, r.data);
381
435
  return r;
@@ -390,4 +444,4 @@ __export(object_exports, {
390
444
 
391
445
  export { aggregateOrThrow, convertWireToOsdkObjects, fetchPageOrThrow, isAttachment, modernToLegacyWhereClause, object_exports };
392
446
  //# sourceMappingURL=out.js.map
393
- //# sourceMappingURL=chunk-TJNTUGSE.mjs.map
447
+ //# sourceMappingURL=chunk-XI2O777X.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;A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AiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOlDA;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 ...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 ?? [],\n // FIXME?\n excludeRid: !args?.includeRid\n };\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n if (args?.orderBy != null) {\n body.orderBy = {\n fields: Object.entries(args.orderBy).map(([field, direction]) => ({\n field,\n direction\n }))\n };\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, options) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: options?.select ?? [],\n excludeRid: !options?.includeRid\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 excludeRid: !options?.includeRid\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),\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}\nconst isAfterFeb2024OrNewApis = false;\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 if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName = obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.__apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey = obj.__primaryKey;\n\n // After Feb 2024 (unless we have new apis):\n if (isAfterFeb2024OrNewApis) {\n delete obj.__apiName;\n delete obj.__primaryKey;\n } else {\n // Hide these from things like `console.log` so that people\n // don't think to use them.\n Object.defineProperties(obj, {\n \"__apiName\": {\n enumerable: false\n },\n \"__primaryKey\": {\n enumerable: false\n }\n });\n }\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\";"]}