@osdk/api 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/build/js/chunk-4D6JZ4TL.js +7 -0
- package/build/js/chunk-4D6JZ4TL.js.map +1 -0
- package/build/js/chunk-BZ6L26S2.mjs +7 -0
- package/build/js/chunk-BZ6L26S2.mjs.map +1 -0
- package/build/js/chunk-SHYKLQMU.js +15 -0
- package/build/js/chunk-SHYKLQMU.js.map +1 -0
- package/build/js/chunk-SM47N47Q.js +19 -0
- package/build/js/chunk-SM47N47Q.js.map +1 -0
- package/build/js/chunk-TPXDMNRT.mjs +9 -0
- package/build/js/chunk-TPXDMNRT.mjs.map +1 -0
- package/build/js/chunk-XIJ2ZQRX.mjs +5 -0
- package/build/js/chunk-XIJ2ZQRX.mjs.map +1 -0
- package/build/js/index.js +11 -10
- package/build/js/index.js.map +1 -1
- package/build/js/index.mjs +6 -5
- package/build/js/index.mjs.map +1 -1
- package/build/js/public/objects.js +4 -3
- package/build/js/public/objects.mjs +2 -1
- package/build/js/public/utils.js +17 -0
- package/build/js/public/utils.js.map +1 -0
- package/build/js/public/utils.mjs +4 -0
- package/build/js/public/utils.mjs.map +1 -0
- package/build/types/client/Client.d.ts +1 -1
- package/build/types/client/ObjectSetCreator.d.ts +1 -1
- package/build/types/client/PageResult.d.ts +1 -1
- package/build/types/client/ThinClient.d.ts +2 -2
- package/build/types/client/createClient.d.ts +2 -2
- package/build/types/client/createOpenApiRequest.d.ts +2 -0
- package/build/types/client/createThinClient.d.ts +2 -2
- package/build/types/client/internal/conversions/legacyToModernSingleAggregationResult.d.ts +3 -3
- package/build/types/client/internal/conversions/modernToLegacyAggregationClause.d.ts +2 -2
- package/build/types/client/internal/conversions/modernToLegacyGroupByClause.d.ts +2 -2
- package/build/types/client/internal/conversions/modernToLegacyWhereClause.d.ts +3 -3
- package/build/types/client/internal/net/index.d.ts +0 -1
- package/build/types/client/object/aggregateOrThrow.d.ts +3 -3
- package/build/types/client/object/fetchPageOrThrow.d.ts +4 -4
- package/build/types/client/objectSet/LinkTypesFrom.d.ts +2 -2
- package/build/types/client/objectSet/ObjectSet.d.ts +5 -5
- package/build/types/client/objectSet/createObjectSet.d.ts +3 -3
- package/build/types/client/query/WhereClause.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregatableKeys.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregateOpts.d.ts +2 -2
- package/build/types/client/query/aggregations/AggregationResultsWithGroups.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregationResultsWithoutGroups.d.ts +2 -2
- package/build/types/client/query/aggregations/AggregationsClause.d.ts +1 -1
- package/build/types/client/query/aggregations/AggregationsClause.test.d.ts +6 -0
- package/build/types/client/query/aggregations/AggregationsResults.d.ts +1 -1
- package/build/types/client/query/aggregations/GroupByClause.d.ts +1 -1
- package/build/types/client/query/aggregations/GroupByClause.test.d.ts +3 -0
- package/build/types/index.d.ts +6 -3
- package/build/types/ontology/ActionDefinition.d.ts +36 -0
- package/build/types/ontology/Definition.d.ts +36 -8
- package/build/types/ontology/OsdkObjectFrom.d.ts +3 -3
- package/build/types/ontology/QueryDefinition.d.ts +77 -0
- package/build/types/ontology/index.d.ts +2 -0
- package/build/types/public/utils.d.ts +2 -0
- package/package.json +3 -9
- package/build/js/chunk-I3UIWCJ4.js +0 -17
- package/build/js/chunk-I3UIWCJ4.js.map +0 -1
- package/build/js/chunk-II7ELH2S.mjs +0 -8
- package/build/js/chunk-II7ELH2S.mjs.map +0 -1
- package/build/types/client/internal/net/createOpenApiRequest.d.ts +0 -2
- /package/build/types/client/{internal/net/createOpenApiRequest.test.d.ts → createOpenApiRequest.test.d.ts} +0 -0
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -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/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,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F,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\";"]}
|
|
File without changes
|