@osdk/api 0.0.3 → 0.0.4

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/api
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 8790640: Adds generated types, errors, and requests for public api endpoints
8
+
3
9
  ## 0.0.3
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var a = require('tiny-invariant');
4
+ var requests = require('@osdk/gateway/requests');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var a__default = /*#__PURE__*/_interopDefault(a);
9
+
10
+ var E=Object.defineProperty;var $=(o,r)=>{for(var e in r)E(o,e,{get:r[e],enumerable:!0});};function g(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"assumed we were getting a `${key}.${type}`"):a__default.default(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function y(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function m(o){return o?Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(o){if("$and"in o)return {type:"and",value:o.$and.map(p)};if("$or"in o)return {type:"or",value:o.$or.map(p)};if("$not"in o)return {type:"not",value:p(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}function u(o,r,e="/api"){return async function(n,l,s,b,A,h,v){let d=new URL(`${e}${l}`,j(o));for(let[f,i]of Object.entries(b||{}))if(Array.isArray(i))for(let w of i)d.searchParams.append(f,w);else d.searchParams.append(f,i);let c=new Headers;return h!=null&&c.set("Content-Type",h),v!=null&&c.set("Accept",v),Object.entries(A||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());}),(await r(d.toString(),{body:JSON.stringify(s),method:n,headers:c})).json()}}function j(o){let r=/^https?:\/\//i,e="https://";return r.test(o)?o.replace(/^http:\/\//i,e):`${e}${o}`}async function N(o,r,e){let t={aggregation:y(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=m(e.groupBy)),e.where&&(t.where=p(e.where));let n=await requests.aggregateObjectsV2(u(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(s=>({group:s.group,values:g(s)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"no group by clause should mean only one data result"):a__default.default(!1)),g(n.data[0]))}async function T(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let l=await requests.loadObjectSetV2(u(o.stack,o.fetchJson),o.ontology.metadata.ontologyApiName,n);return {data:l.data.map(s=>({...s,__name:r})),nextPageToken:l.nextPageToken}}var D={};$(D,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
11
+
12
+ exports.a = p;
13
+ exports.b = N;
14
+ exports.c = T;
15
+ exports.d = D;
16
+ //# sourceMappingURL=out.js.map
17
+ //# sourceMappingURL=chunk-I3UIWCJ4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","createOpenApiRequest","basePath","fetchFn","contextPath","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","protocolRegex","httpsProtocol","aggregateObjectsV2","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,E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,EAA4B+B,EAAI,OAAO,GAEpDA,EAAI,QACNC,EAAK,MAAQ5B,EAA0B2B,EAAI,KAAK,GAKlD,IAAME,EAAS,MAAMN,EAAmBnB,EAAqBqB,EAAW,MAAOA,EAAW,KAAK,EAAGA,EAAW,SAAS,SAAS,gBAAiBC,EAAYE,CAAI,EAChK,OAAKD,EAAI,QAIGE,EAAO,KAAK,IAAI1C,IACnB,CACL,MAAOA,EAAM,MACb,OAAQD,EAAsCC,CAAK,CACrD,EACD,GARG0C,EAAO,KAAK,SAAW,IAAK,QAAQ,IAAI,WAAa,aAAe5C,EAAU,GAAO,qDAAqD,EAAIA,EAAU,EAAK,GACxJC,EAAsC2C,EAAO,KAAK,CAAC,CAAC,EAU/D,CC/BA,OAAS,mBAAAC,MAAuB,yBAChC,eAAsBC,EAAiBC,EAAQN,EAAYO,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAAR,CACF,EAAG,CACD,IAAME,EAAO,CACX,UAAAM,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRL,EAAK,UAAYK,EAAK,eAExB,IAAME,EAAI,MAAML,EAAgB1B,EAAqB4B,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBJ,CAAI,EACpI,MAAO,CACL,KAAMO,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQV,CACV,EAAE,EACF,cAAeS,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAb,EAAA,qBAAAO","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 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\nexport default function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\") {\n return async function openApiRequest(method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {\n const url = new URL(`${contextPath}${endpointPath}`, withHttps(basePath));\n for (const [key, value] of Object.entries(queryArguments || {})) {\n if (Array.isArray(value)) {\n for (const item of value) {\n url.searchParams.append(key, item);\n }\n } else {\n url.searchParams.append(key, value);\n }\n }\n const headersInit = new Headers();\n if (requestMediaType != null) {\n headersInit.set(\"Content-Type\", requestMediaType);\n }\n if (responseMediaType != null) {\n headersInit.set(\"Accept\", responseMediaType);\n }\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const response = await fetchFn(url.toString(), {\n body: JSON.stringify(data),\n method: method,\n headers: headersInit\n });\n return response.json();\n };\n}\nfunction withHttps(url) {\n const protocolRegex = /^https?:\\/\\//i;\n const httpsProtocol = \"https://\";\n return protocolRegex.test(url) ? url.replace(/^http:\\/\\//i, httpsProtocol) : `${httpsProtocol}${url}`;\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 { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { createOpenApiRequest } from \"#net\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, 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(thinClient.stack, thinClient.fetch), thinClient.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 { createOpenApiRequest } from \"#net\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\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 const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetchJson), client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\n nextPageToken: r.nextPageToken\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\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
@@ -0,0 +1,8 @@
1
+ import a from 'tiny-invariant';
2
+ import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
3
+
4
+ var E=Object.defineProperty;var $=(o,r)=>{for(var e in r)E(o,e,{get:r[e],enumerable:!0});};function g(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a(!1,"assumed we were getting a `${key}.${type}`"):a(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function y(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function m(o){return o?Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(o){if("$and"in o)return {type:"and",value:o.$and.map(p)};if("$or"in o)return {type:"or",value:o.$or.map(p)};if("$not"in o)return {type:"not",value:p(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a(!1,"Defined key values are only allowed when they are not undefined."):a(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a(!1,"Defined key values are only allowed when they are not undefined."):a(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}function u(o,r,e="/api"){return async function(n,l,s,b,A,h,v){let d=new URL(`${e}${l}`,j(o));for(let[f,i]of Object.entries(b||{}))if(Array.isArray(i))for(let w of i)d.searchParams.append(f,w);else d.searchParams.append(f,i);let c=new Headers;return h!=null&&c.set("Content-Type",h),v!=null&&c.set("Accept",v),Object.entries(A||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());}),(await r(d.toString(),{body:JSON.stringify(s),method:n,headers:c})).json()}}function j(o){let r=/^https?:\/\//i,e="https://";return r.test(o)?o.replace(/^http:\/\//i,e):`${e}${o}`}async function N(o,r,e){let t={aggregation:y(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=m(e.groupBy)),e.where&&(t.where=p(e.where));let n=await aggregateObjectsV2(u(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(s=>({group:s.group,values:g(s)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"no group by clause should mean only one data result"):a(!1)),g(n.data[0]))}async function T(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let l=await loadObjectSetV2(u(o.stack,o.fetchJson),o.ontology.metadata.ontologyApiName,n);return {data:l.data.map(s=>({...s,__name:r})),nextPageToken:l.nextPageToken}}var D={};$(D,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
5
+
6
+ export { p as a, N as b, T as c, D as d };
7
+ //# sourceMappingURL=out.js.map
8
+ //# sourceMappingURL=chunk-II7ELH2S.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","createOpenApiRequest","basePath","fetchFn","contextPath","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","protocolRegex","httpsProtocol","aggregateObjectsV2","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,EAAYE,EAAM,CAAC,CAAC,EAAI,CAAC,GAE3BF,EAAYE,EAAM,CAAC,CAAC,EAAEA,EAAM,CAAC,CAAC,EAAID,EAAS,MACpCD,CACT,EAAG,CAAC,CAAC,CACP,CCXO,SAASG,EAAgCC,EAAQ,CACtD,OAAO,OAAO,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,EAAGC,CAAC,IACtC,MAAM,QAAQA,CAAC,EACVA,EAAE,IAAIC,IACJ,CACL,KAAMA,EACN,KAAM,GAAGF,CAAC,IAAIE,CAAE,GAChB,MAAOF,CACT,EACD,EAEM,CAAC,CACN,KAAMC,EAEN,KAAM,GAAGD,CAAC,IAAIC,CAAC,GACf,MAAOD,CACT,CAAC,CAEJ,CACH,CCnBO,SAASG,EAA4BC,EAAe,CACzD,OAAKA,EACE,OAAO,QAAQA,CAAa,EAAE,QAAQ,CAAC,CAACC,EAAOC,CAAI,IACpDA,IAAS,QACJ,CAAC,CACN,KAAAA,EACA,MAAAD,CACF,CAAC,EACQC,EAAK,eACP,CAAC,CACN,KAAM,QACN,MAAAD,E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K,EAAK,eAExB,IAAME,EAAI,MAAML,EAAgB1B,EAAqB4B,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBJ,CAAI,EACpI,MAAO,CACL,KAAMO,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQV,CACV,EAAE,EACF,cAAeS,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAb,EAAA,qBAAAO","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 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\nexport default function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\") {\n return async function openApiRequest(method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {\n const url = new URL(`${contextPath}${endpointPath}`, withHttps(basePath));\n for (const [key, value] of Object.entries(queryArguments || {})) {\n if (Array.isArray(value)) {\n for (const item of value) {\n url.searchParams.append(key, item);\n }\n } else {\n url.searchParams.append(key, value);\n }\n }\n const headersInit = new Headers();\n if (requestMediaType != null) {\n headersInit.set(\"Content-Type\", requestMediaType);\n }\n if (responseMediaType != null) {\n headersInit.set(\"Accept\", responseMediaType);\n }\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const response = await fetchFn(url.toString(), {\n body: JSON.stringify(data),\n method: method,\n headers: headersInit\n });\n return response.json();\n };\n}\nfunction withHttps(url) {\n const protocolRegex = /^https?:\\/\\//i;\n const httpsProtocol = \"https://\";\n return protocolRegex.test(url) ? url.replace(/^http:\\/\\//i, httpsProtocol) : `${httpsProtocol}${url}`;\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 { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { createOpenApiRequest } from \"#net\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, 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(thinClient.stack, thinClient.fetch), thinClient.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 { createOpenApiRequest } from \"#net\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\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 const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetchJson), client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\n nextPageToken: r.nextPageToken\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\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
package/build/js/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkLS6HVQGV_js = require('./chunk-LS6HVQGV.js');
3
+ var chunkI3UIWCJ4_js = require('./chunk-I3UIWCJ4.js');
4
4
  var b = require('fetch-retry');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
 
8
8
  var b__default = /*#__PURE__*/_interopDefault(b);
9
9
 
10
- function u(r=fetch,e){return async function(t,o){return o?r(t,{...o,headers:await e(new Headers(o.headers))}):r(t,{headers:await e(new Headers)})}}var i=class extends Error{constructor(e,n,t,o,a,c){super(e),this.message=e,this.errorName=n,this.errorType=t,this.statusCode=o,this.errorInstanceId=a,this.parameters=c;}};var f=class extends i{constructor(e,n,t){super(e,n),this.originalError=t;}};function m(r=fetch){return async function(n,t){let o;try{o=await r(n,t);}catch(a){throw l(a,"A network error occured")}if(!o.ok){let a;try{a=await o.json();}catch(c){throw l(c,"A network error occured while reading response")}throw new i(a?.message??`Failed to fetch ${o.status} ${o.statusText}`,a?.errorName,a?.errorCode,o.status,a?.errorInstanceId,a?.parameters)}return o}}function l(r,e="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(e,"UNKNOWN")}var N=1e3,R=.5,I=3;function d(r){return b__default.default(r,{retryDelay(e){let n=N*2**e,t=n*R*(Math.random()*2-1);return n+t},retryOn(e,n,t){let o=t?.status??0;return !(o>=200&&o<300)&&j(n)&&e<I}})}function j(r){return !(r instanceof i&&r.statusCode!==k&&r.statusCode!==P)}var k=503,P=429;function y(r){return r!=null?JSON.stringify(r):void 0}function w(r=fetch){return r=u(r,e=>(e.set("Content-Type","application/json"),e)),async function(n,t){return (await r(n,{...t,body:y(t.body)})).json()}}function h(r,e,n,t=fetch){let o=u(d(m(t)),async a=>{let c=await n();return a.set("Authorization",`Bearer ${c}`),a.set("Fetch-User-Agent",r.metadata.userAgent),a});return {ontology:r,stack:e,fetch:o,fetchJson:w(o)}}var T="searchAround_";function p(r,e,n,t={type:"base",objectType:r}){let o={aggregate:c=>{throw "TODO"},aggregateOrThrow:async c=>chunkLS6HVQGV_js.b(e,r,c),fetchPage:async c=>{throw "TODO"},fetchPageOrThrow:async c=>chunkLS6HVQGV_js.c(e,r,c??{},t),asyncIter:()=>{throw ""},where:c=>p(r,e,n,{type:"filter",objectSet:t,where:chunkLS6HVQGV_js.a(c)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(c,s){return a(c)().where(s?.$where??{})}};function a(c){return ()=>p(r,e,{},{type:"searchAround",objectSet:t,link:c})}return new Proxy(o,{get(c,s,g){return typeof s=="string"&&s.startsWith(T)?a(s.substring(T.length)):c[s]}})}function F(r){return new Proxy({},{get:(e,n,t)=>{if(typeof n=="string")return r.objectSet(n)}})}function C(r,e,n,t=fetch){let o=h(r,e,n,t),a=(s,g)=>p(s,o,g),c=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>F(c)}});return c}function E(r){return r.type==="ok"}
10
+ function u(r=fetch,e){return async function(t,o){return o?r(t,{...o,headers:await e(new Headers(o.headers))}):r(t,{headers:await e(new Headers)})}}var i=class extends Error{constructor(e,n,t,o,a,c){super(e),this.message=e,this.errorName=n,this.errorType=t,this.statusCode=o,this.errorInstanceId=a,this.parameters=c;}};var f=class extends i{constructor(e,n,t){super(e,n),this.originalError=t;}};function m(r=fetch){return async function(n,t){let o;try{o=await r(n,t);}catch(a){throw l(a,"A network error occured")}if(!o.ok){let a;try{a=await o.json();}catch(c){throw l(c,"A network error occured while reading response")}throw new i(a?.message??`Failed to fetch ${o.status} ${o.statusText}`,a?.errorName,a?.errorCode,o.status,a?.errorInstanceId,a?.parameters)}return o}}function l(r,e="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(e,"UNKNOWN")}var N=1e3,R=.5,I=3;function d(r){return b__default.default(r,{retryDelay(e){let n=N*2**e,t=n*R*(Math.random()*2-1);return n+t},retryOn(e,n,t){let o=t?.status??0;return !(o>=200&&o<300)&&j(n)&&e<I}})}function j(r){return !(r instanceof i&&r.statusCode!==k&&r.statusCode!==P)}var k=503,P=429;function y(r){return r!=null?JSON.stringify(r):void 0}function w(r=fetch){return r=u(r,e=>(e.set("Content-Type","application/json"),e)),async function(n,t){return (await r(n,{...t,body:y(t.body)})).json()}}function h(r,e,n,t=fetch){let o=u(d(m(t)),async a=>{let c=await n();return a.set("Authorization",`Bearer ${c}`),a.set("Fetch-User-Agent",r.metadata.userAgent),a});return {ontology:r,stack:e,fetch:o,fetchJson:w(o)}}var T="searchAround_";function p(r,e,n,t={type:"base",objectType:r}){let o={aggregate:c=>{throw "TODO"},aggregateOrThrow:async c=>chunkI3UIWCJ4_js.b(e,r,c),fetchPage:async c=>{throw "TODO"},fetchPageOrThrow:async c=>chunkI3UIWCJ4_js.c(e,r,c??{},t),asyncIter:()=>{throw ""},where:c=>p(r,e,n,{type:"filter",objectSet:t,where:chunkI3UIWCJ4_js.a(c)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(c,s){return a(c)().where(s?.$where??{})}};function a(c){return ()=>p(r,e,{},{type:"searchAround",objectSet:t,link:c})}return new Proxy(o,{get(c,s,g){return typeof s=="string"&&s.startsWith(T)?a(s.substring(T.length)):c[s]}})}function F(r){return new Proxy({},{get:(e,n,t)=>{if(typeof n=="string")return r.objectSet(n)}})}function C(r,e,n,t=fetch){let o=h(r,e,n,t),a=(s,g)=>p(s,o,g),c=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>F(c)}});return c}function E(r){return r.type==="ok"}
11
11
 
12
12
  Object.defineProperty(exports, 'Objects', {
13
13
  enumerable: true,
14
- get: function () { return chunkLS6HVQGV_js.d; }
14
+ get: function () { return chunkI3UIWCJ4_js.d; }
15
15
  });
16
16
  exports.createClient = C;
17
17
  exports.createThinClient = h;
@@ -1,5 +1,5 @@
1
- import { b as b$1, c, a } from './chunk-N3LDDE54.mjs';
2
- export { d as Objects } from './chunk-N3LDDE54.mjs';
1
+ import { b as b$1, c, a } from './chunk-II7ELH2S.mjs';
2
+ export { d as Objects } from './chunk-II7ELH2S.mjs';
3
3
  import b from 'fetch-retry';
4
4
 
5
5
  function u(r=fetch,e){return async function(t,o){return o?r(t,{...o,headers:await e(new Headers(o.headers))}):r(t,{headers:await e(new Headers)})}}var i=class extends Error{constructor(e,n,t,o,a,c){super(e),this.message=e,this.errorName=n,this.errorType=t,this.statusCode=o,this.errorInstanceId=a,this.parameters=c;}};var f=class extends i{constructor(e,n,t){super(e,n),this.originalError=t;}};function m(r=fetch){return async function(n,t){let o;try{o=await r(n,t);}catch(a){throw l(a,"A network error occured")}if(!o.ok){let a;try{a=await o.json();}catch(c){throw l(c,"A network error occured while reading response")}throw new i(a?.message??`Failed to fetch ${o.status} ${o.statusText}`,a?.errorName,a?.errorCode,o.status,a?.errorInstanceId,a?.parameters)}return o}}function l(r,e="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(e,"UNKNOWN")}var N=1e3,R=.5,I=3;function d(r){return b(r,{retryDelay(e){let n=N*2**e,t=n*R*(Math.random()*2-1);return n+t},retryOn(e,n,t){let o=t?.status??0;return !(o>=200&&o<300)&&j(n)&&e<I}})}function j(r){return !(r instanceof i&&r.statusCode!==k&&r.statusCode!==P)}var k=503,P=429;function y(r){return r!=null?JSON.stringify(r):void 0}function w(r=fetch){return r=u(r,e=>(e.set("Content-Type","application/json"),e)),async function(n,t){return (await r(n,{...t,body:y(t.body)})).json()}}function h(r,e,n,t=fetch){let o=u(d(m(t)),async a=>{let c=await n();return a.set("Authorization",`Bearer ${c}`),a.set("Fetch-User-Agent",r.metadata.userAgent),a});return {ontology:r,stack:e,fetch:o,fetchJson:w(o)}}var T="searchAround_";function p(r,e,n,t={type:"base",objectType:r}){let o={aggregate:c=>{throw "TODO"},aggregateOrThrow:async c=>b$1(e,r,c),fetchPage:async c=>{throw "TODO"},fetchPageOrThrow:async c$1=>c(e,r,c$1??{},t),asyncIter:()=>{throw ""},where:c=>p(r,e,n,{type:"filter",objectSet:t,where:a(c)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(c,s){return a$1(c)().where(s?.$where??{})}};function a$1(c){return ()=>p(r,e,{},{type:"searchAround",objectSet:t,link:c})}return new Proxy(o,{get(c,s,g){return typeof s=="string"&&s.startsWith(T)?a$1(s.substring(T.length)):c[s]}})}function F(r){return new Proxy({},{get:(e,n,t)=>{if(typeof n=="string")return r.objectSet(n)}})}function C(r,e,n,t=fetch){let o=h(r,e,n,t),a=(s,g)=>p(s,o,g),c=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>F(c)}});return c}function E(r){return r.type==="ok"}
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkLS6HVQGV_js = require('../chunk-LS6HVQGV.js');
3
+ var chunkI3UIWCJ4_js = require('../chunk-I3UIWCJ4.js');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, 'aggregateOrThrow', {
8
8
  enumerable: true,
9
- get: function () { return chunkLS6HVQGV_js.b; }
9
+ get: function () { return chunkI3UIWCJ4_js.b; }
10
10
  });
11
11
  Object.defineProperty(exports, 'fetchPageOrThrow', {
12
12
  enumerable: true,
13
- get: function () { return chunkLS6HVQGV_js.c; }
13
+ get: function () { return chunkI3UIWCJ4_js.c; }
14
14
  });
15
15
  //# sourceMappingURL=out.js.map
16
16
  //# sourceMappingURL=objects.js.map
@@ -1,3 +1,3 @@
1
- export { b as aggregateOrThrow, c as fetchPageOrThrow } from '../chunk-N3LDDE54.mjs';
1
+ export { b as aggregateOrThrow, c as fetchPageOrThrow } from '../chunk-II7ELH2S.mjs';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=objects.mjs.map
@@ -1,4 +1,4 @@
1
1
  import type { AggregationClause } from "#client/query";
2
- import type { Wire } from "#net";
3
2
  import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
4
- export declare function modernToLegacyAggregationClause<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>>(select: AC): Wire.AggregationClause[];
3
+ import type { Aggregation } from "@osdk/gateway/types";
4
+ export declare function modernToLegacyAggregationClause<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>>(select: AC): Aggregation[];
@@ -1,4 +1,4 @@
1
1
  import type { GroupByClause } from "#client/query";
2
- import type { Wire } from "#net";
3
2
  import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
4
- export declare function modernToLegacyGroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(groupByClause: GroupByClause<O, K> | undefined): Wire.GroupByClause[] | undefined;
3
+ import type { AggregationGroupByV2 } from "@osdk/gateway/types";
4
+ export declare function modernToLegacyGroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(groupByClause: GroupByClause<O, K> | undefined): AggregationGroupByV2[];
@@ -0,0 +1,2 @@
1
+ import type { OpenApiRequest } from "@osdk/gateway/types";
2
+ export default function createOpenApiRequest<TExpectedResponse>(basePath: string, fetchFn: typeof fetch, contextPath?: string): OpenApiRequest<TExpectedResponse>;
@@ -1,3 +1,2 @@
1
- export { default as aggregateObjectsV2 } from "./aggregateObjectsV2";
2
- export { default as listObjectsFromObjectSetV2 } from "./listObjectsFromObjectSetV2";
1
+ export { default as createOpenApiRequest } from "./createOpenApiRequest";
3
2
  export * as Wire from "./types";
@@ -1,2 +1 @@
1
- export declare function test1(): Promise<void>;
2
- export declare function test2(): Promise<void>;
1
+ export {};
@@ -1,8 +1,10 @@
1
1
  import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "#ontology";
2
2
  import type { StringArrayToUnion } from "#util";
3
3
  import type { AggregationClause } from "./AggregationsClause";
4
+ type SubselectKeys<AC extends AggregationClause<any, any>, P extends keyof AC> = AC[P] extends readonly string[] | string ? P : never;
4
5
  export type AggregationResultsWithoutGroups<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, AC extends AggregationClause<O, K>> = {
5
- [P in PropertyKeysFrom<O, K>]: AC[P] extends readonly string[] | string ? {
6
+ [P in PropertyKeysFrom<O, K> as SubselectKeys<AC, P>]: AC[P] extends readonly string[] | string ? {
6
7
  [Z in StringArrayToUnion<AC[P]>]: Z extends "approximateDistinct" ? number : OsdkObjectPropertyType<PropertyDefinitionFrom<O, K, P>>;
7
8
  } : never;
8
9
  };
10
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/api",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -18,7 +18,8 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "fetch-retry": "^5.0.6",
21
- "tiny-invariant": "^1.3.1"
21
+ "tiny-invariant": "^1.3.1",
22
+ "@osdk/gateway": "0.0.0"
22
23
  },
23
24
  "devDependencies": {
24
25
  "ts-expect": "^1.3.0",
@@ -44,8 +45,10 @@
44
45
  "scripts": {
45
46
  "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
46
47
  "dev:transpile": "tsup --watch",
48
+ "fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
47
49
  "lint": "eslint . && dprint check --config $(find-up dprint.json)",
48
- "prettier": "prettier .",
50
+ "test": "vitest run",
51
+ "test:watch": "vitest",
49
52
  "transpile": "tsup",
50
53
  "transpileWatch": "tsup --watch",
51
54
  "typecheck": "tsc-absolute --build"
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- var a = require('tiny-invariant');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var a__default = /*#__PURE__*/_interopDefault(a);
8
-
9
- var x=Object.defineProperty;var b=(o,r)=>{for(var e in r)x(o,e,{get:r[e],enumerable:!0});};function u(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"assumed we were getting a `${key}.${type}`"):a__default.default(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function f(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function d(o){if(o)return Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[])}function s(o){if("$and"in o)return {type:"and",value:o.$and.map(s)};if("$or"in o)return {type:"or",value:o.$or.map(s)};if("$not"in o)return {type:"not",value:s(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}var l="api/v2/ontologies";async function g(o,r,e,t,n){let i=new URL(`${l}/${e}/objects/${t}/aggregate`,`https://${r}`);return o(i,{method:"POST",body:n})}async function c(o,r,e,t){return o(new URL(`${l}/${e}/objectSets/loadObjects`,`https://${r}`),{method:"POST",body:t})}async function O(o,r,e){let t={aggregation:f(e.select)};e.groupBy&&(t.groupBy=d(e.groupBy)),e.where&&(t.where={where:s(e.where)});let n=await g(o.fetchJson,o.stack,o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(p=>({group:p.group,values:u(p)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"no group by clause should mean only one data result"):a__default.default(!1)),u(n.data[0]))}async function v(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let i=await c(o.fetchJson,o.stack,o.ontology.metadata.ontologyApiName,n);return {data:i.data.map(p=>({...p,__name:r})),nextPageToken:i.nextPageToken}}var h={};b(h,{aggregateOrThrow:()=>O,fetchPageOrThrow:()=>v});
10
-
11
- exports.a = s;
12
- exports.b = O;
13
- exports.c = v;
14
- exports.d = h;
15
- //# sourceMappingURL=out.js.map
16
- //# sourceMappingURL=chunk-LS6HVQGV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/V2_BASE.ts","../../src/client/internal/net/aggregateObjectsV2.ts","../../src/client/internal/net/listObjectsFromObjectSetV2.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","V2_BASE","aggregateObjectsV2","fetchAsJson","foundryHost","ontologyApiName","objectApiName","body","aggregateObjectsUrl","listObjectsFromObjectSetV2","aggregateOrThrow","thinClient","objectType","req","result","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,EAAYE,EAAM,CAAC,CAAC,EAAI,CAAC,GAE3BF,EAAYE,EAAM,CAAC,CAAC,EAAEA,EAAM,CAAC,CAAC,EAAID,EAAS,MACpCD,CACT,EAAG,CAAC,CAAC,CACP,CCXO,SAASG,EAAgCC,EAAQ,CACtD,OAAO,OAAO,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,EAAGC,CAAC,IACtC,MAAM,QAAQA,CAAC,EACVA,EAAE,IAAIC,IACJ,CACL,KAAMA,EACN,KAAM,GAAGF,CAAC,IAAIE,CAAE,GAChB,MAAOF,CACT,EACD,EAEM,CAAC,CACN,KAAMC,EACN,KAAM,GAAGD,CAAC,IAAIC,CAAC,GACf,MAAOD,CACT,CA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CCJA,OAAOzB,MAAe,iBACtB,eAAsB4B,EAAiBC,EAAYC,EAAYC,EAAK,CAClE,IAAMN,EAAO,CACX,YAAanB,EAAgCyB,EAAI,MAAM,CACzD,EACIA,EAAI,UACNN,EAAK,QAAUd,EAA4BoB,EAAI,OAAO,GAEpDA,EAAI,QACNN,EAAK,MAAQ,CACX,MAAOV,EAA0BgB,EAAI,KAAK,CAG5C,GAGF,IAAMC,EAAS,MAAMZ,EAAmBS,EAAW,UAAWA,EAAW,MAAOA,EAAW,SAAS,SAAS,gBAAiBC,EAAYL,CAAI,EAC9I,OAAKM,EAAI,QAIGC,EAAO,KAAK,IAAI9B,IACnB,CACL,MAAOA,EAAM,MACb,OAAQD,EAAsCC,CAAK,CACrD,EACD,GARG8B,EAAO,KAAK,SAAW,IAAK,QAAQ,IAAI,WAAa,aAAehC,EAAU,GAAO,qDAAqD,EAAIA,EAAU,EAAK,GACxJC,EAAsC+B,EAAO,KAAK,CAAC,CAAC,EAU/D,CC9BA,eAAsBC,EAAiBC,EAAQJ,EAAYK,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAAN,CACF,EAAG,CACD,IAAML,EAAO,CACX,UAAAW,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRV,EAAK,UAAYU,EAAK,eAExB,IAAME,EAAI,MAAMV,EAA2BO,EAAO,UAAWA,EAAO,MAAOA,EAAO,SAAS,SAAS,gBAAiBT,CAAI,EACzH,MAAO,CACL,KAAMY,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQR,CACV,EAAE,EACF,cAAeO,EAAE,aACnB,CACF,CCtCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAX,EAAA,qBAAAK","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 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 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 undefined;\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\nexport const V2_BASE = \"api/v2/ontologies\";","/*\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 { V2_BASE } from \"./V2_BASE\";\nexport default async function aggregateObjectsV2(fetchAsJson, foundryHost, ontologyApiName, objectApiName, body) {\n const aggregateObjectsUrl = new URL(`${V2_BASE}/${ontologyApiName}/objects/${objectApiName}/aggregate`, `https://${foundryHost}`);\n return fetchAsJson(aggregateObjectsUrl, {\n method: \"POST\",\n body\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 { V2_BASE } from \"./V2_BASE\";\nexport default async function listObjectsFromObjectSetV2(fetchAsJson, foundryHost, ontologyApiName, body) {\n return fetchAsJson(new URL(`${V2_BASE}/${ontologyApiName}/objectSets/loadObjects`, `https://${foundryHost}`), {\n method: \"POST\",\n body\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 { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { aggregateObjectsV2 } from \"#net\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, objectType, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select)\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = {\n where: modernToLegacyWhereClause(req.where)\n // TODO: orderBy\n // TODO The token stuff here sucks\n };\n }\n\n const result = await aggregateObjectsV2(thinClient.fetchJson, thinClient.stack, thinClient.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 { listObjectsFromObjectSetV2 } from \"#net\";\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 const r = await listObjectsFromObjectSetV2(client.fetchJson, client.stack, client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\n nextPageToken: r.nextPageToken\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\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
@@ -1,7 +0,0 @@
1
- import a from 'tiny-invariant';
2
-
3
- var x=Object.defineProperty;var b=(o,r)=>{for(var e in r)x(o,e,{get:r[e],enumerable:!0});};function u(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a(!1,"assumed we were getting a `${key}.${type}`"):a(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function f(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function d(o){if(o)return Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[])}function s(o){if("$and"in o)return {type:"and",value:o.$and.map(s)};if("$or"in o)return {type:"or",value:o.$or.map(s)};if("$not"in o)return {type:"not",value:s(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a(!1,"Defined key values are only allowed when they are not undefined."):a(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a(!1,"Defined key values are only allowed when they are not undefined."):a(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}var l="api/v2/ontologies";async function g(o,r,e,t,n){let i=new URL(`${l}/${e}/objects/${t}/aggregate`,`https://${r}`);return o(i,{method:"POST",body:n})}async function c(o,r,e,t){return o(new URL(`${l}/${e}/objectSets/loadObjects`,`https://${r}`),{method:"POST",body:t})}async function O(o,r,e){let t={aggregation:f(e.select)};e.groupBy&&(t.groupBy=d(e.groupBy)),e.where&&(t.where={where:s(e.where)});let n=await g(o.fetchJson,o.stack,o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(p=>({group:p.group,values:u(p)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"no group by clause should mean only one data result"):a(!1)),u(n.data[0]))}async function v(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let i=await c(o.fetchJson,o.stack,o.ontology.metadata.ontologyApiName,n);return {data:i.data.map(p=>({...p,__name:r})),nextPageToken:i.nextPageToken}}var h={};b(h,{aggregateOrThrow:()=>O,fetchPageOrThrow:()=>v});
4
-
5
- export { s as a, O as b, v as c, h as d };
6
- //# sourceMappingURL=out.js.map
7
- //# sourceMappingURL=chunk-N3LDDE54.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/V2_BASE.ts","../../src/client/internal/net/aggregateObjectsV2.ts","../../src/client/internal/net/listObjectsFromObjectSetV2.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","V2_BASE","aggregateObjectsV2","fetchAsJson","foundryHost","ontologyApiName","objectApiName","body","aggregateObjectsUrl","listObjectsFromObjectSetV2","aggregateOrThrow","thinClient","objectType","req","result","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,EAAYE,EAAM,CAAC,CAAC,EAAI,CAAC,GAE3BF,EAAYE,EAAM,CAAC,CAAC,EAAEA,EAAM,CAAC,CAAC,EAAID,EAAS,MACpCD,CACT,EAAG,CAAC,CAAC,CACP,CCXO,SAASG,EAAgCC,EAAQ,CACtD,OAAO,OAAO,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,EAAGC,CAAC,IACtC,MAAM,QAAQA,CAAC,EACVA,EAAE,IAAIC,IACJ,CACL,KAAMA,EACN,KAAM,GAAGF,CAAC,IAAIE,CAAE,GAChB,MAAOF,CACT,EACD,EAEM,CAAC,CACN,KAAMC,EACN,KAAM,GAAGD,CAAC,IAAIC,CAAC,GACf,MAAOD,CACT,CAAC,CAEJ,CACH,CClBO,SAASG,EAA4BC,EAAe,CACzD,GAAKA,EACL,OAAO,OAAO,QAAQA,CAAa,EAAE,QAAQ,CAAC,CA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EAAI,MAAM,CACzD,EACIA,EAAI,UACNN,EAAK,QAAUd,EAA4BoB,EAAI,OAAO,GAEpDA,EAAI,QACNN,EAAK,MAAQ,CACX,MAAOV,EAA0BgB,EAAI,KAAK,CAG5C,GAGF,IAAMC,EAAS,MAAMZ,EAAmBS,EAAW,UAAWA,EAAW,MAAOA,EAAW,SAAS,SAAS,gBAAiBC,EAAYL,CAAI,EAC9I,OAAKM,EAAI,QAIGC,EAAO,KAAK,IAAI9B,IACnB,CACL,MAAOA,EAAM,MACb,OAAQD,EAAsCC,CAAK,CACrD,EACD,GARG8B,EAAO,KAAK,SAAW,IAAK,QAAQ,IAAI,WAAa,aAAehC,EAAU,GAAO,qDAAqD,EAAIA,EAAU,EAAK,GACxJC,EAAsC+B,EAAO,KAAK,CAAC,CAAC,EAU/D,CC9BA,eAAsBC,EAAiBC,EAAQJ,EAAYK,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAAN,CACF,EAAG,CACD,IAAML,EAAO,CACX,UAAAW,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRV,EAAK,UAAYU,EAAK,eAExB,IAAME,EAAI,MAAMV,EAA2BO,EAAO,UAAWA,EAAO,MAAOA,EAAO,SAAS,SAAS,gBAAiBT,CAAI,EACzH,MAAO,CACL,KAAMY,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQR,CACV,EAAE,EACF,cAAeO,EAAE,aACnB,CACF,CCtCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAX,EAAA,qBAAAK","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 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 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 undefined;\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\nexport const V2_BASE = \"api/v2/ontologies\";","/*\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 { V2_BASE } from \"./V2_BASE\";\nexport default async function aggregateObjectsV2(fetchAsJson, foundryHost, ontologyApiName, objectApiName, body) {\n const aggregateObjectsUrl = new URL(`${V2_BASE}/${ontologyApiName}/objects/${objectApiName}/aggregate`, `https://${foundryHost}`);\n return fetchAsJson(aggregateObjectsUrl, {\n method: \"POST\",\n body\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 { V2_BASE } from \"./V2_BASE\";\nexport default async function listObjectsFromObjectSetV2(fetchAsJson, foundryHost, ontologyApiName, body) {\n return fetchAsJson(new URL(`${V2_BASE}/${ontologyApiName}/objectSets/loadObjects`, `https://${foundryHost}`), {\n method: \"POST\",\n body\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 { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { aggregateObjectsV2 } from \"#net\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, objectType, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select)\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = {\n where: modernToLegacyWhereClause(req.where)\n // TODO: orderBy\n // TODO The token stuff here sucks\n };\n }\n\n const result = await aggregateObjectsV2(thinClient.fetchJson, thinClient.stack, thinClient.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 { listObjectsFromObjectSetV2 } from \"#net\";\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 const r = await listObjectsFromObjectSetV2(client.fetchJson, client.stack, client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\n nextPageToken: r.nextPageToken\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\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
@@ -1,3 +0,0 @@
1
- import type { FetchAsJsonFn } from "#util";
2
- import type { AggregateObjectsV2Body, AggregationAPIResponse } from "./types";
3
- export default function aggregateObjectsV2(fetchAsJson: FetchAsJsonFn, foundryHost: string, ontologyApiName: string, objectApiName: string, body: AggregateObjectsV2Body): Promise<AggregationAPIResponse>;
@@ -1,3 +0,0 @@
1
- import type { FetchAsJsonFn } from "#util";
2
- import type { LoadObjectSetRequestV2, OntologyObjectV2, PagedResponse } from "./types";
3
- export default function listObjectsFromObjectSetV2(fetchAsJson: FetchAsJsonFn, foundryHost: string, ontologyApiName: string, body: LoadObjectSetRequestV2): Promise<PagedResponse<OntologyObjectV2>>;