@osdk/api 0.0.7 → 0.0.9

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,19 @@
1
1
  # @osdk/api
2
2
 
3
+ ## 0.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 0860ae9: Adds type information for geopoint and geoshape
8
+
9
+ ## 0.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 1674b35: Releasing clients for integration
14
+ - Updated dependencies [1674b35]
15
+ - @osdk/gateway@0.0.3
16
+
3
17
  ## 0.0.7
4
18
 
5
19
  ### Patch Changes
@@ -0,0 +1,9 @@
1
+ import { a } from './chunk-XIJ2ZQRX.mjs';
2
+ import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
3
+ import a$1 from 'tiny-invariant';
4
+
5
+ function f(o,r,t="/api",e){return async function(s,p,N,A,E,$,d){let y=new URL(`${t}${p}`,B(o));for(let[l,i]of Object.entries(A||{}))if(i!=null)if(Array.isArray(i))for(let D of i)y.searchParams.append(l,D);else y.searchParams.append(l,i);let u=new Headers;u.set("Content-Type",$??"application/json"),u.set("Accept",d??"application/json"),Object.entries(E||{}).forEach(([l,i])=>{i!=null&&u.append(l,i.toString());});let k=P(N),m=await r(y.toString(),{body:k,method:s,headers:u});return d&&d==="*/*"?e?m.body:m.blob():m.json()}}function P(o){return o==null||globalThis.Blob&&o instanceof globalThis.Blob?o:JSON.stringify(o)}function B(o){let r=/^https?:\/\//i,t="https://";return r.test(o)?o.replace(/^http:\/\//i,t):`${t}${o}`}function g(o){return o.metrics.reduce((r,t)=>{let e=t.name.split(".");return e.length!=2&&(process.env.NODE_ENV!=="production"?a$1(!1,"assumed we were getting a `${key}.${type}`"):a$1(!1)),e[0]in r||(r[e[0]]={}),r[e[0]][e[1]]=t.value,r},{})}function h(o){return Object.entries(o).flatMap(([r,t])=>Array.isArray(t)?t.map(e=>({type:e,name:`${r}.${e}`,field:r})):[{type:t,name:`${r}.${t}`,field:r}])}function O(o){return o?Object.entries(o).flatMap(([r,t])=>t==="exact"?[{type:t,field:r}]:t.exactWithLimit?[{type:"exact",field:r,maxGroupCount:t.exactWithLimit}]:[]):[]}function c(o){if("$and"in o)return {type:"and",value:o.$and.map(c)};if("$or"in o)return {type:"or",value:o.$or.map(c)};if("$not"in o)return {type:"not",value:c(o.$not)};let r=Object.entries(o);if(r.length===1){let[t,e]=r[0];if(e==null&&(process.env.NODE_ENV!=="production"?a$1(!1,"Defined key values are only allowed when they are not undefined."):a$1(!1)),typeof e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"WhereClause Filter with multiple properties isn't allowed"):a$1(!1));let n=Object.keys(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a$1(!1):a$1(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}}return {type:"and",value:Object.entries(o).map(([t,e])=>{if(e==null&&(process.env.NODE_ENV!=="production"?a$1(!1,"Defined key values are only allowed when they are not undefined."):a$1(!1)),typeof e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"WhereClause Filter with multiple properties isn't allowed"):a$1(!1));let n=Object.keys(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a$1(!1):a$1(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}})}}async function x(o,r,t){let e={aggregation:h(t.select),groupBy:[],where:void 0};t.groupBy&&(e.groupBy=O(t.groupBy)),t.where&&(e.where=c(t.where));let n=await aggregateObjectsV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,e);return t.groupBy?n.data.map(p=>({group:p.group,values:g(p)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"no group by clause should mean only one data result"):a$1(!1)),g(n.data[0]))}function T(o){let r=new Map;return (t,e)=>{let n=t.objects[e],s=r.get(n);return s==null&&(s=o(t,e),r.set(n,s)),s}}var R=T(V);function V(o,r){o.objects[r];let e={};return Object.defineProperty(e,"__name",{value:r,enumerable:!1,configurable:!1,writable:!1}),e}function j(o,r,t){let e=R(o.ontology,r);for(let n of t)Object.setPrototypeOf(n,e);return t}async function w(o,r,t,e={type:"base",objectType:r}){let n={objectSet:e,select:t?.select??[]};t?.nextPageToken&&(n.pageToken=t.nextPageToken);let s=await loadObjectSetV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,n);return j(o,r,s.data),s}var S={};a(S,{aggregateOrThrow:()=>x,fetchPageOrThrow:()=>w});
6
+
7
+ export { c as a, f as b, x as c, w as d, S as e };
8
+ //# sourceMappingURL=out.js.map
9
+ //# sourceMappingURL=chunk-BYTHMUUS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../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/object/fetchPageOrThrow.ts","../../src/client/createCachedOntologyTransform.ts","../../src/client/object/convertWireToOsdkObjects.ts","../../src/client/object/index.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","result","loadObjectSetV2","createCachedOntologyTransform","creator","cache","ontology","objectDefinition","getPrototype","createPrototype","objDef","proto","convertWireToOsdkObjects","client","apiName","objs","obj","fetchPageOrThrow","args","objectSet","r","object_exports","__export"],"mappings":"yCAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAW,GAAGG,CAAY,GAAIO,EAAUZ,CAAQ,CAAC,EACxE,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQP,GAAkB,CAAC,CAAC,EAC5D,GAAIO,GAAS,KAGb,GAAI,MAAM,QAAQA,CAAK,EACrB,QAAWC,KAAQD,EACjBH,EAAI,aAAa,OAAOE,EAAKE,CAAI,OAGnCJ,EAAI,aAAa,OAAOE,EAAKC,CAAK,EAGtC,IAAME,EAAc,IAAI,QACxBA,EAAY,IAAI,eAAgBP,GAAoB,kBAAkB,EACtEO,EAAY,IAAI,SAAUN,GAAqB,kBAAkB,EACjE,OAAO,QAAQF,GAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAACK,EAAKC,CAAK,IAAM,CAClDA,GAAS,MACXE,EAAY,OAAOH,EAAKC,EAAM,SAAS,CAAC,CAE5C,CAAC,EACD,IAAMG,EAAOC,EAAQZ,CAAI,EACnBa,EAAW,MAAMlB,EAAQU,EAAI,SAAS,EAAG,CAC7C,KAAAM,EACA,OAAQb,EACR,QAASY,CACX,CAAC,EACD,OAAIN,GAAqBA,IAAsB,MACzCP,EACKgB,EAAS,KAEXA,EAAS,KAAK,EAEhBA,EAAS,KAAK,CACvB,CACF,CACA,SAASD,EAAQD,EAAM,CAIrB,OAHIA,GAAQ,MAGR,WAAW,MAAQA,aAAgB,WAAW,KACzCA,EAEF,KAAK,UAAUA,CAAI,CAC5B,CACA,SAASL,EAAUD,EAAK,CACtB,IAAMS,EAAgB,gBAChBC,EAAgB,WACtB,OAAOD,EAAc,KAAKT,CAAG,E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CAAgB,EACvC,OAAIN,GAAU,OACZA,EAASG,EAAQE,EAAUd,CAAI,EAC/Ba,EAAM,IAAIE,EAAkBN,CAAM,GAE7BA,CACT,CACF,CCjBA,IAAMO,EAAeL,EAA8BM,CAAe,EAClE,SAASA,EAAgBH,EAAUd,EAAM,CACvC,IAAMkB,EAASJ,EAAS,QAAQd,CAAI,EAC9BmB,EAAQ,CAAC,EAIf,cAAO,eAAeA,EAAO,SAAU,CACrC,MAAOnB,EACP,WAAY,GACZ,aAAc,GACd,SAAU,EACZ,CAAC,EACMmB,CACT,CACO,SAASC,EAAyBC,EAAQC,EAASC,EAAM,CAC9D,IAAMJ,EAAQH,EAAaK,EAAO,SAAUC,CAAO,EACnD,QAAWE,KAAOD,EAChB,OAAO,eAAeC,EAAKL,CAAK,EAgClC,OAAOI,CACT,CFjDA,eAAsBE,EAAiBJ,EAAQd,EAAYmB,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAApB,CACF,EAAG,CACD,IAAM3B,EAAO,CACX,UAAA+C,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACR9C,EAAK,UAAY8C,EAAK,eAExB,IAAME,EAAI,MAAMlB,EAAgBhD,EAAqB2D,EAAO,MAAOA,EAAO,KAAK,EAAGA,EAAO,SAAS,SAAS,gBAAiBzC,CAAI,EAChI,OAAAwC,EAAyBC,EAAQd,EAAYqB,EAAE,IAAI,EAI5CA,CACT,CGtCA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,sBAAAxB,EAAA,qBAAAoB","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\nexport function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 (value == null) {\n continue;\n }\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 headersInit.set(\"Content-Type\", requestMediaType ?? \"application/json\");\n headersInit.set(\"Accept\", responseMediaType ?? \"application/json\");\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions\";\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 invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects\";\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.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, objectType, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createCachedOntologyTransform } from \"../createCachedOntologyTransform\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false\n });\n return proto;\n}\nexport function convertWireToOsdkObjects(client, apiName, objs) {\n const proto = getPrototype(client.ontology, apiName);\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n\n // Saving this code in case we want to come back to temporal. For now its not worth the\n // risk and we can stick to string until we know what we want.\n // ====================================================================================================\n // FIXME\n // Im not going for performance for now, just something usable by beta users\n // Also not married to the $raw\n // obj[\"$raw\"] = {};\n\n // for (\n // const [key, def] of Object.entries(\n // client.ontology.objects[apiName].properties,\n // )\n // ) {\n // if (!(key in obj)) continue;\n // obj[\"$raw\"][key] = obj[key];\n\n // if (def.type === \"timestamp\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.Instant.from(value);\n // }\n // } else if (def.type === \"datetime\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.PlainDateTime.from(value);\n // }\n // }\n // }\n }\n\n return objs;\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,19 @@
1
+ 'use strict';
2
+
3
+ var chunk4D6JZ4TL_js = require('./chunk-4D6JZ4TL.js');
4
+ var requests = require('@osdk/gateway/requests');
5
+ var a = require('tiny-invariant');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var a__default = /*#__PURE__*/_interopDefault(a);
10
+
11
+ function f(o,r,t="/api",e){return async function(s,p,N,A,E,$,d){let y=new URL(`${t}${p}`,B(o));for(let[l,i]of Object.entries(A||{}))if(i!=null)if(Array.isArray(i))for(let D of i)y.searchParams.append(l,D);else y.searchParams.append(l,i);let u=new Headers;u.set("Content-Type",$??"application/json"),u.set("Accept",d??"application/json"),Object.entries(E||{}).forEach(([l,i])=>{i!=null&&u.append(l,i.toString());});let k=P(N),m=await r(y.toString(),{body:k,method:s,headers:u});return d&&d==="*/*"?e?m.body:m.blob():m.json()}}function P(o){return o==null||globalThis.Blob&&o instanceof globalThis.Blob?o:JSON.stringify(o)}function B(o){let r=/^https?:\/\//i,t="https://";return r.test(o)?o.replace(/^http:\/\//i,t):`${t}${o}`}function g(o){return o.metrics.reduce((r,t)=>{let e=t.name.split(".");return e.length!=2&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"assumed we were getting a `${key}.${type}`"):a__default.default(!1)),e[0]in r||(r[e[0]]={}),r[e[0]][e[1]]=t.value,r},{})}function h(o){return Object.entries(o).flatMap(([r,t])=>Array.isArray(t)?t.map(e=>({type:e,name:`${r}.${e}`,field:r})):[{type:t,name:`${r}.${t}`,field:r}])}function O(o){return o?Object.entries(o).flatMap(([r,t])=>t==="exact"?[{type:t,field:r}]:t.exactWithLimit?[{type:"exact",field:r,maxGroupCount:t.exactWithLimit}]:[]):[]}function c(o){if("$and"in o)return {type:"and",value:o.$and.map(c)};if("$or"in o)return {type:"or",value:o.$or.map(c)};if("$not"in o)return {type:"not",value:c(o.$not)};let r=Object.entries(o);if(r.length===1){let[t,e]=r[0];if(e==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 e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).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(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}}return {type:"and",value:Object.entries(o).map(([t,e])=>{if(e==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 e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).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(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}})}}async function x(o,r,t){let e={aggregation:h(t.select),groupBy:[],where:void 0};t.groupBy&&(e.groupBy=O(t.groupBy)),t.where&&(e.where=c(t.where));let n=await requests.aggregateObjectsV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,e);return t.groupBy?n.data.map(p=>({group:p.group,values:g(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)),g(n.data[0]))}function T(o){let r=new Map;return (t,e)=>{let n=t.objects[e],s=r.get(n);return s==null&&(s=o(t,e),r.set(n,s)),s}}var R=T(V);function V(o,r){o.objects[r];let e={};return Object.defineProperty(e,"__name",{value:r,enumerable:!1,configurable:!1,writable:!1}),e}function j(o,r,t){let e=R(o.ontology,r);for(let n of t)Object.setPrototypeOf(n,e);return t}async function w(o,r,t,e={type:"base",objectType:r}){let n={objectSet:e,select:t?.select??[]};t?.nextPageToken&&(n.pageToken=t.nextPageToken);let s=await requests.loadObjectSetV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,n);return j(o,r,s.data),s}var S={};chunk4D6JZ4TL_js.a(S,{aggregateOrThrow:()=>x,fetchPageOrThrow:()=>w});
12
+
13
+ exports.a = c;
14
+ exports.b = f;
15
+ exports.c = x;
16
+ exports.d = w;
17
+ exports.e = S;
18
+ //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=chunk-EVOZ7UGO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../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/object/fetchPageOrThrow.ts","../../src/client/createCachedOntologyTransform.ts","../../src/client/object/convertWireToOsdkObjects.ts","../../src/client/object/index.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","result","loadObjectSetV2","createCachedOntologyTransform","creator","cache","ontology","objectDefinition","getPrototype","createPrototype","objDef","proto","convertWireToOsdkObjects","client","apiName","objs","obj","fetchPageOrThrow","args","objectSet","r","object_exports","__export"],"mappings":"wCAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAW,GAAGG,CAAY,GAAIO,EAAUZ,CAAQ,CAAC,EACxE,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQP,GAAkB,CAAC,CAAC,EAC5D,GAAIO,GAAS,KAGb,GAAI,MAAM,QAAQA,CAAK,EACrB,QAAWC,KAAQD,EACjBH,EAAI,aAAa,OAAOE,EAAKE,CAAI,OAGnCJ,EAAI,aAAa,OAAOE,EAAKC,CAAK,EAGtC,IAAME,EAAc,IAAI,QACxBA,EAAY,IAAI,eAAgBP,GAAoB,kBAAkB,EACtEO,EAAY,IAAI,SAAUN,GAAqB,kBAAkB,EACjE,OAAO,QAAQF,GAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAACK,EAAKC,CAAK,IAAM,CAClDA,GAAS,MACXE,EAAY,OAAOH,EAAKC,EAAM,SAAS,CAAC,CAE5C,CAAC,EACD,IAAMG,EAAOC,EAAQZ,CAAI,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,EAChI,OAAAwC,EAAyBC,EAAQd,EAAYqB,EAAE,IAAI,EAI5CA,CACT,CGtCA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,sBAAAxB,EAAA,qBAAAoB","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\nexport function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 (value == null) {\n continue;\n }\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 headersInit.set(\"Content-Type\", requestMediaType ?? \"application/json\");\n headersInit.set(\"Accept\", responseMediaType ?? \"application/json\");\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions\";\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 invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects\";\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.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, objectType, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createCachedOntologyTransform } from \"../createCachedOntologyTransform\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false\n });\n return proto;\n}\nexport function convertWireToOsdkObjects(client, apiName, objs) {\n const proto = getPrototype(client.ontology, apiName);\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n\n // Saving this code in case we want to come back to temporal. For now its not worth the\n // risk and we can stick to string until we know what we want.\n // ====================================================================================================\n // FIXME\n // Im not going for performance for now, just something usable by beta users\n // Also not married to the $raw\n // obj[\"$raw\"] = {};\n\n // for (\n // const [key, def] of Object.entries(\n // client.ontology.objects[apiName].properties,\n // )\n // ) {\n // if (!(key in obj)) continue;\n // obj[\"$raw\"][key] = obj[key];\n\n // if (def.type === \"timestamp\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.Instant.from(value);\n // }\n // } else if (def.type === \"datetime\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.PlainDateTime.from(value);\n // }\n // }\n // }\n }\n\n return objs;\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,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkSM47N47Q_js = require('./chunk-SM47N47Q.js');
3
+ var chunkEVOZ7UGO_js = require('./chunk-EVOZ7UGO.js');
4
4
  var chunkSHYKLQMU_js = require('./chunk-SHYKLQMU.js');
5
5
  require('./chunk-4D6JZ4TL.js');
6
6
 
7
- var f=class extends chunkSHYKLQMU_js.b{constructor(t,c,n){super(t,c),this.originalError=n;}};function g(r=fetch){return async function(c,n){let a;try{a=await r(c,n);}catch(o){throw A(o,"A network error occured")}if(!a.ok){let o;try{o=await a.json();}catch(e){throw A(e,"A network error occured while reading response")}throw new chunkSHYKLQMU_js.b(o?.message??`Failed to fetch ${a.status} ${a.statusText}`,o?.errorName,o?.errorCode,a.status,o?.errorInstanceId,o?.parameters)}return a}}function A(r,t="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(t,"UNKNOWN")}function w(r){return r!=null?JSON.stringify(r):void 0}function y(r=fetch){return r=chunkSHYKLQMU_js.a(r,t=>(t.set("Content-Type","application/json"),t)),async function(c,n){return (await r(c,{...n,body:w(n.body)})).json()}}function h(r,t,c,n=fetch){let a=chunkSHYKLQMU_js.a(chunkSHYKLQMU_js.c(g(n)),async o=>{let e=await c();return o.set("Authorization",`Bearer ${e}`),o.set("Fetch-User-Agent",r.metadata.userAgent),o});return {ontology:r,stack:t,fetch:a,fetchJson:y(a)}}var T="searchAround_";function p(r,t,c,n={type:"base",objectType:r}){let a={aggregate:e=>{throw "TODO"},aggregateOrThrow:async e=>chunkSM47N47Q_js.c(t,r,e),fetchPage:async e=>{throw "TODO"},fetchPageOrThrow:async e=>chunkSM47N47Q_js.d(t,r,e??{},n),asyncIter:()=>{throw ""},where:e=>p(r,t,c,{type:"filter",objectSet:n,where:chunkSM47N47Q_js.a(e)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(e,i){return o(e)().where(i?.$where??{})}};function o(e){return ()=>p(r,t,{},{type:"searchAround",objectSet:n,link:e})}return new Proxy(a,{get(e,i,O){return typeof i=="string"&&i.startsWith(T)?o(i.substring(T.length)):e[i]}})}function F(r){return new Proxy({},{get:(t,c,n)=>{if(typeof c=="string")return r.objectSet(c)}})}function b(r,t,c,n=fetch){let a=h(r,t,c,n),o=(i,O)=>p(i,a,O),e=Object.defineProperties({},{objectSet:{get:()=>o},objects:{get:()=>F(e)}});return e}function C(r){return r.type==="ok"}
7
+ var f=class extends chunkSHYKLQMU_js.b{constructor(t,c,n){super(t,c),this.originalError=n;}};function g(r=fetch){return async function(c,n){let a;try{a=await r(c,n);}catch(o){throw A(o,"A network error occured")}if(!a.ok){let o;try{o=await a.json();}catch(e){throw A(e,"A network error occured while reading response")}throw new chunkSHYKLQMU_js.b(o?.message??`Failed to fetch ${a.status} ${a.statusText}`,o?.errorName,o?.errorCode,a.status,o?.errorInstanceId,o?.parameters)}return a}}function A(r,t="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(t,"UNKNOWN")}function w(r){return r!=null?JSON.stringify(r):void 0}function y(r=fetch){return r=chunkSHYKLQMU_js.a(r,t=>(t.set("Content-Type","application/json"),t)),async function(c,n){return (await r(c,{...n,body:w(n.body)})).json()}}function h(r,t,c,n=fetch){let a=chunkSHYKLQMU_js.a(chunkSHYKLQMU_js.c(g(n)),async o=>{let e=await c();return o.set("Authorization",`Bearer ${e}`),o.set("Fetch-User-Agent",r.metadata.userAgent),o});return {ontology:r,stack:t,fetch:a,fetchJson:y(a)}}var T="searchAround_";function p(r,t,c,n={type:"base",objectType:r}){let a={aggregate:e=>{throw "TODO"},aggregateOrThrow:async e=>chunkEVOZ7UGO_js.c(t,r,e),fetchPage:async e=>{throw "TODO"},fetchPageOrThrow:async e=>chunkEVOZ7UGO_js.d(t,r,e??{},n),asyncIter:()=>{throw ""},where:e=>p(r,t,c,{type:"filter",objectSet:n,where:chunkEVOZ7UGO_js.a(e)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(e,i){return o(e)().where(i?.$where??{})}};function o(e){return ()=>p(r,t,{},{type:"searchAround",objectSet:n,link:e})}return new Proxy(a,{get(e,i,O){return typeof i=="string"&&i.startsWith(T)?o(i.substring(T.length)):e[i]}})}function F(r){return new Proxy({},{get:(t,c,n)=>{if(typeof c=="string")return r.objectSet(c)}})}function b(r,t,c,n=fetch){let a=h(r,t,c,n),o=(i,O)=>p(i,a,O),e=Object.defineProperties({},{objectSet:{get:()=>o},objects:{get:()=>F(e)}});return e}function C(r){return r.type==="ok"}
8
8
 
9
9
  Object.defineProperty(exports, 'Objects', {
10
10
  enumerable: true,
11
- get: function () { return chunkSM47N47Q_js.e; }
11
+ get: function () { return chunkEVOZ7UGO_js.e; }
12
12
  });
13
13
  Object.defineProperty(exports, 'createOpenApiRequest', {
14
14
  enumerable: true,
15
- get: function () { return chunkSM47N47Q_js.b; }
15
+ get: function () { return chunkEVOZ7UGO_js.b; }
16
16
  });
17
17
  exports.createClient = b;
18
18
  exports.createThinClient = h;
@@ -1,5 +1,5 @@
1
- import { c as c$1, d, a as a$1 } from './chunk-TPXDMNRT.mjs';
2
- export { e as Objects, b as createOpenApiRequest } from './chunk-TPXDMNRT.mjs';
1
+ import { c as c$1, d, a as a$1 } from './chunk-BYTHMUUS.mjs';
2
+ export { e as Objects, b as createOpenApiRequest } from './chunk-BYTHMUUS.mjs';
3
3
  import { a, c, b as b$1 } from './chunk-BZ6L26S2.mjs';
4
4
  import './chunk-XIJ2ZQRX.mjs';
5
5
 
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkSM47N47Q_js = require('../chunk-SM47N47Q.js');
3
+ var chunkEVOZ7UGO_js = require('../chunk-EVOZ7UGO.js');
4
4
  require('../chunk-4D6JZ4TL.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, 'aggregateOrThrow', {
9
9
  enumerable: true,
10
- get: function () { return chunkSM47N47Q_js.c; }
10
+ get: function () { return chunkEVOZ7UGO_js.c; }
11
11
  });
12
12
  Object.defineProperty(exports, 'fetchPageOrThrow', {
13
13
  enumerable: true,
14
- get: function () { return chunkSM47N47Q_js.d; }
14
+ get: function () { return chunkEVOZ7UGO_js.d; }
15
15
  });
16
16
  //# sourceMappingURL=out.js.map
17
17
  //# sourceMappingURL=objects.js.map
@@ -1,4 +1,4 @@
1
- export { c as aggregateOrThrow, d as fetchPageOrThrow } from '../chunk-TPXDMNRT.mjs';
1
+ export { c as aggregateOrThrow, d as fetchPageOrThrow } from '../chunk-BYTHMUUS.mjs';
2
2
  import '../chunk-XIJ2ZQRX.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=objects.mjs.map
@@ -0,0 +1,7 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "../ontology";
2
+ /**
3
+ * Creates a getter function that caches based on the ontology.objects[type] value
4
+ *
5
+ * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching
6
+ */
7
+ export declare function createCachedOntologyTransform<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, T>(creator: (ontology: O, type: K) => T): (ontology: O, type: K) => T;
@@ -0,0 +1,4 @@
1
+ import type { OntologyObjectV2 } from "@osdk/gateway/types";
2
+ import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom } from "../../ontology";
3
+ import type { ThinClient } from "../ThinClient";
4
+ export declare function convertWireToOsdkObjects<T_ClientApiName extends ObjectTypesFrom<T_OntologyDefinition> & string, T_OntologyDefinition extends OntologyDefinition<any>>(client: ThinClient<T_OntologyDefinition>, apiName: T_ClientApiName, objs: OntologyObjectV2[]): OsdkObjectFrom<T_ClientApiName, T_OntologyDefinition, PropertyKeysFrom<T_OntologyDefinition, T_ClientApiName>>[];
@@ -2,8 +2,8 @@ export { createClient, createThinClient, isOk } from "./client";
2
2
  export type { Client, ObjectSet, ResultOrError, ThinClient } from "./client";
3
3
  export { createOpenApiRequest } from "./client/createOpenApiRequest";
4
4
  export type { WhereClause } from "./client/query";
5
- export type { OsdkObject } from "./ontology";
5
+ export type { OsdkObject, OsdkObjectFrom } from "./ontology";
6
6
  export * as Objects from "./client/object";
7
7
  export type { LinkDefinitionFrom, LinkKeysFrom, LinkTargetTypeFrom, ObjectDefinition, ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinition, PropertyDefinitionFrom, PropertyDefinitionsFrom, PropertyKeysFrom, ValidPropertyTypes, } from "./ontology/Definition";
8
8
  export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ValidActionParameterTypes, } from "./ontology/ActionDefinition";
9
- export type { QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalQueryAggregationDefinition, } from "./ontology/QueryDefinition";
9
+ export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./ontology/QueryDefinition";
@@ -15,7 +15,7 @@ export interface OntologyDefinition<K extends string, A extends string = any, Q
15
15
  [AA in A]: ActionDefinition<AA, K>;
16
16
  };
17
17
  queries: {
18
- [QQ in Q]: QueryDefinition<Q>;
18
+ [QQ in Q]: QueryDefinition<QQ, K>;
19
19
  };
20
20
  }
21
21
  export interface ObjectDefinition<K extends string, L extends string> {
@@ -42,11 +42,11 @@ export interface PropertyDefinition {
42
42
  }
43
43
  export interface ValidPropertyTypes {
44
44
  string: string;
45
- datetime: Date;
45
+ datetime: string;
46
46
  double: number;
47
47
  boolean: boolean;
48
48
  integer: number;
49
- timestamp: Date;
49
+ timestamp: string;
50
50
  short: number;
51
51
  long: number;
52
52
  float: number;
@@ -55,12 +55,17 @@ export interface ValidPropertyTypes {
55
55
  numericTimeseries: any;
56
56
  stringTimeseries: any;
57
57
  attachment: any;
58
- geopoint: any;
59
- geoshape: any;
58
+ geopoint: GeoJSON.Point;
59
+ geoshape: GeoJSON.Geometry;
60
60
  }
61
- type MaybeArray<T extends PropertyDefinition, U> = T["multiplicity"] extends true ? Array<U> : U;
61
+ type MaybeArray<T extends {
62
+ multiplicity?: boolean | undefined;
63
+ }, U> = T["multiplicity"] extends true ? Array<U> : U;
62
64
  type MaybeNullable<T extends PropertyDefinition, U> = T["nullable"] extends true ? U | undefined : U;
63
- export type OsdkObjectPropertyType<T extends PropertyDefinition> = MaybeNullable<T, MaybeArray<T, ValidPropertyTypes[T["type"]]>>;
64
- export type OsdkObjectLink<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = T["multiplicity"] extends true ? Array<OsdkObjectLink_Inner<K, O, T>> : OsdkObjectLink_Inner<K, O, T>;
65
+ type Raw<T> = T extends Array<any> ? T[0] : T;
66
+ type Converted<T> = T extends Array<any> ? T[1] : T;
67
+ export type OsdkObjectPropertyType<T extends PropertyDefinition> = MaybeNullable<T, MaybeArray<T, Converted<ValidPropertyTypes[T["type"]]>>>;
68
+ export type OsdkObjectRawPropertyType<T extends PropertyDefinition> = MaybeNullable<T, MaybeArray<T, Raw<ValidPropertyTypes[T["type"]]>>>;
69
+ export type OsdkObjectLink<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = MaybeArray<T, OsdkObjectLink_Inner<K, O, T>>;
65
70
  type OsdkObjectLink_Inner<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = T["targetType"] extends keyof O["objects"] ? O["objects"][T["targetType"]] : never;
66
71
  export {};
@@ -1,3 +1,3 @@
1
1
  export type OsdkObject<N extends string> = {
2
- __name: N;
2
+ __apiName: N;
3
3
  };
@@ -1,6 +1,14 @@
1
1
  import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyKeysFrom } from "./Definition";
2
- export type OsdkObjectFrom<K extends ObjectTypesFrom<T>, T extends OntologyDefinition<any>, PP extends PropertyKeysFrom<T, K>> = {
3
- [P in PP]: OsdkObjectPropertyType<ObjectInfoFrom<T, K>["properties"][P]>;
2
+ export type OsdkObjectFrom<T_ObjectTypeKey extends ObjectTypesFrom<T_Ontology>, T_Ontology extends OntologyDefinition<any>, T_PropertyKeys extends PropertyKeysFrom<T_Ontology, T_ObjectTypeKey> = PropertyKeysFrom<T_Ontology, T_ObjectTypeKey>> = {
3
+ [P in T_PropertyKeys]: OsdkObjectPropertyType<ObjectInfoFrom<T_Ontology, T_ObjectTypeKey>["properties"][P]>;
4
4
  } & {
5
- __name: K;
5
+ /**@deprecated Use __apiName */
6
+ __name: T_ObjectTypeKey;
7
+ __apiName: T_ObjectTypeKey;
8
+ __primaryKey: ObjectInfoFrom<T_Ontology, T_ObjectTypeKey>["primaryKeyType"];
9
+ /**
10
+ * Future versions will require explicitly asking for this field. For now we are marking
11
+ * as always optional to avoid breaking changes.
12
+ */
13
+ __rid?: string;
6
14
  };
@@ -1,22 +1,22 @@
1
- export interface QueryDefinition<Q extends string> {
1
+ export interface QueryDefinition<Q extends string, K extends string> {
2
2
  apiName: Q;
3
3
  description?: string;
4
4
  displayName?: string;
5
5
  rid: string;
6
6
  version: string;
7
- parameters: Record<string, QueryParameterDefinition>;
8
- output: QueryDataTypeDefinition;
7
+ parameters: Record<string, QueryParameterDefinition<K>>;
8
+ output: QueryDataTypeDefinition<K>;
9
9
  }
10
- export interface QueryParameterDefinition {
10
+ export interface QueryParameterDefinition<K extends string> {
11
11
  description?: string;
12
- dataType: QueryDataTypeDefinition;
12
+ dataType: QueryDataTypeDefinition<K>;
13
13
  }
14
- export interface QueryDataTypeDefinition {
15
- type: QueryDataType;
14
+ export interface QueryDataTypeDefinition<K extends string> {
15
+ type: QueryDataType<K>;
16
16
  multiplicity?: boolean;
17
17
  nullable?: boolean;
18
18
  }
19
- export type QueryDataType = keyof ValidBaseQueryDataTypes | ObjectQueryDataType<any> | ObjectSetQueryDataType<any> | SetQueryDataType | UnionQueryDataType | StructQueryDataType | TwoDimensionalAggregationDataType | ThreeDimensionalAggregationDataType;
19
+ export type QueryDataType<K extends string> = keyof ValidBaseQueryDataTypes | ObjectQueryDataType<K> | ObjectSetQueryDataType<K> | SetQueryDataType<K> | UnionQueryDataType<K> | StructQueryDataType<K> | TwoDimensionalAggregationDataType | ThreeDimensionalAggregationDataType;
20
20
  export interface ValidBaseQueryDataTypes {
21
21
  double: number;
22
22
  float: number;
@@ -36,20 +36,17 @@ export interface ObjectSetQueryDataType<K extends string> {
36
36
  type: "objectSet";
37
37
  objectSet: K;
38
38
  }
39
- export interface SetQueryDataType {
39
+ export interface SetQueryDataType<K extends string> {
40
40
  type: "set";
41
- set: QueryDataTypeDefinition;
41
+ set: QueryDataTypeDefinition<K>;
42
42
  }
43
- export interface UnionQueryDataType {
43
+ export interface UnionQueryDataType<K extends string> {
44
44
  type: "union";
45
- union: ReadonlyArray<QueryDataTypeDefinition>;
45
+ union: ReadonlyArray<QueryDataTypeDefinition<K>>;
46
46
  }
47
- export interface StructQueryDataType {
47
+ export interface StructQueryDataType<K extends string> {
48
48
  type: "struct";
49
- struct: ReadonlyArray<{
50
- name: string;
51
- fieldType: QueryDataTypeDefinition;
52
- }>;
49
+ struct: Record<string, QueryDataTypeDefinition<K>>;
53
50
  }
54
51
  export interface TwoDimensionalAggregationDataType {
55
52
  type: "twoDimensionalAggregation";
@@ -59,19 +56,17 @@ export interface ThreeDimensionalAggregationDataType {
59
56
  type: "threeDimensionalAggregation";
60
57
  threeDimensionalAggregation: ThreeDimensionalQueryAggregationDefinition;
61
58
  }
62
- export type TwoDimensionalQueryAggregationDefinition = {
63
- valueType: "date" | "double" | "timestamp";
64
- } & ({
65
- keyType: "boolean" | "date" | "double" | "integer" | "string" | "timestamp";
66
- } | {
59
+ export type AggregationKeyDataType = SimpleAggregationKeyDataType | RangeAggregationKeyDataType;
60
+ export interface SimpleAggregationKeyDataType {
61
+ keyType: "boolean" | "string";
62
+ }
63
+ export interface RangeAggregationKeyDataType {
67
64
  keyType: "range";
68
65
  keySubtype: "date" | "double" | "integer" | "timestamp";
69
- });
70
- export type ThreeDimensionalQueryAggregationDefinition = {
66
+ }
67
+ export type TwoDimensionalQueryAggregationDefinition = AggregationKeyDataType & {
68
+ valueType: "date" | "double" | "timestamp";
69
+ };
70
+ export type ThreeDimensionalQueryAggregationDefinition = AggregationKeyDataType & {
71
71
  valueType: TwoDimensionalQueryAggregationDefinition;
72
- } & ({
73
- keyType: "boolean" | "date" | "double" | "integer" | "string" | "timestamp";
74
- } | {
75
- keyType: "range";
76
- keySubtype: "date" | "double" | "integer" | "timestamp";
77
- });
72
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/api",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -17,9 +17,10 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
+ "@types/geojson": "^7946.0.13",
20
21
  "fetch-retry": "^5.0.6",
21
22
  "tiny-invariant": "^1.3.1",
22
- "@osdk/gateway": "0.0.2"
23
+ "@osdk/gateway": "0.0.3"
23
24
  },
24
25
  "devDependencies": {
25
26
  "ts-expect": "^1.3.0",
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk4D6JZ4TL_js = require('./chunk-4D6JZ4TL.js');
4
- var requests = require('@osdk/gateway/requests');
5
- var a = require('tiny-invariant');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var a__default = /*#__PURE__*/_interopDefault(a);
10
-
11
- function g(n,o,e="/api",t){return async function(u,s,w,A,E,O,l){let y=new URL(`${e}${s}`,B(n));for(let[f,i]of Object.entries(A||{}))if(Array.isArray(i))for(let j of i)y.searchParams.append(f,j);else y.searchParams.append(f,i);let c=new Headers;O!=null&&c.set("Content-Type",O),l!=null&&c.set("Accept",l),Object.entries(E||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());});let $=L(w),m=await o(y.toString(),{body:$,method:u,headers:c});return l&&l==="*/*"?t?m.body:m.blob():m.json()}}function L(n){return n==null||globalThis.Blob&&n instanceof globalThis.Blob?n:JSON.stringify(n)}function B(n){let o=/^https?:\/\//i,e="https://";return o.test(n)?n.replace(/^http:\/\//i,e):`${e}${n}`}function d(n){return n.metrics.reduce((o,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 o||(o[t[0]]={}),o[t[0]][t[1]]=e.value,o},{})}function h(n){return Object.entries(n).flatMap(([o,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${o}.${t}`,field:o})):[{type:e,name:`${o}.${e}`,field:o}])}function v(n){return n?Object.entries(n).flatMap(([o,e])=>e==="exact"?[{type:e,field:o}]:e.exactWithLimit?[{type:"exact",field:o,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(n){if("$and"in n)return {type:"and",value:n.$and.map(p)};if("$or"in n)return {type:"or",value:n.$or.map(p)};if("$not"in n)return {type:"not",value:p(n.$not)};let o=Object.entries(n);if(o.length===1){let[e,t]=o[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 r=Object.keys(t)[0];return t[r]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),r==="ne"?{type:"not",value:{type:"eq",field:e,value:t[r]}}:{type:r,field:e,value:t[r]}}return {type:"and",value:Object.entries(n).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 r=Object.keys(t)[0];return t[r]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),r==="ne"?{type:"not",value:{type:"eq",field:e,value:t[r]}}:{type:r,field:e,value:t[r]}})}}async function N(n,o,e){let t={aggregation:h(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=v(e.groupBy)),e.where&&(t.where=p(e.where));let r=await requests.aggregateObjectsV2(g(n.stack,n.fetch),n.ontology.metadata.ontologyApiName,o,t);return e.groupBy?r.data.map(s=>({group:s.group,values:d(s)})):(r.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)),d(r.data[0]))}async function T(n,o,e,t={type:"base",objectType:o}){let r={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(r.pageToken=e.nextPageToken);let u=await requests.loadObjectSetV2(g(n.stack,n.fetchJson),n.ontology.metadata.ontologyApiName,r);return {data:u.data.map(s=>({...s,__name:o})),nextPageToken:u.nextPageToken}}var P={};chunk4D6JZ4TL_js.a(P,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
12
-
13
- exports.a = p;
14
- exports.b = g;
15
- exports.c = N;
16
- exports.d = T;
17
- exports.e = P;
18
- //# sourceMappingURL=out.js.map
19
- //# sourceMappingURL=chunk-SM47N47Q.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../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/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","result","loadObjectSetV2","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"wCAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAW,GAAGG,CAAY,GAAIO,EAAUZ,CAAQ,CAAC,EACxE,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQP,GAAkB,CAAC,CAAC,EAC5D,GAAI,MAAM,QAAQO,CAAK,EACrB,QAAWC,KAAQD,EACjBH,EAAI,aAAa,OAAOE,EAAKE,CAAI,OAGnCJ,EAAI,aAAa,OAAOE,EAAKC,CAAK,EAGtC,IAAME,EAAc,IAAI,QACpBP,GAAoB,MACtBO,EAAY,IAAI,eAAgBP,CAAgB,EAE9CC,GAAqB,MACvBM,EAAY,IAAI,SAAUN,CAAiB,EAE7C,OAAO,QAAQF,GAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAACK,EAAKC,CAAK,IAAM,CAClDA,GAAS,MACXE,EAAY,OAAOH,EAAKC,EAAM,SAAS,CAAC,CAE5C,CAAC,EACD,IAAMG,EAAOC,EAAQZ,CAAI,EACnBa,EAAW,MAAMlB,EAAQU,EAAI,SAAS,EAAG,CAC7C,KAAAM,EACA,OAAQb,EACR,QAASY,CACX,CAAC,EACD,OAAIN,GAAqBA,IAAsB,MACzCP,EACKgB,EAAS,KAEXA,EAAS,KAAK,EAEhBA,EAAS,KAAK,CACvB,CACF,CACA,SAASD,EAAQD,EAAM,CAIrB,OAHIA,GAAQ,MAGR,WAAW,MAAQA,aAAgB,WAAW,KACzCA,EAEF,KAAK,UAAUA,CAAI,CAC5B,CACA,SAASL,EAAUD,E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,EAAG,CACD,IAAM3B,EAAO,CACX,UAAAkC,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRjC,EAAK,UAAYiC,EAAK,eAExB,IAAME,EAAI,MAAML,EAAgBhD,EAAqBkD,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBhC,CAAI,EACpI,MAAO,CACL,KAAMmC,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQT,CACV,EAAE,EACF,cAAeQ,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAZ,EAAA,qBAAAM","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\nexport function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions\";\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 invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\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\";"]}
@@ -1,9 +0,0 @@
1
- import { a } from './chunk-XIJ2ZQRX.mjs';
2
- import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
3
- import a$1 from 'tiny-invariant';
4
-
5
- function g(n,o,e="/api",t){return async function(u,s,w,A,E,O,l){let y=new URL(`${e}${s}`,B(n));for(let[f,i]of Object.entries(A||{}))if(Array.isArray(i))for(let j of i)y.searchParams.append(f,j);else y.searchParams.append(f,i);let c=new Headers;O!=null&&c.set("Content-Type",O),l!=null&&c.set("Accept",l),Object.entries(E||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());});let $=L(w),m=await o(y.toString(),{body:$,method:u,headers:c});return l&&l==="*/*"?t?m.body:m.blob():m.json()}}function L(n){return n==null||globalThis.Blob&&n instanceof globalThis.Blob?n:JSON.stringify(n)}function B(n){let o=/^https?:\/\//i,e="https://";return o.test(n)?n.replace(/^http:\/\//i,e):`${e}${n}`}function d(n){return n.metrics.reduce((o,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a$1(!1,"assumed we were getting a `${key}.${type}`"):a$1(!1)),t[0]in o||(o[t[0]]={}),o[t[0]][t[1]]=e.value,o},{})}function h(n){return Object.entries(n).flatMap(([o,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${o}.${t}`,field:o})):[{type:e,name:`${o}.${e}`,field:o}])}function v(n){return n?Object.entries(n).flatMap(([o,e])=>e==="exact"?[{type:e,field:o}]:e.exactWithLimit?[{type:"exact",field:o,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(n){if("$and"in n)return {type:"and",value:n.$and.map(p)};if("$or"in n)return {type:"or",value:n.$or.map(p)};if("$not"in n)return {type:"not",value:p(n.$not)};let o=Object.entries(n);if(o.length===1){let[e,t]=o[0];if(t==null&&(process.env.NODE_ENV!=="production"?a$1(!1,"Defined key values are only allowed when they are not undefined."):a$1(!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(!1,"WhereClause Filter with multiple properties isn't allowed"):a$1(!1));let r=Object.keys(t)[0];return t[r]==null&&(process.env.NODE_ENV!=="production"?a$1(!1):a$1(!1)),r==="ne"?{type:"not",value:{type:"eq",field:e,value:t[r]}}:{type:r,field:e,value:t[r]}}return {type:"and",value:Object.entries(n).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a$1(!1,"Defined key values are only allowed when they are not undefined."):a$1(!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(!1,"WhereClause Filter with multiple properties isn't allowed"):a$1(!1));let r=Object.keys(t)[0];return t[r]==null&&(process.env.NODE_ENV!=="production"?a$1(!1):a$1(!1)),r==="ne"?{type:"not",value:{type:"eq",field:e,value:t[r]}}:{type:r,field:e,value:t[r]}})}}async function N(n,o,e){let t={aggregation:h(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=v(e.groupBy)),e.where&&(t.where=p(e.where));let r=await aggregateObjectsV2(g(n.stack,n.fetch),n.ontology.metadata.ontologyApiName,o,t);return e.groupBy?r.data.map(s=>({group:s.group,values:d(s)})):(r.data.length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"no group by clause should mean only one data result"):a$1(!1)),d(r.data[0]))}async function T(n,o,e,t={type:"base",objectType:o}){let r={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(r.pageToken=e.nextPageToken);let u=await loadObjectSetV2(g(n.stack,n.fetchJson),n.ontology.metadata.ontologyApiName,r);return {data:u.data.map(s=>({...s,__name:o})),nextPageToken:u.nextPageToken}}var P={};a(P,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
6
-
7
- export { p as a, g as b, N as c, T as d, P as e };
8
- //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-TPXDMNRT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../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/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","result","loadObjectSetV2","fetchPageOrThrow","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AAI,MAAML,EAAgBhD,EAAqBkD,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBhC,CAAI,EACpI,MAAO,CACL,KAAMmC,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQT,CACV,EAAE,EACF,cAAeQ,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAZ,EAAA,qBAAAM","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\nexport function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions\";\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 invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\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\";"]}