@osdk/client 2.8.0-beta.27 → 2.8.0-beta.29

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 (119) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +4 -20
  3. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  4. package/build/browser/observable/ObservableClient/MediaObservableTypes.js +2 -0
  5. package/build/browser/observable/ObservableClient/MediaObservableTypes.js.map +1 -0
  6. package/build/browser/observable/ObservableClient/MediaTypes.js +2 -0
  7. package/build/browser/observable/ObservableClient/MediaTypes.js.map +1 -0
  8. package/build/browser/observable/ObservableClient.js.map +1 -1
  9. package/build/browser/observable/internal/Changes.js.map +1 -1
  10. package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
  11. package/build/browser/observable/internal/ListQueryView.js +21 -9
  12. package/build/browser/observable/internal/ListQueryView.js.map +1 -1
  13. package/build/browser/observable/internal/ObservableClientImpl.js +32 -0
  14. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  15. package/build/browser/observable/internal/OrderByCanonicalizer.js +5 -2
  16. package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
  17. package/build/browser/observable/internal/SelectCanonicalizer.js +3 -0
  18. package/build/browser/observable/internal/SelectCanonicalizer.js.map +1 -1
  19. package/build/browser/observable/internal/Store.js +5 -1
  20. package/build/browser/observable/internal/Store.js.map +1 -1
  21. package/build/browser/observable/internal/WhereClauseCanonicalizer.js +3 -0
  22. package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  23. package/build/browser/observable/internal/list/InterfaceListQuery.js +2 -6
  24. package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
  25. package/build/browser/observable/internal/list/ListQuery.js +6 -9
  26. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  27. package/build/browser/observable/internal/media/BlobMemoryManager.js +116 -0
  28. package/build/browser/observable/internal/media/BlobMemoryManager.js.map +1 -0
  29. package/build/browser/observable/internal/media/MediaMetadataCacheKey.js +2 -0
  30. package/build/browser/observable/internal/media/MediaMetadataCacheKey.js.map +1 -0
  31. package/build/browser/observable/internal/media/MediaMetadataQuery.js +159 -0
  32. package/build/browser/observable/internal/media/MediaMetadataQuery.js.map +1 -0
  33. package/build/browser/observable/internal/media/getMediaCacheKey.js +28 -0
  34. package/build/browser/observable/internal/media/getMediaCacheKey.js.map +1 -0
  35. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  36. package/build/browser/queries/applyQuery.js +1 -1
  37. package/build/browser/queries/applyQuery.js.map +1 -1
  38. package/build/browser/util/UserAgent.js +2 -2
  39. package/build/cjs/{chunk-BWOPPEUP.cjs → chunk-KGWUPXAM.cjs} +2 -19
  40. package/build/cjs/chunk-KGWUPXAM.cjs.map +1 -0
  41. package/build/cjs/{chunk-ZPGIIKEZ.cjs → chunk-XYZOCIVH.cjs} +40 -40
  42. package/build/cjs/chunk-XYZOCIVH.cjs.map +1 -0
  43. package/build/cjs/index.cjs +10 -10
  44. package/build/cjs/public/internal.cjs +8 -8
  45. package/build/cjs/public/unstable-do-not-use.cjs +137 -89
  46. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  47. package/build/cjs/public/unstable-do-not-use.d.cts +19 -1
  48. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +4 -20
  49. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  50. package/build/esm/observable/ObservableClient/MediaObservableTypes.js +2 -0
  51. package/build/esm/observable/ObservableClient/MediaObservableTypes.js.map +1 -0
  52. package/build/esm/observable/ObservableClient/MediaTypes.js +2 -0
  53. package/build/esm/observable/ObservableClient/MediaTypes.js.map +1 -0
  54. package/build/esm/observable/ObservableClient.js.map +1 -1
  55. package/build/esm/observable/internal/Changes.js.map +1 -1
  56. package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
  57. package/build/esm/observable/internal/ListQueryView.js +21 -9
  58. package/build/esm/observable/internal/ListQueryView.js.map +1 -1
  59. package/build/esm/observable/internal/ObservableClientImpl.js +32 -0
  60. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  61. package/build/esm/observable/internal/OrderByCanonicalizer.js +5 -2
  62. package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
  63. package/build/esm/observable/internal/SelectCanonicalizer.js +3 -0
  64. package/build/esm/observable/internal/SelectCanonicalizer.js.map +1 -1
  65. package/build/esm/observable/internal/Store.js +5 -1
  66. package/build/esm/observable/internal/Store.js.map +1 -1
  67. package/build/esm/observable/internal/WhereClauseCanonicalizer.js +3 -0
  68. package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  69. package/build/esm/observable/internal/list/InterfaceListQuery.js +2 -6
  70. package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
  71. package/build/esm/observable/internal/list/ListQuery.js +6 -9
  72. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  73. package/build/esm/observable/internal/media/BlobMemoryManager.js +116 -0
  74. package/build/esm/observable/internal/media/BlobMemoryManager.js.map +1 -0
  75. package/build/esm/observable/internal/media/MediaMetadataCacheKey.js +2 -0
  76. package/build/esm/observable/internal/media/MediaMetadataCacheKey.js.map +1 -0
  77. package/build/esm/observable/internal/media/MediaMetadataQuery.js +159 -0
  78. package/build/esm/observable/internal/media/MediaMetadataQuery.js.map +1 -0
  79. package/build/esm/observable/internal/media/getMediaCacheKey.js +28 -0
  80. package/build/esm/observable/internal/media/getMediaCacheKey.js.map +1 -0
  81. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  82. package/build/esm/queries/applyQuery.js +1 -1
  83. package/build/esm/queries/applyQuery.js.map +1 -1
  84. package/build/esm/util/UserAgent.js +2 -2
  85. package/build/types/observable/ObservableClient/MediaObservableTypes.d.ts +35 -0
  86. package/build/types/observable/ObservableClient/MediaObservableTypes.d.ts.map +1 -0
  87. package/build/types/observable/ObservableClient/MediaTypes.d.ts +1 -0
  88. package/build/types/observable/ObservableClient/MediaTypes.d.ts.map +1 -0
  89. package/build/types/observable/ObservableClient.d.ts +19 -0
  90. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  91. package/build/types/observable/internal/Changes.d.ts +4 -3
  92. package/build/types/observable/internal/Changes.d.ts.map +1 -1
  93. package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
  94. package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
  95. package/build/types/observable/internal/ListQueryView.d.ts.map +1 -1
  96. package/build/types/observable/internal/OrderByCanonicalizer.d.ts +2 -1
  97. package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -1
  98. package/build/types/observable/internal/SelectCanonicalizer.d.ts +2 -0
  99. package/build/types/observable/internal/SelectCanonicalizer.d.ts.map +1 -1
  100. package/build/types/observable/internal/Store.d.ts.map +1 -1
  101. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +1 -0
  102. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
  103. package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
  104. package/build/types/observable/internal/list/ListQuery.d.ts +2 -0
  105. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  106. package/build/types/observable/internal/media/BlobMemoryManager.d.ts +10 -0
  107. package/build/types/observable/internal/media/BlobMemoryManager.d.ts.map +1 -0
  108. package/build/types/observable/internal/media/MediaMetadataCacheKey.d.ts +4 -0
  109. package/build/types/observable/internal/media/MediaMetadataCacheKey.d.ts.map +1 -0
  110. package/build/types/observable/internal/media/MediaMetadataQuery.d.ts +23 -0
  111. package/build/types/observable/internal/media/MediaMetadataQuery.d.ts.map +1 -0
  112. package/build/types/observable/internal/media/getMediaCacheKey.d.ts +2 -0
  113. package/build/types/observable/internal/media/getMediaCacheKey.d.ts.map +1 -0
  114. package/build/types/public/unstable-do-not-use.d.ts +1 -1
  115. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  116. package/build/types/queries/applyQuery.d.ts.map +1 -1
  117. package/package.json +7 -7
  118. package/build/cjs/chunk-BWOPPEUP.cjs.map +0 -1
  119. package/build/cjs/chunk-ZPGIIKEZ.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 2.8.0-beta.29
4
+
5
+ ### Minor Changes
6
+
7
+ - 520398c: Add canonicalizeOptions API to ObservableClient for stable memo keys in React hooks, add objectSet to list payload
8
+ - ffc6efe: Fix query map parsing to allow nullable values in map entries
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [4a856cb]
13
+ - @osdk/api@2.8.0-beta.29
14
+ - @osdk/client.unstable@2.8.0-beta.29
15
+ - @osdk/generator-converters@2.8.0-beta.29
16
+
17
+ ## 2.8.0-beta.28
18
+
19
+ ### Minor Changes
20
+
21
+ - f294f5a: Remove literal support before GA.
22
+ - 2855223: fix autoFetchMore not working when another subscriber creates the shared query first
23
+ - d284bf2: add media types, caching, and metadata query
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [f294f5a]
28
+ - Updated dependencies [d284bf2]
29
+ - Updated dependencies [b68cebd]
30
+ - @osdk/api@2.8.0-beta.28
31
+ - @osdk/client.unstable@2.8.0-beta.28
32
+ - @osdk/generator-converters@2.8.0-beta.28
33
+
3
34
  ## 2.8.0-beta.27
4
35
 
5
36
  ### Minor Changes
@@ -17,6 +17,7 @@
17
17
  import invariant from "tiny-invariant";
18
18
  import { modernToLegacyWhereClause } from "../internal/conversions/modernToLegacyWhereClause.js";
19
19
  import { derivedPropertyDefinitionFactory } from "./derivedPropertyDefinitionFactory.js";
20
+
20
21
  /** @internal */
21
22
  export function createWithPropertiesObjectSet(objectType, objectSet, definitionMap, fromBaseObjectSet = false) {
22
23
  return {
@@ -31,7 +32,7 @@ export function createWithPropertiesObjectSet(objectType, objectSet, definitionM
31
32
  const rdpNames = new Set(definitionMap.keys());
32
33
  return createWithPropertiesObjectSet(objectType, {
33
34
  type: "filter",
34
- objectSet: objectSet,
35
+ objectSet,
35
36
  where: modernToLegacyWhereClause(clause, objectType, rdpNames)
36
37
  }, definitionMap);
37
38
  },
@@ -79,7 +80,7 @@ export function createWithPropertiesObjectSet(objectType, objectSet, definitionM
79
80
  }
80
81
  const wrappedObjectSet = {
81
82
  type: "selection",
82
- objectSet: objectSet,
83
+ objectSet,
83
84
  operation: aggregationOperationDefinition
84
85
  };
85
86
  const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
@@ -98,7 +99,7 @@ export function createWithPropertiesObjectSet(objectType, objectSet, definitionM
98
99
  }
99
100
  const wrappedObjectSet = {
100
101
  type: "selection",
101
- objectSet: objectSet,
102
+ objectSet,
102
103
  operation: {
103
104
  type: "get",
104
105
  selectedPropertyApiName: name
@@ -107,23 +108,6 @@ export function createWithPropertiesObjectSet(objectType, objectSet, definitionM
107
108
  const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
108
109
  definitionMap.set(selectorResult, wrappedObjectSet);
109
110
  return selectorResult;
110
- },
111
- constant: {
112
- double: () => {
113
- process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
114
- },
115
- integer: () => {
116
- process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
117
- },
118
- long: () => {
119
- process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
120
- },
121
- datetime: () => {
122
- process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
123
- },
124
- timestamp: () => {
125
- process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
126
- }
127
111
  }
128
112
  };
129
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createWithPropertiesObjectSet.js","names":["invariant","modernToLegacyWhereClause","derivedPropertyDefinitionFactory","createWithPropertiesObjectSet","objectType","objectSet","definitionMap","fromBaseObjectSet","pivotTo","link","type","where","clause","rdpNames","Set","keys","aggregate","aggregation","opt","splitAggregation","split","length","process","env","NODE_ENV","aggregationPropertyName","aggregationOperation","aggregationOperationDefinition","selectedPropertyApiName","approximatePercentile","percentile","limit","undefined","wrappedObjectSet","operation","selectorResult","set","selectProperty","name","apiName","constant","double","integer","long","datetime","timestamp"],"sources":["createWithPropertiesObjectSet.ts"],"sourcesContent":["/*\n * Copyright 2024 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 type { DerivedProperty, ObjectOrInterfaceDefinition } from \"@osdk/api\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n SelectedPropertyOperation,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { derivedPropertyDefinitionFactory } from \"./derivedPropertyDefinitionFactory.js\";\n\ntype WithConstSelect<Q extends ObjectOrInterfaceDefinition> =\n & DerivedProperty.SelectPropertyBuilder<Q, false>\n & {\n constant: DerivedProperty.Builder<Q, true>[\"constant\"];\n };\n\n/** @internal */\nexport function createWithPropertiesObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n>(\n objectType: Q,\n objectSet: WireObjectSet,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n fromBaseObjectSet: boolean = false,\n): WithConstSelect<Q> {\n return {\n pivotTo: (link) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"searchAround\",\n objectSet,\n link,\n }, definitionMap);\n },\n where: (clause) => {\n const rdpNames = new Set(definitionMap.keys());\n return createWithPropertiesObjectSet(objectType, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType, rdpNames),\n }, definitionMap);\n },\n aggregate: (aggregation: string, opt: any) => {\n const splitAggregation = aggregation.split(\":\");\n invariant(\n splitAggregation.length === 2 || splitAggregation[0] === \"$count\",\n \"Invalid aggregation format\",\n );\n const [aggregationPropertyName, aggregationOperation] = splitAggregation;\n let aggregationOperationDefinition: SelectedPropertyOperation;\n switch (aggregationOperation) {\n case \"sum\":\n case \"avg\":\n case \"min\":\n case \"max\":\n case \"exactDistinct\":\n case \"approximateDistinct\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n };\n break;\n case \"approximatePercentile\":\n aggregationOperationDefinition = {\n type: \"approximatePercentile\",\n selectedPropertyApiName: aggregationPropertyName,\n approximatePercentile: opt?.percentile ?? .5,\n };\n break;\n case \"collectSet\":\n case \"collectList\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n limit: opt?.limit ?? 100,\n };\n break;\n case undefined:\n if (aggregationPropertyName === \"$count\") {\n aggregationOperationDefinition = {\n type: \"count\",\n };\n break;\n }\n default:\n invariant(\n false,\n \"Invalid aggregation operation \" + aggregationOperation,\n );\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: aggregationOperationDefinition,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n selectProperty: (name) => {\n if (fromBaseObjectSet) {\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"property\",\n apiName: name,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: {\n type: \"get\",\n selectedPropertyApiName: name,\n },\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n constant: {\n double: (value) => {\n invariant(false, \"Not supported\");\n },\n integer: (value) => {\n invariant(false, \"Not supported\");\n },\n long: (value) => {\n invariant(false, \"Not supported\");\n },\n datetime: (value) => {\n invariant(false, \"Not supported\");\n },\n timestamp: (value) => {\n invariant(false, \"Not supported\");\n },\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,gCAAgC,QAAQ,uCAAuC;AAQxF;AACA,OAAO,SAASC,6BAA6BA,CAG3CC,UAAa,EACbC,SAAwB,EACxBC,aAAkD,EAClDC,iBAA0B,GAAG,KAAK,EACd;EACpB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;MACjB,OAAON,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,cAAc;QACpBL,SAAS;QACTI;MACF,CAAC,EAAEH,aAAa,CAAC;IACnB,CAAC;IACDK,KAAK,EAAGC,MAAM,IAAK;MACjB,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACR,aAAa,CAACS,IAAI,CAAC,CAAC,CAAC;MAC9C,OAAOZ,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,QAAQ;QACdL,SAAS,EAAEA,SAAS;QACpBM,KAAK,EAAEV,yBAAyB,CAACW,MAAM,EAAER,UAAU,EAAES,QAAQ;MAC/D,CAAC,EAAEP,aAAa,CAAC;IACnB,CAAC;IACDU,SAAS,EAAEA,CAACC,WAAmB,EAAEC,GAAQ,KAAK;MAC5C,MAAMC,gBA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EA,CAAA,KAAW;QACnBtB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAxB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACD6C,SAAS,EAAEA,CAAA,KAAW;QACpBvB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAxB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"createWithPropertiesObjectSet.js","names":["invariant","modernToLegacyWhereClause","derivedPropertyDefinitionFactory","createWithPropertiesObjectSet","objectType","objectSet","definitionMap","fromBaseObjectSet","pivotTo","link","type","where","clause","rdpNames","Set","keys","aggregate","aggregation","opt","splitAggregation","split","length","process","env","NODE_ENV","aggregationPropertyName","aggregationOperation","aggregationOperationDefinition","selectedPropertyApiName","approximatePercentile","percentile","limit","undefined","wrappedObjectSet","operation","selectorResult","set","selectProperty","name","apiName"],"sources":["createWithPropertiesObjectSet.ts"],"sourcesContent":["/*\n * Copyright 2024 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 type { DerivedProperty, ObjectOrInterfaceDefinition } from \"@osdk/api\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n SelectedPropertyOperation,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { derivedPropertyDefinitionFactory } from \"./derivedPropertyDefinitionFactory.js\";\n\n/** @internal */\nexport function createWithPropertiesObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n>(\n objectType: Q,\n objectSet: WireObjectSet,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n fromBaseObjectSet: boolean = false,\n): DerivedProperty.SelectPropertyBuilder<Q, false> {\n return {\n pivotTo: (link) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"searchAround\",\n objectSet,\n link,\n }, definitionMap);\n },\n where: (clause) => {\n const rdpNames = new Set(definitionMap.keys());\n return createWithPropertiesObjectSet(objectType, {\n type: \"filter\",\n objectSet,\n where: modernToLegacyWhereClause(clause, objectType, rdpNames),\n }, definitionMap);\n },\n aggregate: (aggregation: string, opt: any) => {\n const splitAggregation = aggregation.split(\":\");\n invariant(\n splitAggregation.length === 2 || splitAggregation[0] === \"$count\",\n \"Invalid aggregation format\",\n );\n const [aggregationPropertyName, aggregationOperation] = splitAggregation;\n let aggregationOperationDefinition: SelectedPropertyOperation;\n switch (aggregationOperation) {\n case \"sum\":\n case \"avg\":\n case \"min\":\n case \"max\":\n case \"exactDistinct\":\n case \"approximateDistinct\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n };\n break;\n case \"approximatePercentile\":\n aggregationOperationDefinition = {\n type: \"approximatePercentile\",\n selectedPropertyApiName: aggregationPropertyName,\n approximatePercentile: opt?.percentile ?? .5,\n };\n break;\n case \"collectSet\":\n case \"collectList\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n limit: opt?.limit ?? 100,\n };\n break;\n case undefined:\n if (aggregationPropertyName === \"$count\") {\n aggregationOperationDefinition = {\n type: \"count\",\n };\n break;\n }\n default:\n invariant(\n false,\n \"Invalid aggregation operation \" + aggregationOperation,\n );\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet,\n operation: aggregationOperationDefinition,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n selectProperty: (name) => {\n if (fromBaseObjectSet) {\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"property\",\n apiName: name,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet,\n operation: {\n type: \"get\",\n selectedPropertyApiName: name,\n },\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,gCAAgC,QAAQ,uCAAuC;;AAExF;AACA,OAAO,SAASC,6BAA6BA,CAG3CC,UAAa,EACbC,SAAwB,EACxBC,aAAkD,EAClDC,iBAA0B,GAAG,KAAK,EACe;EACjD,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;MACjB,OAAON,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,cAAc;QACpBL,SAAS;QACTI;MACF,CAAC,EAAEH,aAAa,CAAC;IACnB,CAAC;IACDK,KAAK,EAAGC,MAAM,IAAK;MACjB,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACR,aAAa,CAACS,IAAI,CAAC,CAAC,CAAC;MAC9C,OAAOZ,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,QAAQ;QACdL,SAAS;QACTM,KAAK,EAAEV,yBAAyB,CAACW,MAAM,EAAER,UAAU,EAAES,QAAQ;MAC/D,CAAC,EAAEP,aAAa,C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A2C,GAAG;QAClDvB,IAAI,EAAE,WAAW;QACjBL,SAAS;QACT6B,SAAS,EAAEP;MACb,CAAC;MACD,MAAMQ,cAAoD,GACxDjC,gCAAgC,CAAC+B,gBAAgB,EAAE3B,aAAa,CAAC;MACnEA,aAAa,CAAC8B,GAAG,CAACD,cAAc,EAAEF,gBAAgB,CAAC;MACnD,OAAOE,cAAc;IACvB,CAAC;IACDE,cAAc,EAAGC,IAAI,IAAK;MACxB,IAAI/B,iBAAiB,EAAE;QACrB,MAAM0B,gBAA2C,GAAG;UAClDvB,IAAI,EAAE,UAAU;UAChB6B,OAAO,EAAED;QACX,CAAC;QACD,MAAMH,cAAoD,GACxDjC,gCAAgC,CAAC+B,gBAAgB,EAAE3B,aAAa,CAAC;QACnEA,aAAa,CAAC8B,GAAG,CAACD,cAAc,EAAEF,gBAAgB,CAAC;QACnD,OAAOE,cAAc;MACvB;MACA,MAAMF,gBAA2C,GAAG;QAClDvB,IAAI,EAAE,WAAW;QACjBL,SAAS;QACT6B,SAAS,EAAE;UACTxB,IAAI,EAAE,KAAK;UACXkB,uBAAuB,EAAEU;QAC3B;MACF,CAAC;MACD,MAAMH,cAAoD,GACxDjC,gCAAgC,CAAC+B,gBAAgB,EAAE3B,aAAa,CAAC;MACnEA,aAAa,CAAC8B,GAAG,CAACD,cAAc,EAAEF,gBAAgB,CAAC;MACnD,OAAOE,cAAc;IACvB;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MediaObservableTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaObservableTypes.js","names":[],"sources":["MediaObservableTypes.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { MediaMetadata } from \"@osdk/api\";\nimport type { Status } from \"./common.js\";\n\nexport interface MediaMetadataPayload {\n metadata: MediaMetadata | undefined;\n status: Status;\n lastUpdated: number;\n isOptimistic: boolean;\n}\n\nexport interface MediaMetadataObserveOptions {\n mode?: \"offline\" | \"force\";\n dedupeInterval?: number;\n preview?: boolean;\n}\n\nexport interface MediaContentPayload {\n metadata: MediaMetadata | undefined;\n content: Blob | undefined;\n url: string | undefined;\n previewUrl: string | undefined;\n dimensions: { width: number; height: number } | undefined;\n status: Status;\n isStale: boolean;\n isPreview: boolean;\n lastUpdated: number;\n error: Error | undefined;\n}\n\nexport interface MediaContentObserveOptions {\n dedupeInterval?: number;\n preview?: boolean;\n placeholder?: \"preview\" | \"none\";\n priority?: \"high\" | \"low\";\n staleTime?: number;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MediaTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaTypes.js","names":[],"sources":["MediaTypes.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { MediaPropertyLocation } from \"@osdk/api\";\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type {\n ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n AggregateOpts,\n AggregationsResults,\n CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport type { QueryReturnType } from \"../queries/types.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./internal/objectset/ObjectSetQueryOptions.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectOrInterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n $loadPropertySecurityMetadata?: boolean;\n}\n\nexport type OrderBy<Q extends ObjectOrInterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q, RDPs>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n withProperties?: DerivedProperty.Clause<Q>;\n\n /**\n * Fetch objects by their Resource Identifiers (RIDs).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * observeList({ type: Employee, rids: ['ri.foo.123', 'ri.foo.456'] }, observer)\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * observeList({\n * type: Employee,\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * }, observer)\n */\n rids?: readonly string[];\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n select?: readonly PropertyKeys<Q>[];\n\n /**\n * When true, loads per-property security metadata (marking requirements)\n * alongside each object. The returned objects will have `$propertySecurities`\n * populated with conjunctive/disjunctive marking requirements per property.\n */\n $loadPropertySecurityMetadata?: boolean;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * @example\n * // Fetch all todos at once\n * observeList({ type: Todo, autoFetchMore: true }, observer)\n *\n * @example\n * // Fetch at least 100 todos\n * observeList({ type: Todo, autoFetchMore: 100, pageSize: 25 }, observer)\n */\n autoFetchMore?: boolean | number;\n intersectWith?: Array<{\n where: WhereClause<Q, RDPs>;\n }>;\n pivotTo?: string;\n}\n\nexport interface ObserveObjectCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\nexport interface ObserveObjectsCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\nexport interface ObserveObjectSetArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n objectSet: ObjectSet<T, RDPs>;\n totalCount?: string;\n}\n\ninterface ObserveAggregationBaseOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: T;\n where?: WhereClause<T, RDPs>;\n withProperties?: DerivedProperty.Clause<T>;\n intersectWith?: Array<{\n where: WhereClause<T, RDPs>;\n }>;\n aggregate: A;\n}\n\n/**\n * Options for observeAggregation without an ObjectSet (synchronous).\n */\nexport interface ObserveAggregationOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet?: undefined;\n}\n\n/**\n * Options for observeAggregation with an ObjectSet (asynchronous).\n *\n * When objectSet is provided, the aggregation is performed on that ObjectSet\n * instead of the base type, enabling aggregation on pivoted or filtered sets.\n */\nexport interface ObserveAggregationOptionsWithObjectSet<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet: ObjectSet<T>;\n}\n\nexport interface ObserveAggregationArgs<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n> {\n result: AggregationsResults<T, A> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport interface ObserveFunctionOptions extends CommonObserveOptions {\n /**\n * Object types this function depends on.\n * When actions modify these types, the function will refetch.\n */\n dependsOn?: Array<ObjectTypeDefinition | string>;\n\n /**\n * Specific object instances or ObjectSets this function depends on.\n * When these objects change, the function will refetch.\n *\n * For ObjectSets, the object type is extracted asynchronously and added\n * to the dependency list. Changes to any object of that type will trigger\n * a refetch.\n */\n dependsOnObjects?: Array<\n Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>\n >;\n}\n\nexport interface ObserveFunctionCallbackArgs<\n Q extends QueryDefinition<unknown>,\n> {\n result: QueryReturnType<CompileTimeMetadata<Q>[\"output\"]> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[] | undefined;\n linkedObjectsBySourcePrimaryKey: ReadonlyMap<\n string | number,\n ReadonlyArray<Osdk.Instance<T>>\n >;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object or interface instance with automatic updates when it changes.\n *\n * @param apiName - The object type or interface definition, or its API name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectOrInterfaceDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectCallbackArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveListOptions<T, RDPs>,\n subFn: Observer<ObserveObjectsCallbackArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * Observe an ObjectSet with automatic updates when matching objects change.\n *\n * @param baseObjectSet - The base ObjectSet to observe\n * @param options - Options for transforming and observing the ObjectSet\n * @param subFn - Observer that receives ObjectSet state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports all ObjectSet operations:\n * - Filtering with where clauses\n * - Derived properties with withProperties\n * - Set operations (union, intersect, subtract)\n * - Link traversal with pivotTo\n * - Sorting and pagination\n */\n observeObjectSet<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n >(\n baseObjectSet: ObjectSet<T>,\n options: ObserveObjectSetOptions<T, RDPs>,\n subFn: Observer<ObserveObjectSetArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * @deprecated Use the async overload with `objectSet` parameter instead.\n * Pass `objectSet: client(YourType)` to get the base object set.\n */\n observeAggregation<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ): Unsubscribable;\n\n /**\n * Observe an aggregation query on a custom ObjectSet with automatic updates.\n *\n * This overload accepts an ObjectSet parameter, enabling aggregation on pivoted,\n * filtered, or composed ObjectSets. Returns a Promise because invalidation type\n * computation is async (requires lookups for link targets).\n *\n * @param options - Aggregation configuration including objectSet, where, aggregate spec\n * @param subFn - Observer that receives aggregation result updates\n * @returns Promise resolving to subscription that can be unsubscribed\n *\n * @example\n * ```typescript\n * const sub = await observableClient.observeAggregation(\n * {\n * type: Office,\n * objectSet: $(Employee).pivotTo(\"primaryOffice\"),\n * aggregate: { $select: { $count: \"unordered\" } }\n * },\n * observer\n * );\n * ```\n */\n observeAggregation<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptionsWithObjectSet<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ): Promise<Unsubscribable>;\n\n /**\n * Observe a function execution with automatic updates.\n *\n * @param queryDef - The QueryDefinition to execute\n * @param params - Parameters to pass to the function (undefined if no params)\n * @param options - Observation options including invalidation configuration\n * @param subFn - Observer that receives function result updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Automatic caching and deduplication\n * - Dependency-based invalidation (dependsOn object types)\n * - Instance-based invalidation (dependsOnObjects)\n * - Manual refetch via invalidateFunction()\n */\n observeFunction<Q extends QueryDefinition<unknown>>(\n queryDef: Q,\n params: Record<string, unknown> | undefined,\n options: ObserveFunctionOptions,\n subFn: Observer<ObserveFunctionCallbackArgs<Q>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<ActionEditResponse>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n /**\n * Invalidates the entire cache, forcing all queries to refetch.\n * Use sparingly as this can cause significant network traffic.\n */\n invalidateAll(): Promise<void>;\n\n /**\n * Invalidates specific objects in the cache.\n * @param objects - Single object or array of objects to invalidate\n */\n invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void>;\n\n /**\n * Invalidates all cached data for a specific object type.\n * This includes:\n * - All objects of the specified type\n * - All lists containing objects of this type\n * - All links where the source is of this type\n *\n * @param type - Object type definition or API name string\n * @returns Promise that resolves when invalidation is complete\n */\n invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void>;\n\n /**\n * Invalidate function queries.\n * - If params undefined, invalidates ALL queries for this function\n * - If params provided, invalidates only the query with exact params match\n *\n * @param apiName - Function API name string or QueryDefinition\n * @param params - Optional params for exact match\n */\n invalidateFunction(\n apiName: string | QueryDefinition<unknown>,\n params?: Record<string, unknown>,\n ): Promise<void>;\n\n /**\n * Invalidate functions that depend on a specific object instance.\n *\n * @param apiName - Object type API name\n * @param primaryKey - Object primary key\n */\n invalidateFunctionsByObject(\n apiName: string,\n primaryKey: string | number,\n ): Promise<void>;\n\n canonicalizeWhereClause: <\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n where: WhereClause<T, RDPs>,\n ) => Canonical<WhereClause<T, RDPs>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAE5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AAuJjC;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAgDA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgPA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type {\n ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n AggregateOpts,\n AggregationsResults,\n CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport type { QueryReturnType } from \"../queries/types.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./internal/objectset/ObjectSetQueryOptions.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectOrInterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n $loadPropertySecurityMetadata?: boolean;\n}\n\nexport type OrderBy<Q extends ObjectOrInterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q, RDPs>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n withProperties?: DerivedProperty.Clause<Q>;\n\n /**\n * Fetch objects by their Resource Identifiers (RIDs).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * observeList({ type: Employee, rids: ['ri.foo.123', 'ri.foo.456'] }, observer)\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * observeList({\n * type: Employee,\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * }, observer)\n */\n rids?: readonly string[];\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n select?: readonly PropertyKeys<Q>[];\n\n /**\n * When true, loads per-property security metadata (marking requirements)\n * alongside each object. The returned objects will have `$propertySecurities`\n * populated with conjunctive/disjunctive marking requirements per property.\n */\n $loadPropertySecurityMetadata?: boolean;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * @example\n * // Fetch all todos at once\n * observeList({ type: Todo, autoFetchMore: true }, observer)\n *\n * @example\n * // Fetch at least 100 todos\n * observeList({ type: Todo, autoFetchMore: 100, pageSize: 25 }, observer)\n */\n autoFetchMore?: boolean | number;\n intersectWith?: Array<{\n where: WhereClause<Q, RDPs>;\n }>;\n pivotTo?: string;\n}\n\nexport interface ObserveObjectCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\nexport interface ObserveObjectsCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n objectSet: ObjectSet<T>;\n}\n\nexport interface ObserveObjectSetArgs<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList:\n | Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >\n | undefined;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n objectSet: ObjectSet<T, RDPs>;\n totalCount?: string;\n}\n\ninterface ObserveAggregationBaseOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions, ObserveOptions {\n type: T;\n where?: WhereClause<T, RDPs>;\n withProperties?: DerivedProperty.Clause<T>;\n intersectWith?: Array<{\n where: WhereClause<T, RDPs>;\n }>;\n aggregate: A;\n}\n\n/**\n * Options for observeAggregation without an ObjectSet (synchronous).\n */\nexport interface ObserveAggregationOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet?: undefined;\n}\n\n/**\n * Options for observeAggregation with an ObjectSet (asynchronous).\n *\n * When objectSet is provided, the aggregation is performed on that ObjectSet\n * instead of the base type, enabling aggregation on pivoted or filtered sets.\n */\nexport interface ObserveAggregationOptionsWithObjectSet<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends ObserveAggregationBaseOptions<T, A, RDPs> {\n objectSet: ObjectSet<T>;\n}\n\nexport interface ObserveAggregationArgs<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n> {\n result: AggregationsResults<T, A> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport interface ObserveFunctionOptions extends CommonObserveOptions {\n /**\n * Object types this function depends on.\n * When actions modify these types, the function will refetch.\n */\n dependsOn?: Array<ObjectTypeDefinition | string>;\n\n /**\n * Specific object instances or ObjectSets this function depends on.\n * When these objects change, the function will refetch.\n *\n * For ObjectSets, the object type is extracted asynchronously and added\n * to the dependency list. Changes to any object of that type will trigger\n * a refetch.\n */\n dependsOnObjects?: Array<\n Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>\n >;\n}\n\nexport interface ObserveFunctionCallbackArgs<\n Q extends QueryDefinition<unknown>,\n> {\n result: QueryReturnType<CompileTimeMetadata<Q>[\"output\"]> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectOrInterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[] | undefined;\n linkedObjectsBySourcePrimaryKey: ReadonlyMap<\n string | number,\n ReadonlyArray<Osdk.Instance<T>>\n >;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n totalCount?: string;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object or interface instance with automatic updates when it changes.\n *\n * @param apiName - The object type or interface definition, or its API name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectOrInterfaceDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectCallbackArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveListOptions<T, RDPs>,\n subFn: Observer<ObserveObjectsCallbackArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * Observe an ObjectSet with automatic updates when matching objects change.\n *\n * @param baseObjectSet - The base ObjectSet to observe\n * @param options - Options for transforming and observing the ObjectSet\n * @param subFn - Observer that receives ObjectSet state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports all ObjectSet operations:\n * - Filtering with where clauses\n * - Derived properties with withProperties\n * - Set operations (union, intersect, subtract)\n * - Link traversal with pivotTo\n * - Sorting and pagination\n */\n observeObjectSet<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n >(\n baseObjectSet: ObjectSet<T>,\n options: ObserveObjectSetOptions<T, RDPs>,\n subFn: Observer<ObserveObjectSetArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * @deprecated Use the async overload with `objectSet` parameter instead.\n * Pass `objectSet: client(YourType)` to get the base object set.\n */\n observeAggregation<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ): Unsubscribable;\n\n /**\n * Observe an aggregation query on a custom ObjectSet with automatic updates.\n *\n * This overload accepts an ObjectSet parameter, enabling aggregation on pivoted,\n * filtered, or composed ObjectSets. Returns a Promise because invalidation type\n * computation is async (requires lookups for link targets).\n *\n * @param options - Aggregation configuration including objectSet, where, aggregate spec\n * @param subFn - Observer that receives aggregation result updates\n * @returns Promise resolving to subscription that can be unsubscribed\n *\n * @example\n * ```typescript\n * const sub = await observableClient.observeAggregation(\n * {\n * type: Office,\n * objectSet: $(Employee).pivotTo(\"primaryOffice\"),\n * aggregate: { $select: { $count: \"unordered\" } }\n * },\n * observer\n * );\n * ```\n */\n observeAggregation<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptionsWithObjectSet<T, A, RDPs>,\n subFn: Observer<ObserveAggregationArgs<T, A>>,\n ): Promise<Unsubscribable>;\n\n /**\n * Observe a function execution with automatic updates.\n *\n * @param queryDef - The QueryDefinition to execute\n * @param params - Parameters to pass to the function (undefined if no params)\n * @param options - Observation options including invalidation configuration\n * @param subFn - Observer that receives function result updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Automatic caching and deduplication\n * - Dependency-based invalidation (dependsOn object types)\n * - Instance-based invalidation (dependsOnObjects)\n * - Manual refetch via invalidateFunction()\n */\n observeFunction<Q extends QueryDefinition<unknown>>(\n queryDef: Q,\n params: Record<string, unknown> | undefined,\n options: ObserveFunctionOptions,\n subFn: Observer<ObserveFunctionCallbackArgs<Q>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<ActionEditResponse>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n /**\n * Invalidates the entire cache, forcing all queries to refetch.\n * Use sparingly as this can cause significant network traffic.\n */\n invalidateAll(): Promise<void>;\n\n /**\n * Invalidates specific objects in the cache.\n * @param objects - Single object or array of objects to invalidate\n */\n invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void>;\n\n /**\n * Invalidates all cached data for a specific object type.\n * This includes:\n * - All objects of the specified type\n * - All lists containing objects of this type\n * - All links where the source is of this type\n *\n * @param type - Object type definition or API name string\n * @returns Promise that resolves when invalidation is complete\n */\n invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void>;\n\n /**\n * Invalidate function queries.\n * - If params undefined, invalidates ALL queries for this function\n * - If params provided, invalidates only the query with exact params match\n *\n * @param apiName - Function API name string or QueryDefinition\n * @param params - Optional params for exact match\n */\n invalidateFunction(\n apiName: string | QueryDefinition<unknown>,\n params?: Record<string, unknown>,\n ): Promise<void>;\n\n /**\n * Invalidate functions that depend on a specific object instance.\n *\n * @param apiName - Object type API name\n * @param primaryKey - Object primary key\n */\n invalidateFunctionsByObject(\n apiName: string,\n primaryKey: string | number,\n ): Promise<void>;\n\n canonicalizeWhereClause: <\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n where: WhereClause<T, RDPs>,\n ) => Canonical<WhereClause<T, RDPs>>;\n\n canonicalizeOptions: <OS, T extends CanonicalizeOptionsInput<OS>>(\n options: T,\n ) => CanonicalizedOptions<T>;\n}\n\nexport interface CanonicalizeOptionsInput<OS = ObjectSet<any, any>> {\n where?: object;\n withProperties?: object;\n orderBy?: Record<string, \"asc\" | \"desc\" | undefined>;\n aggregate?: object;\n intersectWith?: Array<{ where: object }>;\n union?: ReadonlyArray<OS>;\n intersect?: ReadonlyArray<OS>;\n subtract?: ReadonlyArray<OS>;\n $select?: ReadonlyArray<string>;\n}\n\nexport type CanonicalizedOptions<\n T extends CanonicalizeOptionsInput<any>,\n> = {\n [K in keyof T]: T[K];\n};\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAE5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AAwJjC;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAgDA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsQA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Changes.js","names":["DEBUG_ONLY__cacheKeyToString","MultiMap","Changes","modifiedObjects","addedObjects","added","Set","modified","deleted","registerObject","cacheKey","data","isNew","set","$objectType","$apiName","add","deleteObject","registerList","key","registerLink","deleteLink","registerObjectSet","registerFunction","isEmpty","size","createChangedObjects","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["Changes.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { ObjectHolder } from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { AggregationCacheKey } from \"./aggregation/AggregationCacheKey.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport { MultiMap } from \"./collections/MultiMap.js\";\nimport type { FunctionCacheKey } from \"./function/FunctionCacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<\n | AggregationCacheKey\n | FunctionCacheKey\n | ListCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n modified: Set<\n | AggregationCacheKey\n | FunctionCacheKey\n | ListCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n deleted: Set<\n | AggregationCacheKey\n | FunctionCacheKey\n | ListCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n\n registerObject = (\n cacheKey: ObjectCacheKey,\n data: ObjectHolder,\n isNew: boolean,\n ): void => {\n this[isNew ? \"addedObjects\" : \"modifiedObjects\"].set(\n data.$objectType ?? data.$apiName,\n data,\n );\n this[isNew ? \"added\" : \"modified\"].add(cacheKey);\n };\n\n deleteObject = (cacheKey: ObjectCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n registerLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.modified.add(cacheKey);\n };\n\n deleteLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerObjectSet = (key: ObjectSetCacheKey): void => {\n this.modified.add(key);\n };\n\n registerFunction = (key: FunctionCacheKey): void => {\n this.modified.add(key);\n };\n\n isEmpty(): boolean {\n return (\n this.modifiedObjects.size === 0\n && this.addedObjects.size === 0\n && this.added.size === 0\n && this.modified.size === 0\n && this.deleted.size === 0\n );\n }\n}\n\nexport function createChangedObjects(): Changes {\n return new Changes();\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n added: listHelper(changes.added),\n modified: listHelper(changes.modified),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<CacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, ObjectHolder>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,4BAA4B,QAAQ,eAAe;AAC5D,SAASC,QAAQ,QAAQ,2BAA2B;AAOpD,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,IAAIF,QAAQ,CAAC,CAAC;EAChEG,YAAY,GAAmC,IAAIH,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G_ONLY__cacheKeyToString","MultiMap","Changes","modifiedObjects","addedObjects","added","Set","modified","deleted","registerObject","cacheKey","data","isNew","set","$objectType","$apiName","add","deleteObject","registerList","key","registerLink","deleteLink","registerObjectSet","registerFunction","isEmpty","size","createChangedObjects","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["Changes.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { ObjectHolder } from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { AggregationCacheKey } from \"./aggregation/AggregationCacheKey.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport { MultiMap } from \"./collections/MultiMap.js\";\nimport type { FunctionCacheKey } from \"./function/FunctionCacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { MediaMetadataCacheKey } from \"./media/MediaMetadataCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<\n | AggregationCacheKey\n | FunctionCacheKey\n | ListCacheKey\n | MediaMetadataCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n modified: Set<\n | AggregationCacheKey\n | FunctionCacheKey\n | ListCacheKey\n | MediaMetadataCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n deleted: Set<\n | AggregationCacheKey\n | FunctionCacheKey\n | ListCacheKey\n | MediaMetadataCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ObjectSetCacheKey\n > = new Set();\n\n registerObject = (\n cacheKey: ObjectCacheKey,\n data: ObjectHolder,\n isNew: boolean,\n ): void => {\n this[isNew ? \"addedObjects\" : \"modifiedObjects\"].set(\n data.$objectType ?? data.$apiName,\n data,\n );\n this[isNew ? \"added\" : \"modified\"].add(cacheKey);\n };\n\n deleteObject = (cacheKey: ObjectCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n registerLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.modified.add(cacheKey);\n };\n\n deleteLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerObjectSet = (key: ObjectSetCacheKey): void => {\n this.modified.add(key);\n };\n\n registerFunction = (key: FunctionCacheKey): void => {\n this.modified.add(key);\n };\n\n isEmpty(): boolean {\n return (\n this.modifiedObjects.size === 0\n && this.addedObjects.size === 0\n && this.added.size === 0\n && this.modified.size === 0\n && this.deleted.size === 0\n );\n }\n}\n\nexport function createChangedObjects(): Changes {\n return new Changes();\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n added: listHelper(changes.added),\n modified: listHelper(changes.modified),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<CacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, ObjectHolder>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,4BAA4B,QAAQ,eAAe;AAC5D,SAASC,QAAQ,QAAQ,2BAA2B;AAQpD,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,IAAIF,QAAQ,CAAC,CAAC;EAChEG,YAAY,GAAmC,IAAIH,QAAQ,CAAC,CAAC;EAE7DI,KAAK,GAQD,IAAIC,GAAG,CAAC,CAAC;EACbC,QAAQ,GAQJ,IAAID,GAAG,CAAC,CAAC;EACbE,OAAO,GAQH,IAAIF,GAAG,CAAC,CAAC;EAEbG,cAAc,GAAGA,CACfC,QAAwB,EACxBC,IAAkB,EAClBC,KAAc,KACL;IACT,IAAI,CAACA,KAAK,GAAG,cAAc,GAAG,iBAAiB,CAAC,CAACC,GAAG,CAClDF,IAAI,CAACG,WAAW,IAAIH,IAAI,CAACI,QAAQ,EACjCJ,IACF,CAAC;IACD,IAAI,CAACC,KAAK,GAAG,OAAO,GAAG,UAAU,CAAC,CAACI,GAAG,CAACN,QAAQ,CAAC;EAClD,CAAC;EAEDO,YAAY,GAAIP,QAAwB,IAAW;IACjD,IAAI,CAACF,OAAO,CAACQ,GAAG,CAACN,QAAQ,CAAC;EAC5B,CAAC;EAEDQ,YAAY,GAAIC,GAAiB,IAAW;IAC1C,IAAI,CAACZ,QAAQ,CAACS,GAAG,CAACG,GAAG,CAAC;EACxB,CAAC;EAEDC,YAAY,GAAIV,QAA8B,IAAW;IACvD,IAAI,CAACH,QAAQ,CAACS,GAAG,CAACN,QAAQ,CAAC;EAC7B,CAAC;EAEDW,U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AOwB,KAAK,CAACC,IAAI,CAACzB,GAAG,CAAC,CAAC0B,GAAG,CAACvC,4BAA4B,CAAC;AAC1D;AAEA,SAASkC,cAAcA,CACrBM,QAAwC,EACxC;EACA,OAAOC,MAAM,CAACC,WAAW,CACvBL,KAAK,CAACC,IAAI,CAACE,QAAQ,CAACG,YAAY,CAAC,CAAC,CAAC,CAACJ,GAAG,CACrC,CAAC,CAACK,IAAI,EAAEC,OAAO,CAAC,KAAK;IACnB,OAAO,CAACD,IAAI,EAAEC,OAAO,CAACN,GAAG,CAACO,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,CACF,CACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"KnownCacheKey.js","names":[],"sources":["KnownCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { AggregationCacheKey } from \"./aggregation/AggregationCacheKey.js\";\nimport type { FunctionCacheKey } from \"./function/FunctionCacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport type KnownCacheKey =\n | AggregationCacheKey\n | FunctionCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ListCacheKey\n | ObjectSetCacheKey;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"KnownCacheKey.js","names":[],"sources":["KnownCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { AggregationCacheKey } from \"./aggregation/AggregationCacheKey.js\";\nimport type { FunctionCacheKey } from \"./function/FunctionCacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { MediaMetadataCacheKey } from \"./media/MediaMetadataCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport type KnownCacheKey =\n | AggregationCacheKey\n | FunctionCacheKey\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ListCacheKey\n | MediaMetadataCacheKey\n | ObjectSetCacheKey;\n"],"mappings":"","ignoreList":[]}
@@ -30,6 +30,7 @@
30
30
  * - Slices the shared data to the subscriber's viewLimit
31
31
  * - Provides a fetchMore that increments viewLimit and fetches if needed
32
32
  * - Reports hasMore based on both local viewLimit and server pagination
33
+ * - Drives autoFetchMore page-by-page when enabled (per-subscriber concern)
33
34
  */
34
35
  let viewIdCounter = 0;
35
36
  export class ListQueryView {
@@ -37,7 +38,7 @@ export class ListQueryView {
37
38
  #viewLimit;
38
39
  #pageSize;
39
40
  #viewId;
40
- #hasAutoFetch;
41
+ #autoFetchMinimum;
41
42
  #fetchMore;
42
43
  #pendingFetchMore;
43
44
  #lastPayload;
@@ -46,11 +47,8 @@ export class ListQueryView {
46
47
  this.#query = query;
47
48
  this.#pageSize = pageSize;
48
49
  this.#viewId = `view_${++viewIdCounter}`;
49
-
50
- // With autoFetchMore, subscriber sees all loaded data (no view limit)
51
- // Otherwise, limit to their pageSize
52
- this.#hasAutoFetch = autoFetchMore === true || typeof autoFetchMore === "number" && autoFetchMore > 0;
53
- this.#viewLimit = this.#hasAutoFetch ? Number.MAX_SAFE_INTEGER : pageSize;
50
+ this.#autoFetchMinimum = autoFetchMore === true ? Number.MAX_SAFE_INTEGER : typeof autoFetchMore === "number" && autoFetchMore > 0 ? autoFetchMore : 0;
51
+ this.#viewLimit = this.#autoFetchMinimum > 0 ? Number.MAX_SAFE_INTEGER : pageSize;
54
52
 
55
53
  // Memoize fetchMore to maintain stable function identity
56
54
  this.#fetchMore = this.#createFetchMore();
@@ -63,8 +61,10 @@ export class ListQueryView {
63
61
  const sub = this.#query.subscribe({
64
62
  next: payload => {
65
63
  this.#lastPayload = payload;
66
- observer.next?.(this.#transformPayload(payload));
67
- if (!this.#hasAutoFetch && payload.status === "loaded" && (payload.resolvedList?.length ?? 0) < this.#viewLimit && this.#query.hasMorePages()) {
64
+ this.#observer?.next?.(this.#transformPayload(payload));
65
+ const loadedCount = payload.resolvedList?.length ?? 0;
66
+ const fetchThreshold = this.#autoFetchMinimum > 0 ? this.#autoFetchMinimum : this.#viewLimit;
67
+ if (payload.status === "loaded" && this.#query.hasMorePages() && loadedCount < fetchThreshold) {
68
68
  void this.#query.fetchMore();
69
69
  }
70
70
  },
@@ -88,12 +88,24 @@ export class ListQueryView {
88
88
  #transformPayload(payload) {
89
89
  const resolvedList = payload.resolvedList;
90
90
  const loadedCount = resolvedList?.length ?? 0;
91
+ let status = payload.status;
92
+
93
+ // When auto-fetching and below threshold with more pages available,
94
+ // report "loading" to prevent status oscillation
95
+ if (this.#autoFetchMinimum > 0 && status === "loaded" && this.#query.hasMorePages() && loadedCount < this.#autoFetchMinimum) {
96
+ status = "loading";
97
+ }
98
+
99
+ // When query says "loading" but we have enough for our view, report "loaded"
100
+ if (loadedCount >= this.#viewLimit && status === "loading") {
101
+ status = "loaded";
102
+ }
91
103
  return {
92
104
  ...payload,
93
105
  resolvedList: resolvedList?.slice(0, this.#viewLimit),
94
106
  hasMore: this.#viewLimit < loadedCount || payload.hasMore,
95
107
  fetchMore: this.#fetchMore,
96
- status: loadedCount >= this.#viewLimit && payload.status === "loading" ? "loaded" : payload.status
108
+ status
97
109
  };
98
110
  }
99
111
  #createFetchMore() {
@@ -1 +1 @@
1
- {"version":3,"file":"ListQueryView.js","names":["viewIdCounter","ListQueryView","query","viewLimit","pageSize","viewId","hasAutoFetch","fetchMore","pendingFetchMore","lastPayload","observer","constructor","autoFetchMore","Number","MAX_SAFE_INTEGER","createFetchMore","registerFetchPageSize","subscribe","sub","next","payload","transformPayload","status","resolvedList","length","hasMorePages","error","err","complete","add","unregisterFetchPageSize","undefined","reEmitWithNewViewLimit","#reEmitWithNewViewLimit","#transformPayload","loadedCount","slice","hasMore","#createFetchMore","getLoadedCount","hasMoreOnServer","finally","Promise","resolve"],"sources":["ListQueryView.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { Subscription } from \"rxjs\";\nimport type { Observer } from \"../ObservableClient/common.js\";\nimport type { BaseListPayloadShape } from \"./base-list/BaseListQuery.js\";\n\n/**\n * Interface for the query methods that ListQueryView needs.\n * This allows ListQueryView to work with any query that supports these operations.\n */\nexport interface ListQueryViewTarget<PAYLOAD extends BaseListPayloadShape> {\n subscribe(observer: Observer<PAYLOAD>): Subscription;\n registerFetchPageSize(viewId: string, pageSize: number): void;\n unregisterFetchPageSize(viewId: string): void;\n getLoadedCount(): number;\n hasMorePages(): boolean;\n notifySubscribers(): void;\n fetchMore(): Promise<void>;\n}\n\n/**\n * A view into a shared ListQuery cache.\n *\n * Each subscriber gets their own View instance that tracks how much of the\n * shared cache they want to see (viewLimit). This allows multiple components\n * with different pageSize requirements to share the same underlying cache.\n *\n * The View:\n * - Slices the shared data to the subscriber's viewLimit\n * - Provides a fetchMore that increments viewLimit and fetches if needed\n * - Reports hasMore based on both local viewLimit and server pagination\n */\nlet viewIdCounter = 0;\n\nexport class ListQueryView<PAYLOAD extends BaseListPayloadShape> {\n #query: ListQueryViewTarget<PAYLOAD>;\n #viewLimit: number;\n #pageSize: number;\n #viewId: string;\n #hasAutoFetch: boolean;\n #fetchMore: () => Promise<void>;\n #pendingFetchMore: Promise<void> | undefined;\n #lastPayload: PAYLOAD | undefined;\n #observer: Observer<PAYLOAD> | undefined;\n\n constructor(\n query: ListQueryViewTarget<PAYLOAD>,\n pageSize: number,\n autoFetchMore?: boolean | number,\n ) {\n this.#query = query;\n this.#pageSize = pageSize;\n this.#viewId = `view_${++viewIdCounter}`;\n\n // With autoFetchMore, subscriber sees all loaded data (no view limit)\n // Otherwise, limit to their pageSize\n this.#hasAutoFetch = autoFetchMore === true\n || (typeof autoFetchMore === \"number\" && autoFetchMore > 0);\n this.#viewLimit = this.#hasAutoFetch ? Number.MAX_SAFE_INTEGER : pageSize;\n\n // Memoize fetchMore to maintain stable function identity\n this.#fetchMore = this.#createFetchMore();\n\n // Tell the query to fetch with at least this pageSize\n query.registerFetchPageSize(this.#viewId, pageSize);\n }\n\n subscribe(observer: Observer<PAYLOAD>): Subscription {\n this.#observer = observer;\n const sub = this.#query.subscribe({\n next: (payload) => {\n this.#lastPayload = payload;\n observer.next?.(this.#transformPayload(payload));\n\n if (\n !this.#hasAutoFetch\n && payload.status === \"loaded\"\n && (payload.resolvedList?.length ?? 0) < this.#viewLimit\n && this.#query.hasMorePages()\n ) {\n void this.#query.fetchMore();\n }\n },\n error: (err) => observer.error?.(err),\n complete: () => observer.complete?.(),\n });\n\n // Cleanup: unregister pageSize when subscriber unsubscribes\n sub.add(() => {\n this.#query.unregisterFetchPageSize(this.#viewId);\n this.#observer = undefined;\n this.#lastPayload = undefined;\n });\n\n return sub;\n }\n\n #reEmitWithNewViewLimit(): void {\n if (this.#lastPayload && this.#observer) {\n this.#observer.next?.(this.#transformPayload(this.#lastPayload));\n }\n }\n\n #transformPayload(payload: PAYLOAD): PAYLOAD {\n const resolvedList = payload.resolvedList;\n const loadedCount = resolvedList?.length ?? 0;\n\n return {\n ...payload,\n resolvedList: resolvedList?.slice(0, this.#viewLimit),\n hasMore: this.#viewLimit < loadedCount || payload.hasMore,\n fetchMore: this.#fetchMore,\n status: loadedCount >= this.#viewLimit && payload.status === \"loading\"\n ? \"loaded\"\n : payload.status,\n };\n }\n\n #createFetchMore(): () => Promise<void> {\n return () => {\n if (this.#pendingFetchMore) {\n return this.#pendingFetchMore;\n }\n\n this.#viewLimit += this.#pageSize;\n\n const loadedCount = this.#query.getLoadedCount();\n const hasMoreOnServer = this.#query.hasMorePages();\n\n if (this.#viewLimit > loadedCount && hasMoreOnServer) {\n // Need to fetch more data from server\n this.#pendingFetchMore = this.#query.fetchMore().finally(() => {\n this.#pendingFetchMore = undefined;\n });\n return this.#pendingFetchMore;\n }\n\n // We have enough data in cache, just re-emit with new viewLimit (sync)\n this.#reEmitWithNewViewLimit();\n return Promise.resolve();\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,aAAa,GAAG,CAAC;AAErB,OAAO,MAAMC,aAAa,CAAuC;EAC/D,CAACC,KAAK;EACN,CAACC,SAAS;EACV,CAACC,QAAQ;EACT,C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CAACE,MAAM,KAAK,SAAS,GAClE,QAAQ,GACRF,OAAO,CAACE;IACd,CAAC;EACH;EAEA,CAACP,eAAeuB,CAAA,EAAwB;IACtC,OAAO,MAAM;MACX,IAAI,IAAI,CAAC,CAAC9B,gBAAgB,EAAE;QAC1B,OAAO,IAAI,CAAC,CAACA,gBAAgB;MAC/B;MAEA,IAAI,CAAC,CAACL,SAAS,IAAI,IAAI,CAAC,CAACC,QAAQ;MAEjC,MAAM+B,WAAW,GAAG,IAAI,CAAC,CAACjC,KAAK,CAACqC,cAAc,CAAC,CAAC;MAChD,MAAMC,eAAe,GAAG,IAAI,CAAC,CAACtC,KAAK,CAACuB,YAAY,CAAC,CAAC;MAElD,IAAI,IAAI,CAAC,CAACtB,SAAS,GAAGgC,WAAW,IAAIK,eAAe,EAAE;QACpD;QACA,IAAI,CAAC,CAAChC,gBAAgB,GAAG,IAAI,CAAC,CAACN,KAAK,CAACK,SAAS,CAAC,CAAC,CAACkC,OAAO,CAAC,MAAM;UAC7D,IAAI,CAAC,CAACjC,gBAAgB,GAAGuB,SAAS;QACpC,CAAC,CAAC;QACF,OAAO,IAAI,CAAC,CAACvB,gBAAgB;MAC/B;;MAEA;MACA,IAAI,CAAC,CAACwB,sBAAsB,CAAC,CAAC;MAC9B,OAAOU,OAAO,CAACC,OAAO,CAAC,CAAC;IAC1B,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ListQueryView.js","names":["viewIdCounter","ListQueryView","query","viewLimit","pageSize","viewId","autoFetchMinimum","fetchMore","pendingFetchMore","lastPayload","observer","constructor","autoFetchMore","Number","MAX_SAFE_INTEGER","createFetchMore","registerFetchPageSize","subscribe","sub","next","payload","transformPayload","loadedCount","resolvedList","length","fetchThreshold","status","hasMorePages","error","err","complete","add","unregisterFetchPageSize","undefined","reEmitWithNewViewLimit","#reEmitWithNewViewLimit","#transformPayload","slice","hasMore","#createFetchMore","getLoadedCount","hasMoreOnServer","finally","Promise","resolve"],"sources":["ListQueryView.ts"],"sourcesContent":["/*\n * Copyright 2025 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 type { Subscription } from \"rxjs\";\nimport type { Observer, Status } from \"../ObservableClient/common.js\";\nimport type { BaseListPayloadShape } from \"./base-list/BaseListQuery.js\";\n\n/**\n * Interface for the query methods that ListQueryView needs.\n * This allows ListQueryView to work with any query that supports these operations.\n */\nexport interface ListQueryViewTarget<PAYLOAD extends BaseListPayloadShape> {\n subscribe(observer: Observer<PAYLOAD>): Subscription;\n registerFetchPageSize(viewId: string, pageSize: number): void;\n unregisterFetchPageSize(viewId: string): void;\n getLoadedCount(): number;\n hasMorePages(): boolean;\n notifySubscribers(): void;\n fetchMore(): Promise<void>;\n}\n\n/**\n * A view into a shared ListQuery cache.\n *\n * Each subscriber gets their own View instance that tracks how much of the\n * shared cache they want to see (viewLimit). This allows multiple components\n * with different pageSize requirements to share the same underlying cache.\n *\n * The View:\n * - Slices the shared data to the subscriber's viewLimit\n * - Provides a fetchMore that increments viewLimit and fetches if needed\n * - Reports hasMore based on both local viewLimit and server pagination\n * - Drives autoFetchMore page-by-page when enabled (per-subscriber concern)\n */\nlet viewIdCounter = 0;\n\nexport class ListQueryView<PAYLOAD extends BaseListPayloadShape> {\n #query: ListQueryViewTarget<PAYLOAD>;\n #viewLimit: number;\n #pageSize: number;\n #viewId: string;\n #autoFetchMinimum: number;\n #fetchMore: () => Promise<void>;\n #pendingFetchMore: Promise<void> | undefined;\n #lastPayload: PAYLOAD | undefined;\n #observer: Observer<PAYLOAD> | undefined;\n\n constructor(\n query: ListQueryViewTarget<PAYLOAD>,\n pageSize: number,\n autoFetchMore?: boolean | number,\n ) {\n this.#query = query;\n this.#pageSize = pageSize;\n this.#viewId = `view_${++viewIdCounter}`;\n\n this.#autoFetchMinimum = autoFetchMore === true\n ? Number.MAX_SAFE_INTEGER\n : (typeof autoFetchMore === \"number\" && autoFetchMore > 0)\n ? autoFetchMore\n : 0;\n this.#viewLimit = this.#autoFetchMinimum > 0\n ? Number.MAX_SAFE_INTEGER\n : pageSize;\n\n // Memoize fetchMore to maintain stable function identity\n this.#fetchMore = this.#createFetchMore();\n\n // Tell the query to fetch with at least this pageSize\n query.registerFetchPageSize(this.#viewId, pageSize);\n }\n\n subscribe(observer: Observer<PAYLOAD>): Subscription {\n this.#observer = observer;\n const sub = this.#query.subscribe({\n next: (payload) => {\n this.#lastPayload = payload;\n this.#observer?.next?.(this.#transformPayload(payload));\n\n const loadedCount = payload.resolvedList?.length ?? 0;\n const fetchThreshold = this.#autoFetchMinimum > 0\n ? this.#autoFetchMinimum\n : this.#viewLimit;\n\n if (\n payload.status === \"loaded\"\n && this.#query.hasMorePages()\n && loadedCount < fetchThreshold\n ) {\n void this.#query.fetchMore();\n }\n },\n error: (err) => observer.error?.(err),\n complete: () => observer.complete?.(),\n });\n\n // Cleanup: unregister pageSize when subscriber unsubscribes\n sub.add(() => {\n this.#query.unregisterFetchPageSize(this.#viewId);\n this.#observer = undefined;\n this.#lastPayload = undefined;\n });\n\n return sub;\n }\n\n #reEmitWithNewViewLimit(): void {\n if (this.#lastPayload && this.#observer) {\n this.#observer.next?.(this.#transformPayload(this.#lastPayload));\n }\n }\n\n #transformPayload(payload: PAYLOAD): PAYLOAD {\n const resolvedList = payload.resolvedList;\n const loadedCount = resolvedList?.length ?? 0;\n\n let status: Status = payload.status;\n\n // When auto-fetching and below threshold with more pages available,\n // report \"loading\" to prevent status oscillation\n if (\n this.#autoFetchMinimum > 0\n && status === \"loaded\"\n && this.#query.hasMorePages()\n && loadedCount < this.#autoFetchMinimum\n ) {\n status = \"loading\";\n }\n\n // When query says \"loading\" but we have enough for our view, report \"loaded\"\n if (loadedCount >= this.#viewLimit && status === \"loading\") {\n status = \"loaded\";\n }\n\n return {\n ...payload,\n resolvedList: resolvedList?.slice(0, this.#viewLimit),\n hasMore: this.#viewLimit < loadedCount || payload.hasMore,\n fetchMore: this.#fetchMore,\n status,\n };\n }\n\n #createFetchMore(): () => Promise<void> {\n return () => {\n if (this.#pendingFetchMore) {\n return this.#pendingFetchMore;\n }\n\n this.#viewLimit += this.#pageSize;\n\n const loadedCount = this.#query.getLoadedCount();\n const hasMoreOnServer = this.#query.hasMorePages();\n\n if (this.#viewLimit > loadedCount && hasMoreOnServer) {\n // Need to fetch more data from server\n this.#pendingFetchMore = this.#query.fetchMore().finally(() => {\n this.#pendingFetchMore = undefined;\n });\n return this.#pendingFetchMore;\n }\n\n // We have enough data in cache, just re-emit with new viewLimit (sync)\n this.#reEmitWithNewViewLimit();\n return Promise.resolve();\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,aAAa,GAAG,CAAC;AAErB,OAAO,MAAMC,aAAa,CAAuC;EAC/D,CAACC,KAAK;EACN,CAACC,SAAS;EACV,CAACC,QAAQ;EACT,CAACC,MAAM;EACP,CAACC,gBAAgB;EACjB,CAACC,SAAS;EACV,CAACC,gBAAgB;EACjB,CAACC,WAAW;EACZ,CAACC,QAAQ;EAETC,WAAWA,CACTT,KAAmC,EACnCE,QAAgB,EAChBQ,aAAgC,EAChC;IACA,IAAI,CAAC,CAACV,KAAK,GAAGA,KAAK;IACnB,IAAI,CAAC,CAACE,QAAQ,GAAGA,QAAQ;IACzB,IAAI,CAAC,CAACC,MAAM,GAAG,QAAQ,EAAEL,aAAa,EAAE;IAExC,IAAI,CAAC,C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,CAAC,EAAE,IAAI,CAAC,CAAClC,SAAS,CAAC;MACrDmC,OAAO,EAAE,IAAI,CAAC,CAACnC,SAAS,GAAGmB,WAAW,IAAIF,OAAO,CAACkB,OAAO;MACzD/B,SAAS,EAAE,IAAI,CAAC,CAACA,SAAS;MAC1BmB;IACF,CAAC;EACH;EAEA,CAACX,eAAewB,CAAA,EAAwB;IACtC,OAAO,MAAM;MACX,IAAI,IAAI,CAAC,CAAC/B,gBAAgB,EAAE;QAC1B,OAAO,IAAI,CAAC,CAACA,gBAAgB;MAC/B;MAEA,IAAI,CAAC,CAACL,SAAS,IAAI,IAAI,CAAC,CAACC,QAAQ;MAEjC,MAAMkB,WAAW,GAAG,IAAI,CAAC,CAACpB,KAAK,CAACsC,cAAc,CAAC,CAAC;MAChD,MAAMC,eAAe,GAAG,IAAI,CAAC,CAACvC,KAAK,CAACyB,YAAY,CAAC,CAAC;MAElD,IAAI,IAAI,CAAC,CAACxB,SAAS,GAAGmB,WAAW,IAAImB,eAAe,EAAE;QACpD;QACA,IAAI,CAAC,CAACjC,gBAAgB,GAAG,IAAI,CAAC,CAACN,KAAK,CAACK,SAAS,CAAC,CAAC,CAACmC,OAAO,CAAC,MAAM;UAC7D,IAAI,CAAC,CAAClC,gBAAgB,GAAGyB,SAAS;QACpC,CAAC,CAAC;QACF,OAAO,IAAI,CAAC,CAACzB,gBAAgB;MAC/B;;MAEA;MACA,IAAI,CAAC,CAAC0B,sBAAsB,CAAC,CAAC;MAC9B,OAAOS,OAAO,CAACC,OAAO,CAAC,CAAC;IAC1B,CAAC;EACH;AACF","ignoreList":[]}
@@ -29,6 +29,9 @@ import { UnsubscribableWrapper } from "./UnsubscribableWrapper.js";
29
29
  * @internal
30
30
  */
31
31
  export class ObservableClientImpl {
32
+ #unionCache = new WeakMap();
33
+ #intersectCache = new WeakMap();
34
+ #subtractCache = new WeakMap();
32
35
  constructor(store) {
33
36
  this.__experimentalStore = store;
34
37
  this.applyAction = store.applyAction.bind(store);
@@ -114,6 +117,35 @@ export class ObservableClientImpl {
114
117
  canonicalizeWhereClause(where) {
115
118
  return this.__experimentalStore.whereCanonicalizer.canonicalize(where);
116
119
  }
120
+ canonicalizeOptions(options) {
121
+ const store = this.__experimentalStore;
122
+ const result = {
123
+ ...options
124
+ };
125
+ result.where = store.whereCanonicalizer.canonicalize(result.where);
126
+ result.withProperties = store.genericCanonicalizer.canonicalize(result.withProperties);
127
+ result.orderBy = store.orderByCanonicalizer.canonicalize(result.orderBy);
128
+ result.aggregate = store.genericCanonicalizer.canonicalize(result.aggregate);
129
+ result.intersectWith = store.genericCanonicalizer.canonicalize(result.intersectWith);
130
+ result.$select = store.selectCanonicalizer.canonicalize(result.$select);
131
+ result.union = this.#canonObjectSetArray(result.union, store.objectSetArrayCanonicalizer.canonicalizeUnion.bind(store.objectSetArrayCanonicalizer), this.#unionCache);
132
+ result.intersect = this.#canonObjectSetArray(result.intersect, store.objectSetArrayCanonicalizer.canonicalizeIntersect.bind(store.objectSetArrayCanonicalizer), this.#intersectCache);
133
+ result.subtract = this.#canonObjectSetArray(result.subtract, store.objectSetArrayCanonicalizer.canonicalizeSubtract.bind(store.objectSetArrayCanonicalizer), this.#subtractCache);
134
+ return result;
135
+ }
136
+ #canonObjectSetArray(arr, canonicalize, cache) {
137
+ if (!arr || arr.length === 0) {
138
+ return arr;
139
+ }
140
+ const wireStrings = arr.map(os => JSON.stringify(getWireObjectSet(os)));
141
+ const canonKey = canonicalize(wireStrings);
142
+ let cached = cache.get(canonKey);
143
+ if (!cached) {
144
+ cached = arr;
145
+ cache.set(canonKey, cached);
146
+ }
147
+ return cached;
148
+ }
117
149
  }
118
150
  function observeSingleLink(store, objectsArray, linkName, options, observer) {
119
151
  if (objectsArray.length === 0) {