@osdk/client 0.20.0-beta.3 → 0.20.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +28 -5
  2. package/build/browser/{chunk-M3BF5ESV.js → chunk-3ZYIZQ7V.js} +290 -8
  3. package/build/browser/chunk-3ZYIZQ7V.js.map +1 -0
  4. package/build/browser/index.js +2 -2
  5. package/build/browser/public/unstable-do-not-use.js +2 -2
  6. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  7. package/build/cjs/{chunk-EP4KLU3N.cjs → chunk-4FXEPHWC.cjs} +290 -8
  8. package/build/cjs/chunk-4FXEPHWC.cjs.map +1 -0
  9. package/build/cjs/index.cjs +5 -5
  10. package/build/cjs/public/unstable-do-not-use.cjs +8 -8
  11. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  12. package/build/esm/Client.d.ts +3 -2
  13. package/build/esm/Client.d.ts.map +1 -1
  14. package/build/esm/{chunk-JRG5V55N.js → chunk-MD6R46EZ.js} +290 -8
  15. package/build/esm/chunk-MD6R46EZ.js.map +1 -0
  16. package/build/esm/createClient.d.ts.map +1 -1
  17. package/build/esm/index.js +2 -2
  18. package/build/esm/object/Cache.d.ts +1 -1
  19. package/build/esm/object/SimpleCache.d.ts +1 -1
  20. package/build/esm/objectSet/createObjectSet.d.ts.map +1 -1
  21. package/build/esm/ontology/loadFullObjectMetadata.d.ts +1 -1
  22. package/build/esm/ontology/loadFullObjectMetadata.d.ts.map +1 -1
  23. package/build/esm/ontology/loadInterfaceDefinition.d.ts +1 -1
  24. package/build/esm/ontology/loadInterfaceDefinition.d.ts.map +1 -1
  25. package/build/esm/public/unstable-do-not-use.js +2 -2
  26. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  27. package/build/esm/queries/applyQuery.d.ts +6 -0
  28. package/build/esm/queries/applyQuery.d.ts.map +1 -0
  29. package/build/esm/queries/createQueryInvoker.d.ts +5 -0
  30. package/build/esm/queries/createQueryInvoker.d.ts.map +1 -0
  31. package/build/esm/queries/queries.test.d.ts +2 -0
  32. package/build/esm/queries/queries.test.d.ts.map +1 -0
  33. package/build/esm/util/isOsdkBaseObject.d.ts +3 -0
  34. package/build/esm/util/isOsdkBaseObject.d.ts.map +1 -0
  35. package/build/esm/util/isOsdkObject.d.ts +3 -0
  36. package/build/esm/util/isOsdkObject.d.ts.map +1 -0
  37. package/build/esm/util/toDataValue.d.ts.map +1 -1
  38. package/build/esm/util/toDataValueQueries.d.ts +10 -0
  39. package/build/esm/util/toDataValueQueries.d.ts.map +1 -0
  40. package/package.json +22 -15
  41. package/build/browser/chunk-M3BF5ESV.js.map +0 -1
  42. package/build/cjs/chunk-EP4KLU3N.cjs.map +0 -1
  43. package/build/esm/chunk-JRG5V55N.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 0.20.0-beta.4
4
+
5
+ ### Minor Changes
6
+
7
+ - 7afa226: Fix action params that take objects to correctly parse out primary key.
8
+ - 3ec7c38: Add support for queries in 2.0
9
+ - 4824449: Fix asyncIter to fetch subsequent pages
10
+ - bc89b62: Spelling fixes and spell check in CI
11
+ - a92e032: ClientCache now uses a key field as the cache key instead of the entire client
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [3ec7c38]
16
+ - Updated dependencies [bc89b62]
17
+ - @osdk/client.api@0.20.0-beta.4
18
+ - @osdk/api@1.9.0-beta.1
19
+ - @osdk/generator-converters@0.7.0-beta.1
20
+ - @osdk/client.unstable.osw@0.1.0-beta.0
21
+ - @osdk/shared.client.impl@0.1.0-beta.1
22
+ - @osdk/shared.net.errors@1.1.0-beta.0
23
+ - @osdk/shared.net.fetch@0.1.0-beta.1
24
+ - @osdk/client.unstable@0.1.0-beta.0
25
+
3
26
  ## 0.20.0-beta.3
4
27
 
5
28
  ### Minor Changes
@@ -60,7 +83,7 @@
60
83
  - 5378312: Added batch action support for 2.0 client
61
84
  - b3563e0: OSDK learns \_\_EXPERIMENTAL_strictNonNull to throw, drop objects, or return `| undefined` for properties, allowing for correct typesafety.
62
85
  - dd6033a: Adds a createPlatformClient if you only need platform apis
63
- - 4dbac7e: Fixes link direction for experiental bulk loads
86
+ - 4dbac7e: Fixes link direction for experimental bulk loads
64
87
  - 413e511: Added attachment uploading, reading, and metadata fetching support to 2.0.
65
88
  - 44add10: Standardize the use of dollar signs as prefixes for object properties that are specific to the OSDK.
66
89
 
@@ -76,7 +99,7 @@
76
99
 
77
100
  - 0a64def: Adds experimental batch link support
78
101
  - f9b3c72: Support importing the unstable-do-not-use from moduleResolution: node
79
- - 978ecd5: Rexport PalantirApiError
102
+ - 978ecd5: Reexport PalantirApiError
80
103
  - 978ecd5: Client is now usable for calling Platform SDK
81
104
  - c9f3214: Interfaces are now mapped as views
82
105
 
@@ -111,7 +134,7 @@
111
134
 
112
135
  - Introduced an optional pino logger to the client
113
136
  - Fixes issues with where clauses for equality in subscriptions
114
- - Fixes issues with inconsistent idname and apiName's in the mapping data
137
+ - Fixes issues with inconsistent id name and apiName's in the mapping data
115
138
 
116
139
  - 9906a41: Foundry Platform API support
117
140
  - 9906a41: Compatible version checks now use versions that are both embedded in the code and updated automatically as part of the release process.
@@ -197,7 +220,7 @@
197
220
 
198
221
  ### Minor Changes
199
222
 
200
- - 6d81f7f: Add priliminary action support to v2
223
+ - 6d81f7f: Add preliminary action support to v2
201
224
 
202
225
  ## 0.0.11
203
226
 
@@ -267,7 +290,7 @@
267
290
 
268
291
  ### Patch Changes
269
292
 
270
- - f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatability in @osdk/api"
293
+ - f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatibility in @osdk/api"
271
294
  - 848404c: Handle conflicts between object, action, and query names
272
295
  - Updated dependencies [f3120fb]
273
296
  - Updated dependencies [848404c]
@@ -1241,6 +1241,7 @@ function createObjectSet(objectType, clientCtx, objectSet = {
1241
1241
  const result = await base.fetchPage({
1242
1242
  $nextPageToken
1243
1243
  });
1244
+ $nextPageToken = result.nextPageToken;
1244
1245
  for (const obj of result.data) {
1245
1246
  yield obj;
1246
1247
  }
@@ -1597,7 +1598,7 @@ function applyFetchArgs(args, body) {
1597
1598
  async function fetchObjectPage(client, objectType, args, objectSet) {
1598
1599
  const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(addUserAgent(client, objectType), await client.ontologyRid, applyFetchArgs(args, {
1599
1600
  objectSet,
1600
- // We have to do the following case because LoadObjectSetRequestV2 isnt readonly
1601
+ // We have to do the following case because LoadObjectSetRequestV2 isn't readonly
1601
1602
  select: args?.$select ?? [],
1602
1603
  // FIXME?
1603
1604
  excludeRid: !args?.$includeRid
@@ -1626,6 +1627,11 @@ function isOntologyObjectV2(o) {
1626
1627
  return o && typeof o === "object" && typeof o.__apiName === "string" && o.__primaryKey != null;
1627
1628
  }
1628
1629
 
1630
+ // src/util/isOsdkObject.ts
1631
+ function isOsdkBaseObject(o) {
1632
+ return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
1633
+ }
1634
+
1629
1635
  // src/util/toDataValue.ts
1630
1636
  async function toDataValue(value, client) {
1631
1637
  if (value == null) {
@@ -1647,6 +1653,9 @@ async function toDataValue(value, client) {
1647
1653
  if (isOntologyObjectV2(value)) {
1648
1654
  return await toDataValue(value.__primaryKey, client);
1649
1655
  }
1656
+ if (isOsdkBaseObject(value)) {
1657
+ return await toDataValue(value.$primaryKey, client);
1658
+ }
1650
1659
  if (isWireObjectSet(value)) {
1651
1660
  return value;
1652
1661
  }
@@ -1708,19 +1717,19 @@ async function remapBatchActionParams(params, client) {
1708
1717
  }));
1709
1718
  return remappedParams;
1710
1719
  }
1711
- async function loadFullObjectMetadata(client, objtype) {
1712
- const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, await client.ontologyRid, objtype, {
1720
+ async function loadFullObjectMetadata(client, objectType) {
1721
+ const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, await client.ontologyRid, objectType, {
1713
1722
  preview: true
1714
1723
  });
1715
1724
  const ret = wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
1716
- client.logger?.debug(`END loadFullObjectMetadata(${objtype})`);
1725
+ client.logger?.debug(`END loadFullObjectMetadata(${objectType})`);
1717
1726
  return {
1718
1727
  ...ret,
1719
1728
  rid: full.objectType.rid
1720
1729
  };
1721
1730
  }
1722
- async function loadInterfaceDefinition(client, objtype) {
1723
- const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, await client.ontologyRid, objtype, {
1731
+ async function loadInterfaceDefinition(client, objectType) {
1732
+ const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, await client.ontologyRid, objectType, {
1724
1733
  preview: true
1725
1734
  });
1726
1735
  return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
@@ -1761,7 +1770,7 @@ var createStandardOntologyProviderFactory = (client) => {
1761
1770
  };
1762
1771
 
1763
1772
  // src/util/UserAgent.ts
1764
- var USER_AGENT = `osdk-client/${"0.20.0-beta.3"}`;
1773
+ var USER_AGENT = `osdk-client/${"0.20.0-beta.4"}`;
1765
1774
 
1766
1775
  // src/createMinimalClient.ts
1767
1776
  function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {
@@ -1785,6 +1794,277 @@ function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fet
1785
1794
  });
1786
1795
  }
1787
1796
 
1797
+ // src/util/isOsdkBaseObject.ts
1798
+ function isOsdkBaseObject2(o) {
1799
+ return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
1800
+ }
1801
+
1802
+ // src/util/toDataValueQueries.ts
1803
+ async function toDataValueQueries(value, client, desiredType) {
1804
+ if (value == null) {
1805
+ return value;
1806
+ }
1807
+ if (Array.isArray(value) && desiredType.multiplicity) {
1808
+ const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType));
1809
+ return Promise.all(promiseArray);
1810
+ }
1811
+ switch (desiredType.type) {
1812
+ case "attachment": {
1813
+ if (isAttachmentUpload(value)) {
1814
+ const attachment = await esm_exports.Attachments.uploadAttachment(client, value, {
1815
+ filename: value.name
1816
+ }, {
1817
+ "Content-Length": value.size.toString(),
1818
+ "Content-Type": value.type
1819
+ });
1820
+ return attachment.rid;
1821
+ }
1822
+ return value;
1823
+ }
1824
+ case "twoDimensionalAggregation": {
1825
+ return {
1826
+ groups: value
1827
+ };
1828
+ }
1829
+ case "threeDimensionalAggregation": {
1830
+ return {
1831
+ groups: value
1832
+ };
1833
+ }
1834
+ case "set": {
1835
+ if (value instanceof Set) {
1836
+ const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType["set"]));
1837
+ return Promise.all(promiseArray);
1838
+ }
1839
+ break;
1840
+ }
1841
+ case "object": {
1842
+ if (isOsdkBaseObject2(value)) {
1843
+ return value.$primaryKey;
1844
+ }
1845
+ break;
1846
+ }
1847
+ case "objectSet": {
1848
+ if (isWireObjectSet(value)) {
1849
+ return value;
1850
+ }
1851
+ if (isObjectSet(value)) {
1852
+ return getWireObjectSet(value);
1853
+ }
1854
+ break;
1855
+ }
1856
+ case "struct": {
1857
+ if (typeof value === "object") {
1858
+ const structMap = {};
1859
+ for (const [key, structValue] of Object.entries(value)) {
1860
+ structMap[key] = await toDataValueQueries(structValue, client, desiredType["struct"][key]);
1861
+ }
1862
+ return structMap;
1863
+ }
1864
+ }
1865
+ case "boolean":
1866
+ case "date":
1867
+ case "double":
1868
+ case "float":
1869
+ case "integer":
1870
+ case "long":
1871
+ case "string":
1872
+ case "timestamp":
1873
+ return value;
1874
+ }
1875
+ return value;
1876
+ }
1877
+
1878
+ // src/queries/applyQuery.ts
1879
+ async function applyQuery(client, query, params) {
1880
+ const response = await esm_exports2.QueryTypes.executeQueryV2(addUserAgent(client, query), await client.ontologyRid, query.apiName, {
1881
+ parameters: params ? await remapQueryParams(params, client, query.parameters) : {}
1882
+ });
1883
+ const objectOutputDefs = await getRequiredDefinitions(query.output, client);
1884
+ const remappedResponse = await remapQueryResponse(client, query.output, response.value, objectOutputDefs);
1885
+ return remappedResponse;
1886
+ }
1887
+ async function remapQueryParams(params, client, paramTypes) {
1888
+ const parameterMap = {};
1889
+ for (const [key, value] of Object.entries(params)) {
1890
+ parameterMap[key] = await toDataValueQueries(value, client, paramTypes[key]);
1891
+ }
1892
+ return parameterMap;
1893
+ }
1894
+ async function remapQueryResponse(client, responseDataType, responseValue, definitions) {
1895
+ if (responseValue == null) {
1896
+ if (responseDataType.nullable) {
1897
+ return void 0;
1898
+ } else {
1899
+ throw new Error("Got null response when nullable was not allowed");
1900
+ }
1901
+ }
1902
+ if (responseDataType.multiplicity != null && responseDataType.multiplicity !== false) {
1903
+ const withoutMultiplicity = {
1904
+ ...responseDataType,
1905
+ multiplicity: false
1906
+ };
1907
+ for (let i = 0; i < responseValue.length; i++) {
1908
+ responseValue[i] = await remapQueryResponse(responseValue[i], withoutMultiplicity, client, definitions);
1909
+ }
1910
+ return responseValue;
1911
+ }
1912
+ switch (responseDataType.type) {
1913
+ case "union": {
1914
+ throw new Error("Union return types are not yet supported");
1915
+ }
1916
+ case "set": {
1917
+ for (let i = 0; i < responseValue.length; i++) {
1918
+ responseValue[i] = await remapQueryResponse(responseValue[i], responseDataType.set, client, definitions);
1919
+ }
1920
+ return responseValue;
1921
+ }
1922
+ case "attachment": {
1923
+ return createAttachmentFromRid(client, responseValue);
1924
+ }
1925
+ case "object": {
1926
+ const def = definitions.get(responseDataType.object);
1927
+ if (!def) {
1928
+ throw new Error(`Missing definition for ${responseDataType.object}`);
1929
+ }
1930
+ return createQueryObjectResponse(responseValue, def);
1931
+ }
1932
+ case "objectSet": {
1933
+ const def = definitions.get(responseDataType.objectSet);
1934
+ if (!def) {
1935
+ throw new Error(`Missing definition for ${responseDataType.objectSet}`);
1936
+ }
1937
+ if (typeof responseValue === "string") {
1938
+ return createObjectSet(def, client, {
1939
+ type: "intersect",
1940
+ objectSets: [{
1941
+ type: "base",
1942
+ objectType: responseDataType.objectSet
1943
+ }, {
1944
+ type: "reference",
1945
+ reference: responseValue
1946
+ }]
1947
+ });
1948
+ }
1949
+ return createObjectSet(def, client, responseValue);
1950
+ }
1951
+ case "struct": {
1952
+ for (const [key, subtype] of Object.entries(responseDataType.struct)) {
1953
+ if (requiresConversion(subtype)) {
1954
+ responseValue[key] = await remapQueryResponse(responseValue[key], subtype, client, definitions);
1955
+ }
1956
+ }
1957
+ return responseValue;
1958
+ }
1959
+ case "twoDimensionalAggregation": {
1960
+ const result = [];
1961
+ for (const {
1962
+ key,
1963
+ value
1964
+ } of responseValue.groups) {
1965
+ result.push({
1966
+ key,
1967
+ value
1968
+ });
1969
+ }
1970
+ return result;
1971
+ }
1972
+ case "threeDimensionalAggregation": {
1973
+ const result = [];
1974
+ for (const {
1975
+ key,
1976
+ groups
1977
+ } of responseValue.groups) {
1978
+ const subResult = [];
1979
+ for (const {
1980
+ key: subKey,
1981
+ value
1982
+ } of groups) {
1983
+ subResult.push({
1984
+ key: subKey,
1985
+ value
1986
+ });
1987
+ }
1988
+ result.push({
1989
+ key,
1990
+ groups: subResult
1991
+ });
1992
+ }
1993
+ return result;
1994
+ }
1995
+ }
1996
+ return responseValue;
1997
+ }
1998
+ async function getRequiredDefinitions(dataType, client) {
1999
+ const result = /* @__PURE__ */ new Map();
2000
+ switch (dataType.type) {
2001
+ case "objectSet": {
2002
+ const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.objectSet);
2003
+ result.set(dataType.objectSet, objectDef);
2004
+ break;
2005
+ }
2006
+ case "object": {
2007
+ const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.object);
2008
+ result.set(dataType.object, objectDef);
2009
+ break;
2010
+ }
2011
+ case "set": {
2012
+ return getRequiredDefinitions(dataType.set, client);
2013
+ }
2014
+ case "struct": {
2015
+ for (const value of Object.values(dataType.struct)) {
2016
+ for (const [type, objectDef] of await getRequiredDefinitions(value, client)) {
2017
+ result.set(type, objectDef);
2018
+ }
2019
+ }
2020
+ break;
2021
+ }
2022
+ }
2023
+ return result;
2024
+ }
2025
+ function requiresConversion(dataType) {
2026
+ switch (dataType.type) {
2027
+ case "boolean":
2028
+ case "date":
2029
+ case "double":
2030
+ case "float":
2031
+ case "integer":
2032
+ case "long":
2033
+ case "object":
2034
+ case "string":
2035
+ case "timestamp":
2036
+ return false;
2037
+ case "union":
2038
+ return true;
2039
+ case "struct":
2040
+ return Object.values(dataType.struct).some(requiresConversion);
2041
+ case "set":
2042
+ return requiresConversion(dataType.set);
2043
+ case "attachment":
2044
+ case "objectSet":
2045
+ case "twoDimensionalAggregation":
2046
+ case "threeDimensionalAggregation":
2047
+ return true;
2048
+ default:
2049
+ return false;
2050
+ }
2051
+ }
2052
+ function createQueryObjectResponse(primaryKey, objectDef) {
2053
+ return {
2054
+ $apiName: objectDef.apiName,
2055
+ $title: void 0,
2056
+ $objectType: objectDef.apiName,
2057
+ $primaryKey: primaryKey
2058
+ };
2059
+ }
2060
+
2061
+ // src/queries/createQueryInvoker.ts
2062
+ function createQueryInvoker(client, query) {
2063
+ return function(...args) {
2064
+ return applyQuery(client, query, ...args);
2065
+ };
2066
+ }
2067
+
1788
2068
  // src/createClient.ts
1789
2069
  var ActionInvoker = class {
1790
2070
  constructor(clientCtx, actionDef) {
@@ -1802,6 +2082,8 @@ function createClientInternal(objectSetFactory, baseUrl, ontologyRid, tokenProvi
1802
2082
  } else if (o.type === "action") {
1803
2083
  clientCtx.ontologyProvider.maybeSeed(o);
1804
2084
  return new ActionInvoker(clientCtx, o);
2085
+ } else if (o.type === "query") {
2086
+ return createQueryInvoker(clientCtx, o);
1805
2087
  } else {
1806
2088
  throw new Error("not implemented");
1807
2089
  }
@@ -1817,4 +2099,4 @@ var createClient = createClientInternal.bind(void 0, createObjectSet);
1817
2099
 
1818
2100
  export { ActionValidationError, USER_AGENT, augment, convertWireToOsdkObjects, createAttachmentFromRid, createClient, createClientInternal, createObjectSet, createSimpleAsyncCache, esm_exports2 as esm_exports };
1819
2101
  //# sourceMappingURL=out.js.map
1820
- //# sourceMappingURL=chunk-M3BF5ESV.js.map
2102
+ //# sourceMappingURL=chunk-3ZYIZQ7V.js.map