@osdk/client 0.4.1 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 05a1d36b: Making list of objects enumerable in 2.0 syntax
8
+
3
9
  ## 0.4.1
4
10
 
5
11
  ### Patch Changes
@@ -300,14 +300,7 @@ function convertWireToOsdkObjects(client, objs) {
300
300
  writable: false
301
301
  });
302
302
  if (converter) {
303
- for (const obj2 of objs) {
304
- Object.setPrototypeOf(obj2, proto);
305
- converter(obj2);
306
- }
307
- } else {
308
- for (const obj2 of objs) {
309
- Object.setPrototypeOf(obj2, proto);
310
- }
303
+ converter(obj);
311
304
  }
312
305
  }
313
306
  }
@@ -343,4 +336,4 @@ __export(object_exports, {
343
336
 
344
337
  export { aggregateOrThrow, convertWireToOsdkObjects, fetchPageOrThrow, modernToLegacyWhereClause, object_exports };
345
338
  //# sourceMappingURL=out.js.map
346
- //# sourceMappingURL=chunk-DVD5PAXO.mjs.map
339
+ //# sourceMappingURL=chunk-2KAHVPSN.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/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,0BAA0B;AACnC,SAAS,4BAA4B;AACrC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E,GAAG;AAAA,UACpC;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO,MAAM,SAAS,IAAI,OAAK;AAC7B,eAAW,QAAQ,OAAO;AACxB,WAAK,CAAC;AAAA,IACR;AAAA,EACF,IAAI;AACN;AAKO,SAAS,yBAAyB,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;;;AN5FA,eAAsB,iBAAiB,QAAQ,YAAY,MAAM,YAAY;AAAA,EAC3E,MAAM;AAAA,EACN;AACF,GAAG;AACD,QAAM,OAAO;AAAA,IACX;AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,EAC3B;AAEA,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;;;AOzCA;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 { aggregateObjectsV2 } 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, 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 // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, objectType, body);\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\";\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 const [field, filter] = parts[0];\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 !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([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 !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\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\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\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\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 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\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: 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 steps = [];\n for (const [key, value] of Object.entries(ontology.objects[type].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\";"]}
@@ -306,14 +306,7 @@ function convertWireToOsdkObjects(client, objs) {
306
306
  writable: false
307
307
  });
308
308
  if (converter) {
309
- for (const obj2 of objs) {
310
- Object.setPrototypeOf(obj2, proto);
311
- converter(obj2);
312
- }
313
- } else {
314
- for (const obj2 of objs) {
315
- Object.setPrototypeOf(obj2, proto);
316
- }
309
+ converter(obj);
317
310
  }
318
311
  }
319
312
  }
@@ -353,4 +346,4 @@ exports.fetchPageOrThrow = fetchPageOrThrow;
353
346
  exports.modernToLegacyWhereClause = modernToLegacyWhereClause;
354
347
  exports.object_exports = object_exports;
355
348
  //# sourceMappingURL=out.js.map
356
- //# sourceMappingURL=chunk-YVZITKIQ.cjs.map
349
+ //# sourceMappingURL=chunk-MCG6J7IR.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/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,0BAA0B;AACnC,SAAS,4BA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GAAG,EAAE,GAAG;AAAA,UACpC;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO,MAAM,SAAS,IAAI,OAAK;AAC7B,eAAW,QAAQ,OAAO;AACxB,WAAK,CAAC;AAAA,IACR;AAAA,EACF,IAAI;AACN;AAKO,SAAS,yBAAyB,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;;;AN5FA,eAAsB,iBAAiB,QAAQ,YAAY,MAAM,YAAY;AAAA,EAC3E,MAAM;AAAA,EACN;AACF,GAAG;AACD,QAAM,OAAO;AAAA,IACX;AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,EAC3B;AAEA,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;;;AOzCA;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 { aggregateObjectsV2 } 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, 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 // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, objectType, body);\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\";\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 const [field, filter] = parts[0];\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 !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([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 !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\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\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\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\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 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\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: 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 steps = [];\n for (const [key, value] of Object.entries(ontology.objects[type].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 chunkYVZITKIQ_cjs = require('./chunk-YVZITKIQ.cjs');
3
+ var chunkMCG6J7IR_cjs = require('./chunk-MCG6J7IR.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');
@@ -527,7 +527,7 @@ async function convertFoundryToOsdkObjects(client, ctx, objects) {
527
527
  }), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName]]);
528
528
  return convertedObject;
529
529
  }));
530
- chunkYVZITKIQ_cjs.convertWireToOsdkObjects(client, osdkObjects);
530
+ chunkMCG6J7IR_cjs.convertWireToOsdkObjects(client, osdkObjects);
531
531
  return osdkObjects;
532
532
  }
533
533
  var objectTypeMapping = /* @__PURE__ */ new WeakMap();
@@ -597,13 +597,13 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
597
597
  // throw "TODO";
598
598
  // },
599
599
  aggregateOrThrow: async (req) => {
600
- return chunkYVZITKIQ_cjs.aggregateOrThrow(clientCtx, objectType, req);
600
+ return chunkMCG6J7IR_cjs.aggregateOrThrow(clientCtx, objectType, req);
601
601
  },
602
602
  // fetchPage: async (args?: { nextPageToken?: string }) => {
603
603
  // throw "TODO";
604
604
  // },
605
605
  fetchPageOrThrow: async (args) => {
606
- return chunkYVZITKIQ_cjs.fetchPageOrThrow(clientCtx, objectType, args ?? {}, objectSet);
606
+ return chunkMCG6J7IR_cjs.fetchPageOrThrow(clientCtx, objectType, args ?? {}, objectSet);
607
607
  },
608
608
  // asyncIter: () => {
609
609
  // throw "";
@@ -612,7 +612,7 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
612
612
  return createObjectSet2(objectType, clientCtx, {
613
613
  type: "filter",
614
614
  objectSet,
615
- where: chunkYVZITKIQ_cjs.modernToLegacyWhereClause(clause)
615
+ where: chunkMCG6J7IR_cjs.modernToLegacyWhereClause(clause)
616
616
  });
617
617
  },
618
618
  // [Symbol.asyncIterator]: () => {
@@ -646,12 +646,24 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
646
646
  }
647
647
 
648
648
  // src/ObjectSetCreator.ts
649
- function createObjectSetCreator(client) {
649
+ function createObjectSetCreator(client, clientContext) {
650
650
  return new Proxy({}, {
651
651
  get: (target, p, receiver) => {
652
652
  if (typeof p === "string")
653
653
  return client.objectSet(p);
654
654
  return void 0;
655
+ },
656
+ ownKeys(target) {
657
+ return Object.keys(clientContext.ontology.objects);
658
+ },
659
+ getOwnPropertyDescriptor(target, p) {
660
+ if (typeof p === "string") {
661
+ return {
662
+ enumerable: clientContext.ontology.objects[p] != null,
663
+ configurable: true,
664
+ value: client.objectSet(p)
665
+ };
666
+ }
655
667
  }
656
668
  });
657
669
  }
@@ -665,7 +677,7 @@ function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
665
677
  get: () => objectSetFactory
666
678
  },
667
679
  objects: {
668
- get: () => createObjectSetCreator(client)
680
+ get: () => createObjectSetCreator(client, clientCtx)
669
681
  },
670
682
  actions: {
671
683
  get: () => createActionInvoker(clientCtx)
@@ -690,7 +702,7 @@ function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
690
702
 
691
703
  Object.defineProperty(exports, 'Objects', {
692
704
  enumerable: true,
693
- get: function () { return chunkYVZITKIQ_cjs.object_exports; }
705
+ get: function () { return chunkMCG6J7IR_cjs.object_exports; }
694
706
  });
695
707
  Object.defineProperty(exports, 'createClientContext', {
696
708
  enumerable: true,