@osdk/client 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/build/js/chunk-6NFYRRQY.mjs +9 -0
  3. package/build/js/chunk-6NFYRRQY.mjs.map +1 -0
  4. package/build/js/chunk-AEQM3CTL.js +18 -0
  5. package/build/js/chunk-AEQM3CTL.js.map +1 -0
  6. package/build/js/index.js +10 -0
  7. package/build/js/index.js.map +1 -1
  8. package/build/js/index.mjs +6 -0
  9. package/build/js/index.mjs.map +1 -1
  10. package/build/js/public/objects.js +16 -0
  11. package/build/js/public/objects.js.map +1 -0
  12. package/build/js/public/objects.mjs +3 -0
  13. package/build/js/public/objects.mjs.map +1 -0
  14. package/build/types/Client.d.ts +8 -0
  15. package/build/types/ObjectSetCreator.d.ts +15 -0
  16. package/build/types/PageResult.d.ts +5 -0
  17. package/build/types/createCachedOntologyTransform.d.ts +7 -0
  18. package/build/types/createClient.d.ts +3 -0
  19. package/build/types/index.d.ts +5 -1
  20. package/build/types/internal/conversions/index.d.ts +4 -0
  21. package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts +4 -0
  22. package/build/types/internal/conversions/modernToLegacyAggregationClause.d.ts +4 -0
  23. package/build/types/internal/conversions/modernToLegacyGroupByClause.d.ts +4 -0
  24. package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +4 -0
  25. package/build/types/internal/net/V2_BASE.d.ts +1 -0
  26. package/build/types/internal/net/index.d.ts +1 -0
  27. package/build/types/internal/net/types.d.ts +357 -0
  28. package/build/types/object/aggregateOrThrow.d.ts +4 -0
  29. package/build/types/object/aggregateOrThrow.test.d.ts +1 -0
  30. package/build/types/object/convertWireToOsdkObjects.d.ts +3 -0
  31. package/build/types/object/fetchPageOrThrow.d.ts +9 -0
  32. package/build/types/object/index.d.ts +2 -0
  33. package/build/types/objectSet/LinkTypesFrom.d.ts +2 -0
  34. package/build/types/objectSet/ObjectSet.d.ts +24 -0
  35. package/build/types/objectSet/createObjectSet.d.ts +4 -0
  36. package/build/types/public/objects.d.ts +1 -0
  37. package/build/types/query/WhereClause.d.ts +24 -0
  38. package/build/types/query/aggregations/AggregatableKeys.d.ts +4 -0
  39. package/build/types/query/aggregations/AggregateOpts.d.ts +7 -0
  40. package/build/types/query/aggregations/AggregationResultsWithGroups.d.ts +10 -0
  41. package/build/types/query/aggregations/AggregationResultsWithoutGroups.d.ts +10 -0
  42. package/build/types/query/aggregations/AggregationsClause.d.ts +8 -0
  43. package/build/types/query/aggregations/AggregationsClause.test.d.ts +42 -0
  44. package/build/types/query/aggregations/AggregationsResults.d.ts +5 -0
  45. package/build/types/query/aggregations/AggregationsResults.test.d.ts +1 -0
  46. package/build/types/query/aggregations/GroupByClause.d.ts +12 -0
  47. package/build/types/query/aggregations/GroupByClause.test.d.ts +21 -0
  48. package/build/types/query/aggregations/GroupByMapper.d.ts +4 -0
  49. package/build/types/query/index.d.ts +7 -0
  50. package/build/types/util/ArrayElement.d.ts +1 -0
  51. package/build/types/util/NOOP.d.ts +3 -0
  52. package/build/types/util/StringArrayToUnion.d.ts +1 -0
  53. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 0.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - dfc2b94: Fix OAuth login process
8
+ - Updated dependencies [dfc2b94]
9
+ - @osdk/gateway@0.0.5
10
+ - @osdk/api@0.0.12
11
+
12
+ ## 0.0.4
13
+
14
+ ### Patch Changes
15
+
16
+ - f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatability in @osdk/api"
17
+ - 848404c: Handle conflicts between object, action, and query names
18
+ - Updated dependencies [f3120fb]
19
+ - Updated dependencies [848404c]
20
+ - @osdk/gateway@0.0.4
21
+ - @osdk/api@0.0.11
22
+
3
23
  ## 0.0.3
4
24
 
5
25
  ### Patch Changes
@@ -0,0 +1,9 @@
1
+ import { createOpenApiRequest } from '@osdk/api';
2
+ import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
3
+ import a from 'tiny-invariant';
4
+
5
+ var O=Object.defineProperty;var b=(o,r)=>{for(var t in r)O(o,t,{get:r[t],enumerable:!0});};function p(o){return o.metrics.reduce((r,t)=>{let e=t.name.split(".");return e.length!=2&&(process.env.NODE_ENV!=="production"?a(!1,"assumed we were getting a `${key}.${type}`"):a(!1)),e[0]in r||(r[e[0]]={}),r[e[0]][e[1]]=t.value,r},{})}function u(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 l(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 i(o){if("$and"in o)return {type:"and",value:o.$and.map(i)};if("$or"in o)return {type:"or",value:o.$or.map(i)};if("$not"in o)return {type:"not",value:i(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,"Defined key values are only allowed when they are not undefined."):a(!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,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!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,"Defined key values are only allowed when they are not undefined."):a(!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,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}})}}async function d(o,r,t){let e={aggregation:u(t.select),groupBy:[],where:void 0};t.groupBy&&(e.groupBy=l(t.groupBy)),t.where&&(e.where=i(t.where));let n=await aggregateObjectsV2(createOpenApiRequest(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,e);return t.groupBy?n.data.map(c=>({group:c.group,values:p(c)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"no group by clause should mean only one data result"):a(!1)),p(n.data[0]))}function y(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 x=y(N);function N(o,r){o.objects[r];let e={};return Object.defineProperty(e,"__name",{value:r,enumerable:!1,configurable:!1,writable:!1}),e}function m(o,r,t){let e=x(o.ontology,r);for(let n of t)Object.setPrototypeOf(n,e);return t}async function v(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(createOpenApiRequest(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,n);return m(o,r,s.data),s}var w={};b(w,{aggregateOrThrow:()=>d,fetchPageOrThrow:()=>v});
6
+
7
+ export { i as a, d as b, v as c, w as d };
8
+ //# sourceMappingURL=out.js.map
9
+ //# sourceMappingURL=chunk-6NFYRRQY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/object/aggregateOrThrow.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/object/fetchPageOrThrow.ts","../../src/createCachedOntologyTransform.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/object/index.ts"],"names":["createOpenApiRequest","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","createCachedOntologyTransform","creator","cache","ontology","objectDefinition","getPrototype","createPrototype","objDef","proto","convertWireToOsdkObjects","client","apiName","objs","obj","fetchPageOrThrow","args","objectSet","r","object_exports","__export"],"mappings":"0FAgBA,OAAS,wBAAAA,MAA4B,YACrC,OAAS,sBAAAC,MAA0B,yBACnC,OAAOC,MAAe,iBCFtB,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,EAAYE,EAAM,CAAC,CAAC,EAAI,CAAC,GAE3BF,EAAYE,EAAM,CAAC,CAAC,EAAEA,EAAM,CAAC,CAAC,EAAID,EAAS,MACpCD,CACT,EAAG,CAAC,CAAC,CACP,CCXO,SAASG,EAAgCC,EAAQ,CACtD,OAAO,OAAO,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,EAAGC,CAAC,IACtC,MAAM,QAAQA,CAAC,EACVA,EAAE,IAAIC,IACJ,CACL,KAAMA,EACN,KAAM,GAAGF,CAAC,IAAIE,CAAE,GAChB,MAAOF,CACT,EACD,EAEM,CAAC,CACN,KAAMC,EAEN,KAAM,GAAGD,CAAC,IAAIC,CAAC,GACf,MAAOD,CACT,CAAC,CAEJ,CACH,CCnBO,SAASG,EAA4BC,EAAe,CACzD,OAAKA,EACE,OAAO,QAAQA,CAAa,EAAE,QAAQ,CAAC,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EAAA,sBAAAzB,EAAA,qBAAAqB","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createOpenApiRequest } from \"@osdk/api\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\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 { createOpenApiRequest } from \"@osdk/api\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\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,18 @@
1
+ 'use strict';
2
+
3
+ var api = require('@osdk/api');
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
+ var O=Object.defineProperty;var b=(o,r)=>{for(var t in r)O(o,t,{get:r[t],enumerable:!0});};function p(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 u(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 l(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 i(o){if("$and"in o)return {type:"and",value:o.$and.map(i)};if("$or"in o)return {type:"or",value:o.$or.map(i)};if("$not"in o)return {type:"not",value:i(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 d(o,r,t){let e={aggregation:u(t.select),groupBy:[],where:void 0};t.groupBy&&(e.groupBy=l(t.groupBy)),t.where&&(e.where=i(t.where));let n=await requests.aggregateObjectsV2(api.createOpenApiRequest(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,e);return t.groupBy?n.data.map(c=>({group:c.group,values:p(c)})):(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)),p(n.data[0]))}function y(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 x=y(N);function N(o,r){o.objects[r];let e={};return Object.defineProperty(e,"__name",{value:r,enumerable:!1,configurable:!1,writable:!1}),e}function m(o,r,t){let e=x(o.ontology,r);for(let n of t)Object.setPrototypeOf(n,e);return t}async function v(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(api.createOpenApiRequest(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,n);return m(o,r,s.data),s}var w={};b(w,{aggregateOrThrow:()=>d,fetchPageOrThrow:()=>v});
12
+
13
+ exports.a = i;
14
+ exports.b = d;
15
+ exports.c = v;
16
+ exports.d = w;
17
+ //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=chunk-AEQM3CTL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/object/aggregateOrThrow.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/object/fetchPageOrThrow.ts","../../src/createCachedOntologyTransform.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/object/index.ts"],"names":["createOpenApiRequest","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","createCachedOntologyTransform","creator","cache","ontology","objectDefinition","getPrototype","createPrototype","objDef","proto","convertWireToOsdkObjects","client","apiName","objs","obj","fetchPageOrThrow","args","objectSet","r","object_exports","__export"],"mappings":"0FAgBA,OAAS,wBAAAA,MAA4B,YACrC,OAAS,sBAAAC,MAA0B,yBACnC,OAAOC,MAAe,iBCFtB,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,EAAYE,EAAM,CAAC,CAAC,EAAI,CAAC,GAE3BF,EAAYE,EAAM,CAAC,CAAC,EAAEA,EAAM,CAAC,CAAC,EAAID,EAAS,MACpCD,CACT,EAAG,CAAC,CAAC,CACP,CCXO,SAASG,EAAgCC,EAAQ,CACtD,OAAO,OAAO,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,EAAGC,CAAC,IACtC,MAAM,QAAQA,CAAC,EACVA,EAAE,IAAIC,IACJ,CACL,KAAMA,EACN,KAAM,GAAGF,CAAC,IAAIE,CAAE,GAChB,MAAOF,CACT,EACD,EAEM,CAAC,CACN,KAAMC,EAEN,KAAM,GAAGD,CAAC,IAAIC,CAAC,GACf,MAAOD,CACT,CAAC,CAEJ,CACH,CCnBO,SAASG,EAA4BC,EAAe,CACzD,OAAKA,EACE,OAAO,QAAQA,CAAa,EAAE,QAAQ,CAAC,CAACC,EAAOC,CAAI,IACpDA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AAqB","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createOpenApiRequest } from \"@osdk/api\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\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 { createOpenApiRequest } from \"@osdk/api\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\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,4 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ var chunkAEQM3CTL_js = require('./chunk-AEQM3CTL.js');
4
+ var api = require('@osdk/api');
5
+
6
+ var m="searchAround_";function s(r,o,n,c={type:"base",objectType:r}){let i={aggregate:e=>{throw "TODO"},aggregateOrThrow:async e=>chunkAEQM3CTL_js.b(o,r,e),fetchPage:async e=>{throw "TODO"},fetchPageOrThrow:async e=>chunkAEQM3CTL_js.c(o,r,e??{},c),asyncIter:()=>{throw ""},where:e=>s(r,o,n,{type:"filter",objectSet:c,where:chunkAEQM3CTL_js.a(e)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(e,t){return a(e)().where(t?.$where??{})}};function a(e){return ()=>s(r,o,{},{type:"searchAround",objectSet:c,link:e})}return new Proxy(i,{get(e,t,u){return typeof t=="string"&&t.startsWith(m)?a(t.substring(m.length)):e[t]}})}function w(r){return new Proxy({},{get:(o,n,c)=>{if(typeof n=="string")return r.objectSet(n)}})}function b(r,o,n,c=fetch){let i=api.createThinClient(r,o,n,c),a=(t,u)=>s(t,i,u),e=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>w(e)}});return e}
7
+
8
+ Object.defineProperty(exports, 'Objects', {
9
+ enumerable: true,
10
+ get: function () { return chunkAEQM3CTL_js.d; }
11
+ });
12
+ exports.createClient = b;
3
13
  //# sourceMappingURL=out.js.map
4
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/createClient.ts","../../src/objectSet/createObjectSet.ts","../../src/ObjectSetCreator.ts"],"names":["createThinClient","searchAroundPrefix","createObjectSet","objectType","thinClient","opts","objectSet","base","req","aggregateOrThrow","args","fetchPageOrThrow","clause","modernToLegacyWhereClause","type","createSearchAround","link","target","p","receiver","createObjectSetCreator","client","createClient","ontology","stack","tokenProvider","fetchFn","objectSetFactory"],"mappings":"6DAgBA,OAAS,oBAAAA,MAAwB,YCEjC,IAAMC,EAAqB,gBACpB,SAASC,EAAgBC,EAAYC,EAAYC,EAAMC,EAAY,CACxE,KAAM,OACN,WAAAH,CACF,EAAG,CACD,IAAMI,EAAO,CACX,UAAWC,GAAO,CAChB,KAAM,MACR,EACA,iBAAkB,MAAMA,GACfC,EAAiBL,EAAYD,EAAYK,CAAG,EAErD,UAAW,M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AAuBC,CAAM,CAC1C,CACF,CAAC,EACD,OAAOA,CACT","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createThinClient } from \"@osdk/api\";\nimport { createObjectSet } from \"./objectSet/createObjectSet\";\nimport { createObjectSetCreator } from \"./ObjectSetCreator\";\nexport function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {\n const thinClient = createThinClient(ontology, stack, tokenProvider, fetchFn);\n const objectSetFactory = (type, opts) => createObjectSet(type, thinClient, opts);\n const client = Object.defineProperties({}, {\n objectSet: {\n get: () => objectSetFactory\n },\n objects: {\n get: () => createObjectSetCreator(client)\n }\n });\n return client;\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 { modernToLegacyWhereClause } from \"../internal/conversions\";\nimport { aggregateOrThrow, fetchPageOrThrow } from \"../object\";\nconst searchAroundPrefix = \"searchAround_\";\nexport function createObjectSet(objectType, thinClient, opts, objectSet = {\n type: \"base\",\n objectType\n}) {\n const base = {\n aggregate: req => {\n throw \"TODO\";\n },\n aggregateOrThrow: async req => {\n return aggregateOrThrow(thinClient, objectType, req);\n },\n fetchPage: async args => {\n throw \"TODO\";\n },\n fetchPageOrThrow: async args => {\n return fetchPageOrThrow(thinClient, objectType, args ?? {}, objectSet);\n },\n asyncIter: () => {\n throw \"\";\n },\n where: clause => {\n return createObjectSet(objectType, thinClient, opts, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause)\n });\n },\n [Symbol.asyncIterator]: () => {\n throw \"\";\n },\n pivotTo: function (type, opts) {\n return createSearchAround(type)().where(opts?.$where ?? {});\n }\n };\n function createSearchAround(link) {\n return () => {\n return createObjectSet(objectType, thinClient, {}, {\n type: \"searchAround\",\n objectSet,\n link\n });\n };\n }\n return new Proxy(base, {\n get(target, p, receiver) {\n if (typeof p === \"string\" && p.startsWith(searchAroundPrefix)) {\n return createSearchAround(p.substring(searchAroundPrefix.length));\n }\n return target[p];\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\n/**\n * A type that creates an object set for each object in the ontology.\n */\n\n/**\n * Create a proxy for the object set creator.\n * @param client The client to use to create the object sets.\n * @returns A proxy for the object set creator.\n */\nexport function createObjectSetCreator(client) {\n return new Proxy({}, {\n get: (target, p, receiver) => {\n if (typeof p === \"string\") return client.objectSet(p);\n return undefined;\n }\n });\n}"]}
@@ -1,3 +1,9 @@
1
+ import { b as b$1, c, a } from './chunk-6NFYRRQY.mjs';
2
+ export { d as Objects } from './chunk-6NFYRRQY.mjs';
3
+ import { createThinClient } from '@osdk/api';
1
4
 
5
+ var m="searchAround_";function s(r,o,n,c$1={type:"base",objectType:r}){let i={aggregate:e=>{throw "TODO"},aggregateOrThrow:async e=>b$1(o,r,e),fetchPage:async e=>{throw "TODO"},fetchPageOrThrow:async e=>c(o,r,e??{},c$1),asyncIter:()=>{throw ""},where:e=>s(r,o,n,{type:"filter",objectSet:c$1,where:a(e)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(e,t){return a$1(e)().where(t?.$where??{})}};function a$1(e){return ()=>s(r,o,{},{type:"searchAround",objectSet:c$1,link:e})}return new Proxy(i,{get(e,t,u){return typeof t=="string"&&t.startsWith(m)?a$1(t.substring(m.length)):e[t]}})}function w(r){return new Proxy({},{get:(o,n,c)=>{if(typeof n=="string")return r.objectSet(n)}})}function b(r,o,n,c=fetch){let i=createThinClient(r,o,n,c),a=(t,u)=>s(t,i,u),e=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>w(e)}});return e}
6
+
7
+ export { b as createClient };
2
8
  //# sourceMappingURL=out.js.map
3
9
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/createClient.ts","../../src/objectSet/createObjectSet.ts","../../src/ObjectSetCreator.ts"],"names":["createThinClient","searchAroundPrefix","createObjectSet","objectType","thinClient","opts","objectSet","base","req","aggregateOrThrow","args","fetchPageOrThrow","clause","modernToLegacyWhereClause","type","createSearchAround","link","target","p","receiver","createObjectSetCreator","client","createClient","ontology","stack","tokenProvider","fetchFn","objectSetFactory"],"mappings":"8DAgBA,OAAS,oBAAAA,MAAwB,YCEjC,IAAMC,EAAqB,gBACpB,SAASC,EAAgBC,EAAYC,EAAYC,EAAMC,EAAY,CACxE,KAAM,OACN,WAAAH,CACF,EAAG,CACD,IAAMI,EAAO,CACX,UAAWC,GAAO,CAChB,KAAM,MACR,EACA,iBAAkB,MAAMA,GACfC,EAAiBL,EAAYD,EAAYK,CAAG,EAErD,UAAW,MAAME,GAAQ,CACvB,KAAM,MACR,EACA,iBAAkB,MAAMA,GACfC,EAAiBP,EAA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right 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 { createThinClient } from \"@osdk/api\";\nimport { createObjectSet } from \"./objectSet/createObjectSet\";\nimport { createObjectSetCreator } from \"./ObjectSetCreator\";\nexport function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {\n const thinClient = createThinClient(ontology, stack, tokenProvider, fetchFn);\n const objectSetFactory = (type, opts) => createObjectSet(type, thinClient, opts);\n const client = Object.defineProperties({}, {\n objectSet: {\n get: () => objectSetFactory\n },\n objects: {\n get: () => createObjectSetCreator(client)\n }\n });\n return client;\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 { modernToLegacyWhereClause } from \"../internal/conversions\";\nimport { aggregateOrThrow, fetchPageOrThrow } from \"../object\";\nconst searchAroundPrefix = \"searchAround_\";\nexport function createObjectSet(objectType, thinClient, opts, objectSet = {\n type: \"base\",\n objectType\n}) {\n const base = {\n aggregate: req => {\n throw \"TODO\";\n },\n aggregateOrThrow: async req => {\n return aggregateOrThrow(thinClient, objectType, req);\n },\n fetchPage: async args => {\n throw \"TODO\";\n },\n fetchPageOrThrow: async args => {\n return fetchPageOrThrow(thinClient, objectType, args ?? {}, objectSet);\n },\n asyncIter: () => {\n throw \"\";\n },\n where: clause => {\n return createObjectSet(objectType, thinClient, opts, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause)\n });\n },\n [Symbol.asyncIterator]: () => {\n throw \"\";\n },\n pivotTo: function (type, opts) {\n return createSearchAround(type)().where(opts?.$where ?? {});\n }\n };\n function createSearchAround(link) {\n return () => {\n return createObjectSet(objectType, thinClient, {}, {\n type: \"searchAround\",\n objectSet,\n link\n });\n };\n }\n return new Proxy(base, {\n get(target, p, receiver) {\n if (typeof p === \"string\" && p.startsWith(searchAroundPrefix)) {\n return createSearchAround(p.substring(searchAroundPrefix.length));\n }\n return target[p];\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\n/**\n * A type that creates an object set for each object in the ontology.\n */\n\n/**\n * Create a proxy for the object set creator.\n * @param client The client to use to create the object sets.\n * @returns A proxy for the object set creator.\n */\nexport function createObjectSetCreator(client) {\n return new Proxy({}, {\n get: (target, p, receiver) => {\n if (typeof p === \"string\") return client.objectSet(p);\n return undefined;\n }\n });\n}"]}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunkAEQM3CTL_js = require('../chunk-AEQM3CTL.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, 'aggregateOrThrow', {
8
+ enumerable: true,
9
+ get: function () { return chunkAEQM3CTL_js.b; }
10
+ });
11
+ Object.defineProperty(exports, 'fetchPageOrThrow', {
12
+ enumerable: true,
13
+ get: function () { return chunkAEQM3CTL_js.c; }
14
+ });
15
+ //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { b as aggregateOrThrow, c as fetchPageOrThrow } from '../chunk-6NFYRRQY.mjs';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=objects.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ import type { ObjectSet, ObjectSetOptions } from "./objectSet/ObjectSet";
3
+ import type { ObjectSetCreator } from "./ObjectSetCreator";
4
+ export type ConcreteObjectType<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = O["objects"][K];
5
+ export interface Client<O extends OntologyDefinition<any>> {
6
+ objectSet: <const K extends ObjectTypesFrom<O>>(type: K, opts?: ObjectSetOptions<O, K>) => ObjectSet<O, K>;
7
+ objects: ObjectSetCreator<O>;
8
+ }
@@ -0,0 +1,15 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ import type { Client } from "./Client";
3
+ import type { ObjectSet } from "./objectSet/ObjectSet";
4
+ /**
5
+ * A type that creates an object set for each object in the ontology.
6
+ */
7
+ export type ObjectSetCreator<D extends OntologyDefinition<any>> = {
8
+ [T in ObjectTypesFrom<D>]: ObjectSet<D, T>;
9
+ };
10
+ /**
11
+ * Create a proxy for the object set creator.
12
+ * @param client The client to use to create the object sets.
13
+ * @returns A proxy for the object set creator.
14
+ */
15
+ export declare function createObjectSetCreator<T extends Client<any>>(client: T): {};
@@ -0,0 +1,5 @@
1
+ import type { OsdkObject } from "@osdk/api";
2
+ export interface PageResult<T extends OsdkObject<any>> {
3
+ data: T[];
4
+ nextPageToken: string | undefined;
5
+ }
@@ -0,0 +1,7 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
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,3 @@
1
+ import type { OntologyDefinition } from "@osdk/api";
2
+ import type { Client } from "./Client";
3
+ export declare function createClient<O extends OntologyDefinition<any>>(ontology: O, stack: string, tokenProvider: () => Promise<string> | string, fetchFn?: typeof globalThis.fetch): Client<O>;
@@ -1 +1,5 @@
1
- export {};
1
+ export type { Client } from "./Client";
2
+ export { createClient } from "./createClient";
3
+ export type { ObjectSet } from "./objectSet/ObjectSet";
4
+ export type { PageResult } from "./PageResult";
5
+ export * as Objects from "./object/index";
@@ -0,0 +1,4 @@
1
+ export { legacyToModernSingleAggregationResult } from "./legacyToModernSingleAggregationResult";
2
+ export { modernToLegacyAggregationClause } from "./modernToLegacyAggregationClause";
3
+ export { modernToLegacyGroupByClause } from "./modernToLegacyGroupByClause";
4
+ export { modernToLegacyWhereClause } from "./modernToLegacyWhereClause";
@@ -0,0 +1,4 @@
1
+ import type { AggregationClause, AggregationResultsWithoutGroups } from "../../query";
2
+ import type { ArrayElement } from "../../util/ArrayElement";
3
+ import type { Wire } from "../net";
4
+ export declare function legacyToModernSingleAggregationResult<AC extends AggregationClause<any, any>>(entry: ArrayElement<Wire.AggregateObjectsResponseV2["data"]>): AggregationResultsWithoutGroups<any, any, AC>;
@@ -0,0 +1,4 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ import type { Aggregation } from "@osdk/gateway/types";
3
+ import type { AggregationClause } from "../../query";
4
+ export declare function modernToLegacyAggregationClause<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>>(select: AC): Aggregation[];
@@ -0,0 +1,4 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ import type { AggregationGroupByV2 } from "@osdk/gateway/types";
3
+ import type { GroupByClause } from "../../query";
4
+ export declare function modernToLegacyGroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(groupByClause: GroupByClause<O, K> | undefined): AggregationGroupByV2[];
@@ -0,0 +1,4 @@
1
+ import type { ObjectDefinition } from "@osdk/api";
2
+ import type { WhereClause } from "../../query";
3
+ import type { Wire } from "../net";
4
+ export declare function modernToLegacyWhereClause<T extends ObjectDefinition<any, any>>(whereClause: WhereClause<T>): Wire.SearchJsonQueryV2;
@@ -0,0 +1 @@
1
+ export declare const V2_BASE = "api/v2/ontologies";
@@ -0,0 +1 @@
1
+ export * as Wire from "./types";
@@ -0,0 +1,357 @@
1
+ export interface AggregationClause {
2
+ type: string;
3
+ field?: string;
4
+ name: string;
5
+ }
6
+ export type AggregationValueType = number | string | boolean;
7
+ export type BaseGroupValue = number | string | boolean;
8
+ export type Bucketing<T> = {
9
+ startValue?: T;
10
+ endValue: T;
11
+ } | {
12
+ startValue: T;
13
+ endValue?: T;
14
+ };
15
+ export type GroupValue = BaseGroupValue | Bucketing<BaseGroupValue>;
16
+ export interface WhereClauseV2 {
17
+ type: string;
18
+ field?: string;
19
+ value?: string | number | BoundingBoxFilter | PolyGonGeoJson | DistanceOf | boolean | WhereClauseV2 | WhereClauseV2[];
20
+ }
21
+ export type BoundingBoxFilter = {
22
+ topLeft: PointGeoJson;
23
+ bottomRight: PointGeoJson;
24
+ };
25
+ export type PolyGonGeoJson = {
26
+ type: "Polygon";
27
+ coordinates: number[][][];
28
+ };
29
+ export type DistanceOf = {
30
+ center: PointGeoJson;
31
+ distance: {
32
+ value: number;
33
+ unit: string;
34
+ };
35
+ };
36
+ export type PointGeoJson = {
37
+ type: "Point";
38
+ coordinates: number[];
39
+ };
40
+ export interface SearchClauseV2 {
41
+ where?: WhereClauseV2;
42
+ orderBy?: {
43
+ fields: OrderByClause[];
44
+ };
45
+ pageSize?: number;
46
+ pageToken?: string;
47
+ }
48
+ export interface OrderByClause {
49
+ field: string;
50
+ direction: string;
51
+ }
52
+ export type GroupByClause = GroupByExact | GroupByFixedWidth | GroupByDuration | GroupByRanges;
53
+ export type GroupByExact = {
54
+ type: "exact";
55
+ field: string;
56
+ maxGroupCount?: number;
57
+ };
58
+ export type GroupByFixedWidth = {
59
+ type: "fixedWidth";
60
+ field: string;
61
+ fixedWidth: number;
62
+ };
63
+ export type TimeUnit = "MILLISECONDS" | "SECONDS" | "MINUTES" | "HOURS" | "DAYS" | "WEEKS" | "MONTHS" | "YEARS" | "QUARTERS";
64
+ export type GroupByDuration = {
65
+ type: "duration";
66
+ field: string;
67
+ unit: TimeUnit;
68
+ value: number;
69
+ };
70
+ export type GroupByRanges = {
71
+ type: "ranges";
72
+ field: string;
73
+ ranges: Array<{
74
+ startValue?: string | number;
75
+ endValue: string | number;
76
+ } | {
77
+ startValue: string | number;
78
+ endValue?: string | number;
79
+ }>;
80
+ };
81
+ export interface AggregateObjectsV2Body {
82
+ aggregation: AggregationClause[];
83
+ groupBy?: GroupByClause[];
84
+ where?: SearchClauseV2;
85
+ }
86
+ export type AggregationAPIResponse = {
87
+ excludedItems?: number;
88
+ data: Array<{
89
+ group: {
90
+ [key: string]: GroupValue;
91
+ };
92
+ metrics: Array<{
93
+ name: string;
94
+ value: AggregationValueType;
95
+ }>;
96
+ }>;
97
+ };
98
+ export type AggregateObjectsResponseV2 = {
99
+ excludedItems?: number;
100
+ data: Array<AggregateObjectsResponseItemV2>;
101
+ };
102
+ export type AggregateObjectsResponseItemV2 = {
103
+ group: Record<AggregationGroupKeyV2, AggregationGroupValueV2>;
104
+ metrics: Array<AggregationMetricResultV2>;
105
+ };
106
+ export type AggregationGroupKeyV2 = string;
107
+ export type AggregationGroupValueV2 = any;
108
+ export type AggregationMetricResultV2 = {
109
+ name: string;
110
+ value?: any;
111
+ };
112
+ export type LoadObjectSetRequestV2 = {
113
+ objectSet: ObjectSet;
114
+ orderBy?: SearchOrderBy;
115
+ select: Array<SelectedPropertyApiName>;
116
+ pageToken?: PageToken;
117
+ pageSize?: PageSize;
118
+ };
119
+ export type SearchOrderBy = {
120
+ fields: Array<SearchOrdering>;
121
+ };
122
+ export type SearchOrdering = {
123
+ field: string;
124
+ direction?: string;
125
+ };
126
+ export type SelectedPropertyApiName = string;
127
+ export type PageToken = string;
128
+ export type PageSize = number;
129
+ export type ObjectRid = string;
130
+ export type ObjectSet = (ObjectSetBaseType & {
131
+ type: "base";
132
+ }) | (ObjectSetStaticType & {
133
+ type: "static";
134
+ }) | (ObjectSetReferenceType & {
135
+ type: "reference";
136
+ }) | (ObjectSetFilterType & {
137
+ type: "filter";
138
+ }) | (ObjectSetUnionType & {
139
+ type: "union";
140
+ }) | (ObjectSetIntersectionType & {
141
+ type: "intersect";
142
+ }) | (ObjectSetSubtractType & {
143
+ type: "subtract";
144
+ }) | (ObjectSetSearchAroundType & {
145
+ type: "searchAround";
146
+ });
147
+ export type ObjectSetBaseType = {
148
+ objectType: string;
149
+ };
150
+ export type ObjectSetStaticType = {
151
+ objects: Array<ObjectRid>;
152
+ };
153
+ export type ObjectSetReferenceType = {
154
+ reference: string;
155
+ };
156
+ export type ObjectSetFilterType = {
157
+ objectSet: ObjectSet;
158
+ where: SearchJsonQueryV2;
159
+ };
160
+ export type ObjectSetIntersectionType = {
161
+ objectSets: Array<ObjectSet>;
162
+ };
163
+ /** */
164
+ export type ObjectSetUnionType = {
165
+ objectSets: Array<ObjectSet>;
166
+ };
167
+ export type ObjectSetSubtractType = {
168
+ objectSets: Array<ObjectSet>;
169
+ };
170
+ export type ObjectSetSearchAroundType = {
171
+ objectSet: ObjectSet;
172
+ link: LinkTypeApiName;
173
+ };
174
+ export type LinkTypeApiName = string;
175
+ export type SearchJsonQueryV2 = (LtQuery & {
176
+ type: "lt";
177
+ }) | (GtQuery & {
178
+ type: "gt";
179
+ }) | (LteQuery & {
180
+ type: "lte";
181
+ }) | (GteQuery & {
182
+ type: "gte";
183
+ }) | (EqualsQuery & {
184
+ type: "eq";
185
+ }) | (IsNullQuery & {
186
+ type: "isNull";
187
+ }) | (ContainsQuery & {
188
+ type: "contains";
189
+ }) | (AndQueryV2 & {
190
+ type: "and";
191
+ }) | (OrQueryV2 & {
192
+ type: "or";
193
+ }) | (NotQueryV2 & {
194
+ type: "not";
195
+ }) | (StartsWithQuery & {
196
+ type: "startsWith";
197
+ }) | (ContainsAllTermsInOrderQuery & {
198
+ type: "containsAllTermsInOrder";
199
+ }) | (ContainsAnyTermQuery & {
200
+ type: "containsAnyTerm";
201
+ }) | (ContainsAllTermsQuery & {
202
+ type: "containsAllTerms";
203
+ }) | (WithinDistanceOfQuery & {
204
+ type: "withinDistanceOf";
205
+ }) | (WithinBoundingBoxQuery & {
206
+ type: "withinBoundingBox";
207
+ }) | (IntersectsBoundingBoxQuery & {
208
+ type: "intersectsBoundingBox";
209
+ }) | (DoesNotIntersectBoundingBoxQuery & {
210
+ type: "doesNotIntersectBoundingBox";
211
+ }) | (WithinPolygonQuery & {
212
+ type: "withinPolygon";
213
+ }) | (IntersectsPolygonQuery & {
214
+ type: "intersectsPolygon";
215
+ }) | (DoesNotIntersectPolygonQuery & {
216
+ type: "doesNotIntersectPolygon";
217
+ });
218
+ export type LtQuery = {
219
+ field: string;
220
+ value: any;
221
+ };
222
+ export type GtQuery = {
223
+ field: string;
224
+ value: any;
225
+ };
226
+ export type LteQuery = {
227
+ field: string;
228
+ value: any;
229
+ };
230
+ /** Returns objects where the specified field is greater than or equal to a value. */
231
+ export type GteQuery = {
232
+ field: string;
233
+ value: any;
234
+ };
235
+ /** Returns objects where the specified field is equal to a value. */
236
+ export type EqualsQuery = {
237
+ field: string;
238
+ value: any;
239
+ };
240
+ /** Returns objects based on the existence of the specified field. */
241
+ export type IsNullQuery = {
242
+ field: string;
243
+ value: boolean;
244
+ };
245
+ /** Returns objects where the specified array contains a value. */
246
+ export type ContainsQuery = {
247
+ field: string;
248
+ value: any;
249
+ };
250
+ export type AndQueryV2 = {
251
+ value: Array<SearchJsonQueryV2>;
252
+ };
253
+ export type OrQueryV2 = {
254
+ value: Array<SearchJsonQueryV2>;
255
+ };
256
+ export type NotQueryV2 = {
257
+ value: SearchJsonQueryV2;
258
+ };
259
+ export type StartsWithQuery = {
260
+ field: string;
261
+ value: string;
262
+ };
263
+ export type ContainsAllTermsInOrderQuery = {
264
+ field: string;
265
+ value: string;
266
+ };
267
+ export type ContainsAnyTermQuery = {
268
+ field: string;
269
+ value: string;
270
+ fuzzy?: Fuzzy;
271
+ };
272
+ export type ContainsAllTermsQuery = {
273
+ field: string;
274
+ value: string;
275
+ fuzzy?: Fuzzy;
276
+ };
277
+ export type WithinDistanceOfQuery = {
278
+ field: string;
279
+ value: CenterPoint;
280
+ };
281
+ export type WithinBoundingBoxQuery = {
282
+ field: string;
283
+ value: BoundingBoxValue;
284
+ };
285
+ export type IntersectsBoundingBoxQuery = {
286
+ field: string;
287
+ value: BoundingBoxValue;
288
+ };
289
+ export type DoesNotIntersectBoundingBoxQuery = {
290
+ field: string;
291
+ value: BoundingBoxValue;
292
+ };
293
+ export type WithinPolygonQuery = {
294
+ field: string;
295
+ value: PolygonValue;
296
+ };
297
+ export type IntersectsPolygonQuery = {
298
+ field: string;
299
+ value: PolygonValue;
300
+ };
301
+ export type DoesNotIntersectPolygonQuery = {
302
+ field: string;
303
+ value: PolygonValue;
304
+ };
305
+ export type CenterPoint = {
306
+ center: CenterPointTypes;
307
+ distance: Distance;
308
+ };
309
+ export type CenterPointTypes = GeoPoint & {
310
+ type: "Point";
311
+ };
312
+ export type GeoPoint = {
313
+ coordinates: Position;
314
+ bbox?: BBox;
315
+ };
316
+ export type Position = Array<Coordinate>;
317
+ export type Fuzzy = boolean;
318
+ export type Coordinate = number;
319
+ export type BBox = Array<Coordinate>;
320
+ export type Distance = {
321
+ value: number;
322
+ unit: DistanceUnit;
323
+ };
324
+ export type DistanceUnit = "MILLIMETERS" | "CENTIMETERS" | "METERS" | "KILOMETERS" | "INCHES" | "FEET" | "YARDS" | "MILES" | "NAUTICAL_MILES";
325
+ export type BoundingBoxValue = {
326
+ topLeft: WithinBoundingBoxPoint;
327
+ bottomRight: WithinBoundingBoxPoint;
328
+ };
329
+ export type WithinBoundingBoxPoint = GeoPoint & {
330
+ type: "Point";
331
+ };
332
+ export type PolygonValue = Polygon & {
333
+ type: "Polygon";
334
+ };
335
+ export type Polygon = {
336
+ coordinates: Array<LinearRing>;
337
+ bbox?: BBox;
338
+ };
339
+ export type LinearRing = Array<Position>;
340
+ type ApiValueBaseType = string | number | boolean;
341
+ type ApiValueType = ApiValueBaseType[] | ApiValueBaseType;
342
+ type rid = string;
343
+ export type OntologyObjectV2 = {
344
+ [key: string]: ApiValueType;
345
+ } & {
346
+ __rid: rid;
347
+ __primaryKey: ApiValueType;
348
+ };
349
+ export type PagedResponse<T> = {
350
+ data: T[];
351
+ nextPageToken?: string;
352
+ };
353
+ export type PageOptions = {
354
+ pageSize?: number;
355
+ pageToken?: string;
356
+ };
357
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, ThinClient } from "@osdk/api";
2
+ import type { AggregationsResults } from "../query";
3
+ import type { AggregateOpts } from "../query/aggregations/AggregateOpts";
4
+ export declare function aggregateOrThrow<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, const AO extends AggregateOpts<T, K, any>>(thinClient: ThinClient<T>, objectType: K & string, req: AO): Promise<AggregationsResults<T, K, AO>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom, ThinClient } from "@osdk/api";
2
+ import type { OntologyObjectV2 } from "@osdk/gateway/types";
3
+ 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>>[];
@@ -0,0 +1,9 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom, ThinClient } from "@osdk/api";
2
+ import type { Wire } from "../internal/net";
3
+ import type { PageResult } from "../PageResult";
4
+ import type { NOOP } from "../util/NOOP";
5
+ export interface FetchPageOrThrowArgs<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, L extends PropertyKeysFrom<O, K>> {
6
+ select?: readonly L[];
7
+ nextPageToken?: string;
8
+ }
9
+ export declare function fetchPageOrThrow<O extends OntologyDefinition<any>, T extends ObjectTypesFrom<O>, const A extends FetchPageOrThrowArgs<O, T, PropertyKeysFrom<O, T>>>(client: ThinClient<O>, objectType: T & string, args: A, objectSet?: Wire.ObjectSet): Promise<PageResult<NOOP<OsdkObjectFrom<T, O, A["select"] extends readonly string[] ? A["select"][number] : PropertyKeysFrom<O, T>>>>>;
@@ -0,0 +1,2 @@
1
+ export { aggregateOrThrow } from "./aggregateOrThrow";
2
+ export { fetchPageOrThrow } from "./fetchPageOrThrow";
@@ -0,0 +1,2 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ export type LinkTypesFrom<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = keyof O["objects"][K]["links"];
@@ -0,0 +1,24 @@
1
+ import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectFrom, PropertyKeysFrom, ResultOrError } from "@osdk/api";
2
+ import type { FetchPageOrThrowArgs } from "../object/fetchPageOrThrow";
3
+ import type { PageResult } from "../PageResult";
4
+ import type { AggregationsResults, WhereClause } from "../query";
5
+ import type { AggregateOpts } from "../query/aggregations/AggregateOpts";
6
+ import type { LinkTypesFrom } from "./LinkTypesFrom";
7
+ export type ObjectSet<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = BaseObjectSet<O, K>;
8
+ export type SearchAround<O extends OntologyDefinition<string>, K extends ObjectTypesFrom<O>> = {
9
+ [L in LinkTypesFrom<O, K> & string as `searchAround_${L}`]: () => ObjectSet<O, L>;
10
+ };
11
+ export interface BaseObjectSet<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> {
12
+ fetchPageOrThrow: <L extends PropertyKeysFrom<O, K>>(args?: FetchPageOrThrowArgs<O, K, L>) => Promise<PageResult<OsdkObjectFrom<K, O, L>>>;
13
+ fetchPage: <L extends PropertyKeysFrom<O, K>>(args?: FetchPageOrThrowArgs<O, K, L>) => Promise<ResultOrError<PageResult<OsdkObjectFrom<K, O, L>>>>;
14
+ asyncIter: () => AsyncIterableIterator<OsdkObjectFrom<K, O, PropertyKeysFrom<O, K>>>;
15
+ [Symbol.asyncIterator](): AsyncIterableIterator<OsdkObjectFrom<K, O, PropertyKeysFrom<O, K>>>;
16
+ aggregateOrThrow: <const AO extends AggregateOpts<O, K, any>>(req: AO) => Promise<AggregationsResults<O, K, AO>>;
17
+ aggregate: <const AO extends AggregateOpts<O, K, any>>(req: AO) => Promise<ResultOrError<AggregationsResults<O, K, typeof req>>>;
18
+ where: (clause: WhereClause<ObjectInfoFrom<O, K>>) => ObjectSet<O, K>;
19
+ pivotTo: <T extends LinkTypesFrom<O, K>>(type: T & string, opts?: ObjectSetOptions<O, O["objects"][K]["links"][T]["targetType"]>) => ObjectSet<O, O["objects"][K]["links"][T]["targetType"]>;
20
+ }
21
+ export interface ObjectSetOptions<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> {
22
+ $where?: WhereClause<ObjectInfoFrom<O, K>>;
23
+ }
24
+ export type ObjectSetFactory<O extends OntologyDefinition<any>> = <K extends ObjectTypesFrom<O>>(type: K & string, opts?: ObjectSetOptions<O, K>) => ObjectSet<O, K>;
@@ -0,0 +1,4 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, ThinClient } from "@osdk/api";
2
+ import type { Wire } from "../internal/net";
3
+ import type { ObjectSet, ObjectSetOptions } from "./ObjectSet";
4
+ export declare function createObjectSet<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(objectType: K & string, thinClient: ThinClient<O>, opts: ObjectSetOptions<O, K> | undefined, objectSet?: Wire.ObjectSet): ObjectSet<O, K>;
@@ -0,0 +1 @@
1
+ export * from "../object";
@@ -0,0 +1,24 @@
1
+ import type { ObjectDefinition, PropertyDefinition } from "@osdk/api";
2
+ export type PossibleWhereClauseFilters = "gt" | "eq" | "ne" | "isNull" | "gte" | "lt" | "lte";
3
+ type MakeFilter<K extends PossibleWhereClauseFilters, V> = K extends string ? Omit<{
4
+ [k in PossibleWhereClauseFilters]?: undefined;
5
+ }, K> & {
6
+ [k in K]: V;
7
+ } : never;
8
+ type BaseFilter<T> = T | MakeFilter<"eq" | "ne", T> | MakeFilter<"isNull", boolean>;
9
+ type StringFilter = BaseFilter<string>;
10
+ type NumberFilter = BaseFilter<number> | MakeFilter<"gt" | "gte" | "lt" | "lte", number>;
11
+ type FilterFor<PD extends PropertyDefinition> = PD["type"] extends "string" ? StringFilter : NumberFilter;
12
+ export interface AndWhereClause<T extends ObjectDefinition<any, any>> {
13
+ $and: WhereClause<T>[];
14
+ }
15
+ export interface OrWhereClause<T extends ObjectDefinition<any, any>> {
16
+ $or: WhereClause<T>[];
17
+ }
18
+ export interface NotWhereClause<T extends ObjectDefinition<any, any>> {
19
+ $not: WhereClause<T>;
20
+ }
21
+ export type WhereClause<T extends ObjectDefinition<any, any>> = OrWhereClause<T> | AndWhereClause<T> | NotWhereClause<T> | {
22
+ [P in keyof T["properties"]]?: FilterFor<T["properties"][P]>;
23
+ };
24
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, PropertyKeysFrom } from "@osdk/api";
2
+ export type AggregatableKeys<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof {
3
+ [P in PropertyKeysFrom<O, K>]: any;
4
+ };
@@ -0,0 +1,7 @@
1
+ import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ import type { AggregationClause, GroupByClause, WhereClause } from "../../query";
3
+ export type AggregateOpts<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>> = {
4
+ select: AC;
5
+ where?: WhereClause<ObjectInfoFrom<T, K>>;
6
+ groupBy?: GroupByClause<T, K>;
7
+ };
@@ -0,0 +1,10 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "@osdk/api";
2
+ import type { AggregationResultsWithoutGroups } from "./AggregationResultsWithoutGroups";
3
+ import type { AggregationClause } from "./AggregationsClause";
4
+ import type { GroupByClause } from "./GroupByClause";
5
+ export type AggregationResultsWithGroups<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, A extends AggregationClause<O, K>, G extends GroupByClause<O, K> | undefined> = {
6
+ group: {
7
+ [P in keyof G & PropertyKeysFrom<O, K>]: OsdkObjectPropertyType<PropertyDefinitionFrom<O, K, P>>;
8
+ };
9
+ values: AggregationResultsWithoutGroups<O, K, A>;
10
+ }[];
@@ -0,0 +1,10 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinitionFrom, PropertyKeysFrom } from "@osdk/api";
2
+ import type { StringArrayToUnion } from "../../util/StringArrayToUnion";
3
+ import type { AggregationClause } from "./AggregationsClause";
4
+ type SubselectKeys<AC extends AggregationClause<any, any>, P extends keyof AC> = AC[P] extends readonly string[] | string ? P : never;
5
+ export type AggregationResultsWithoutGroups<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, AC extends AggregationClause<O, K>> = {
6
+ [P in PropertyKeysFrom<O, K> as SubselectKeys<AC, P>]: AC[P] extends readonly string[] | string ? {
7
+ [Z in StringArrayToUnion<AC[P]>]: Z extends "approximateDistinct" ? number : OsdkObjectPropertyType<PropertyDefinitionFrom<O, K, P>>;
8
+ } : never;
9
+ };
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, PropertyDefinitionsFrom } from "@osdk/api";
2
+ import type { AggregatableKeys } from "./AggregatableKeys";
3
+ type StringAggregateOption = "approximateDistinct";
4
+ type NumericAggregateOption = "min" | "max" | "sum" | "avg" | "approximateDistinct";
5
+ export type AggregationClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = {
6
+ [P in AggregatableKeys<O, K>]?: PropertyDefinitionsFrom<O, K>[P]["type"] extends "string" ? StringAggregateOption | StringAggregateOption[] : PropertyDefinitionsFrom<O, K>[P]["type"] extends "double" ? NumericAggregateOption | NumericAggregateOption[] : PropertyDefinitionsFrom<O, K>[P]["type"];
7
+ };
8
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { AggregatableKeys } from "./AggregatableKeys";
2
+ import type { AggregationClause } from "./AggregationsClause";
3
+ export type huh = AggregatableKeys<{
4
+ metadata: any;
5
+ objects: {
6
+ Todo: {
7
+ apiName: "Todo";
8
+ primaryKeyType: "double";
9
+ links: {};
10
+ properties: {
11
+ text: {
12
+ type: "string";
13
+ };
14
+ id: {
15
+ type: "double";
16
+ };
17
+ };
18
+ };
19
+ };
20
+ actions: {};
21
+ queries: {};
22
+ }, "Todo">;
23
+ export type Q = AggregationClause<{
24
+ metadata: any;
25
+ objects: {
26
+ Todo: {
27
+ apiName: "Todo";
28
+ primaryKeyType: "double";
29
+ links: {};
30
+ properties: {
31
+ text: {
32
+ type: "string";
33
+ };
34
+ id: {
35
+ type: "double";
36
+ };
37
+ };
38
+ };
39
+ };
40
+ actions: {};
41
+ queries: {};
42
+ }, "Todo">;
@@ -0,0 +1,5 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "@osdk/api";
2
+ import type { AggregateOpts } from "./AggregateOpts";
3
+ import type { AggregationResultsWithGroups } from "./AggregationResultsWithGroups";
4
+ import type { AggregationResultsWithoutGroups } from "./AggregationResultsWithoutGroups";
5
+ export type AggregationsResults<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AO extends AggregateOpts<T, K, any>> = unknown extends AO["groupBy"] ? AggregationResultsWithoutGroups<T, K, AO["select"]> : Exclude<AO["groupBy"], undefined> extends never ? AggregationResultsWithoutGroups<T, K, AO["select"]> : AggregationResultsWithGroups<T, K, AO["select"], AO["groupBy"]>;
@@ -0,0 +1,12 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition, PropertyDefinitionFrom } from "@osdk/api";
2
+ import type { AggregatableKeys } from "./AggregatableKeys";
3
+ import type { GroupByMapper } from "./GroupByMapper";
4
+ export type GroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = {
5
+ [P in AggregatableKeys<O, K>]?: GroupByEntry<O, K, P>;
6
+ };
7
+ export type StringGroupByValue = "exact" | {
8
+ exactWithLimit: number;
9
+ };
10
+ type GroupByEntry<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, P extends AggregatableKeys<O, K>> = PropertyDefinitionFrom<O, K, P>["type"] extends keyof GroupByMapper ? GroupByMapper[PropertyDefinitionFrom<O, K, P>["type"]] : never;
11
+ export type AllGroupByValues = GroupByMapper[keyof GroupByMapper];
12
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { GroupByClause } from "./GroupByClause";
2
+ export type F = GroupByClause<{
3
+ metadata: any;
4
+ objects: {
5
+ Todo: {
6
+ apiName: "Todo";
7
+ primaryKeyType: "double";
8
+ links: {};
9
+ properties: {
10
+ text: {
11
+ type: "string";
12
+ };
13
+ id: {
14
+ type: "double";
15
+ };
16
+ };
17
+ };
18
+ };
19
+ actions: {};
20
+ queries: {};
21
+ }, "Todo">;
@@ -0,0 +1,4 @@
1
+ import type { StringGroupByValue } from "./GroupByClause";
2
+ export interface GroupByMapper {
3
+ string: StringGroupByValue;
4
+ }
@@ -0,0 +1,7 @@
1
+ export type * from "./aggregations/AggregatableKeys";
2
+ export type * from "./aggregations/AggregationResultsWithGroups";
3
+ export type * from "./aggregations/AggregationResultsWithoutGroups";
4
+ export type * from "./aggregations/AggregationsClause";
5
+ export type * from "./aggregations/AggregationsResults";
6
+ export type { AllGroupByValues, GroupByClause, } from "./aggregations/GroupByClause";
7
+ export type { AndWhereClause, NotWhereClause, OrWhereClause, PossibleWhereClauseFilters, WhereClause, } from "./WhereClause";
@@ -0,0 +1 @@
1
+ export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
@@ -0,0 +1,3 @@
1
+ export type NOOP<T> = T extends (...args: any[]) => any ? T : T extends abstract new (...args: any[]) => any ? T : {
2
+ [K in keyof T]: T[K];
3
+ };
@@ -0,0 +1 @@
1
+ export type StringArrayToUnion<T extends string | readonly string[]> = T extends ReadonlyArray<infer U> ? U : T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/client",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -19,7 +19,8 @@
19
19
  "dependencies": {
20
20
  "fetch-retry": "^5.0.6",
21
21
  "tiny-invariant": "^1.3.1",
22
- "@osdk/gateway": "0.0.3"
22
+ "@osdk/api": "0.0.12",
23
+ "@osdk/gateway": "0.0.5"
23
24
  },
24
25
  "devDependencies": {
25
26
  "ts-expect": "^1.3.0",