@osdk/client 2.7.0-beta.10 → 2.7.0-beta.11

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 (89) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/browser/observable/FunctionPayload.js +2 -0
  3. package/build/browser/observable/FunctionPayload.js.map +1 -0
  4. package/build/browser/observable/ObservableClient.js.map +1 -1
  5. package/build/browser/observable/internal/Changes.js +3 -0
  6. package/build/browser/observable/internal/Changes.js.map +1 -1
  7. package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
  8. package/build/browser/observable/internal/ObservableClientImpl.js +20 -0
  9. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  10. package/build/browser/observable/internal/Store.js +8 -0
  11. package/build/browser/observable/internal/Store.js.map +1 -1
  12. package/build/browser/observable/internal/actions/ActionApplication.js +11 -7
  13. package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
  14. package/build/browser/observable/internal/function/FunctionCacheKey.js +26 -0
  15. package/build/browser/observable/internal/function/FunctionCacheKey.js.map +1 -0
  16. package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.js +150 -0
  17. package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.js.map +1 -0
  18. package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.test.js +186 -0
  19. package/build/browser/observable/internal/function/FunctionParamsCanonicalizer.test.js.map +1 -0
  20. package/build/browser/observable/internal/function/FunctionQuery.js +137 -0
  21. package/build/browser/observable/internal/function/FunctionQuery.js.map +1 -0
  22. package/build/browser/observable/internal/function/FunctionQuery.test.js +278 -0
  23. package/build/browser/observable/internal/function/FunctionQuery.test.js.map +1 -0
  24. package/build/browser/observable/internal/function/FunctionsHelper.js +92 -0
  25. package/build/browser/observable/internal/function/FunctionsHelper.js.map +1 -0
  26. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  27. package/build/browser/util/UserAgent.js +2 -2
  28. package/build/cjs/{Client-DaUJl7jZ.d.cts → Client-Cmx6x_V1.d.cts} +1 -1
  29. package/build/cjs/{chunk-MZZAHBN6.cjs → chunk-666JN2DO.cjs} +6 -4
  30. package/build/cjs/{chunk-MZZAHBN6.cjs.map → chunk-666JN2DO.cjs.map} +1 -1
  31. package/build/cjs/{createClient-D5G3qzAO.d.cts → createClient-BPK4om7e.d.cts} +1 -1
  32. package/build/cjs/index.cjs +7 -7
  33. package/build/cjs/index.d.cts +2 -2
  34. package/build/cjs/public/internal.d.cts +1 -1
  35. package/build/cjs/public/unstable-do-not-use.cjs +375 -23
  36. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  37. package/build/cjs/public/unstable-do-not-use.d.cts +55 -4
  38. package/build/esm/observable/FunctionPayload.js +2 -0
  39. package/build/esm/observable/FunctionPayload.js.map +1 -0
  40. package/build/esm/observable/ObservableClient.js.map +1 -1
  41. package/build/esm/observable/internal/Changes.js +3 -0
  42. package/build/esm/observable/internal/Changes.js.map +1 -1
  43. package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
  44. package/build/esm/observable/internal/ObservableClientImpl.js +20 -0
  45. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  46. package/build/esm/observable/internal/Store.js +8 -0
  47. package/build/esm/observable/internal/Store.js.map +1 -1
  48. package/build/esm/observable/internal/actions/ActionApplication.js +11 -7
  49. package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
  50. package/build/esm/observable/internal/function/FunctionCacheKey.js +26 -0
  51. package/build/esm/observable/internal/function/FunctionCacheKey.js.map +1 -0
  52. package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.js +150 -0
  53. package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.js.map +1 -0
  54. package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.test.js +186 -0
  55. package/build/esm/observable/internal/function/FunctionParamsCanonicalizer.test.js.map +1 -0
  56. package/build/esm/observable/internal/function/FunctionQuery.js +137 -0
  57. package/build/esm/observable/internal/function/FunctionQuery.js.map +1 -0
  58. package/build/esm/observable/internal/function/FunctionQuery.test.js +278 -0
  59. package/build/esm/observable/internal/function/FunctionQuery.test.js.map +1 -0
  60. package/build/esm/observable/internal/function/FunctionsHelper.js +92 -0
  61. package/build/esm/observable/internal/function/FunctionsHelper.js.map +1 -0
  62. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  63. package/build/esm/util/UserAgent.js +2 -2
  64. package/build/types/observable/FunctionPayload.d.ts +10 -0
  65. package/build/types/observable/FunctionPayload.d.ts.map +1 -0
  66. package/build/types/observable/ObservableClient.d.ts +52 -1
  67. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  68. package/build/types/observable/internal/Changes.d.ts +5 -3
  69. package/build/types/observable/internal/Changes.d.ts.map +1 -1
  70. package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
  71. package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
  72. package/build/types/observable/internal/Store.d.ts +5 -1
  73. package/build/types/observable/internal/Store.d.ts.map +1 -1
  74. package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
  75. package/build/types/observable/internal/function/FunctionCacheKey.d.ts +17 -0
  76. package/build/types/observable/internal/function/FunctionCacheKey.d.ts.map +1 -0
  77. package/build/types/observable/internal/function/FunctionParamsCanonicalizer.d.ts +16 -0
  78. package/build/types/observable/internal/function/FunctionParamsCanonicalizer.d.ts.map +1 -0
  79. package/build/types/observable/internal/function/FunctionParamsCanonicalizer.test.d.ts +1 -0
  80. package/build/types/observable/internal/function/FunctionParamsCanonicalizer.test.d.ts.map +1 -0
  81. package/build/types/observable/internal/function/FunctionQuery.d.ts +40 -0
  82. package/build/types/observable/internal/function/FunctionQuery.d.ts.map +1 -0
  83. package/build/types/observable/internal/function/FunctionQuery.test.d.ts +1 -0
  84. package/build/types/observable/internal/function/FunctionQuery.test.d.ts.map +1 -0
  85. package/build/types/observable/internal/function/FunctionsHelper.d.ts +25 -0
  86. package/build/types/observable/internal/function/FunctionsHelper.d.ts.map +1 -0
  87. package/build/types/public/unstable-do-not-use.d.ts +2 -1
  88. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  89. package/package.json +8 -8
@@ -0,0 +1,278 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { addOne, Employee } from "@osdk/client.test.ontology";
18
+ import { LegacyFauxFoundry, startNodeApiServer } from "@osdk/shared.test";
19
+ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
20
+ import { createClient } from "../../../createClient.js";
21
+ import { createChangedObjects } from "../Changes.js";
22
+ import { Store } from "../Store.js";
23
+ function mockFunctionSubCallback() {
24
+ return {
25
+ next: vi.fn(),
26
+ error: vi.fn(),
27
+ complete: vi.fn()
28
+ };
29
+ }
30
+ function createMockObjectHolder(apiName, primaryKey) {
31
+ return {
32
+ $apiName: apiName,
33
+ $primaryKey: primaryKey
34
+ };
35
+ }
36
+ async function waitForCall(mock, count = 1) {
37
+ await vi.waitFor(() => {
38
+ expect(mock.next).toHaveBeenCalledTimes(count);
39
+ });
40
+ }
41
+ describe("FunctionQuery", () => {
42
+ let client;
43
+ let store;
44
+ beforeAll(() => {
45
+ const testSetup = startNodeApiServer(new LegacyFauxFoundry(), createClient);
46
+ ({
47
+ client
48
+ } = testSetup);
49
+ return () => {
50
+ testSetup.apiServer.close();
51
+ };
52
+ });
53
+ beforeEach(() => {
54
+ store = new Store(client);
55
+ return () => {
56
+ store = undefined;
57
+ };
58
+ });
59
+ afterEach(() => {
60
+ vi.clearAllMocks();
61
+ });
62
+ it("observes function execution and returns result", async () => {
63
+ const subFn = mockFunctionSubCallback();
64
+ const subscription = store.functions.observe({
65
+ queryDef: addOne,
66
+ params: {
67
+ n: 2
68
+ },
69
+ dedupeInterval: 0
70
+ }, subFn);
71
+ await waitForCall(subFn, 1);
72
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
73
+ status: "loading"
74
+ }));
75
+ await waitForCall(subFn, 2);
76
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
77
+ status: "loaded",
78
+ result: 3
79
+ }));
80
+ subscription.unsubscribe();
81
+ });
82
+ it("invalidates function and re-fetches", async () => {
83
+ const subFn = mockFunctionSubCallback();
84
+ const subscription = store.functions.observe({
85
+ queryDef: addOne,
86
+ params: {
87
+ n: 2
88
+ },
89
+ dedupeInterval: 0
90
+ }, subFn);
91
+ await waitForCall(subFn, 2);
92
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
93
+ status: "loaded",
94
+ result: 3
95
+ }));
96
+ subFn.next.mockClear();
97
+
98
+ // Invalidate the function
99
+ await store.invalidateFunction(addOne, {
100
+ n: 2
101
+ });
102
+
103
+ // Wait for refetch to complete - gets loading then loaded
104
+ await vi.waitFor(() => {
105
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
106
+ status: "loaded",
107
+ result: 3
108
+ }));
109
+ });
110
+ subscription.unsubscribe();
111
+ });
112
+ it("dependsOn triggers refetch on object type invalidation", async () => {
113
+ const subFn = mockFunctionSubCallback();
114
+ const subscription = store.functions.observe({
115
+ queryDef: addOne,
116
+ params: {
117
+ n: 2
118
+ },
119
+ dependsOn: [Employee.apiName],
120
+ dedupeInterval: 0
121
+ }, subFn);
122
+ await waitForCall(subFn, 2);
123
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
124
+ status: "loaded",
125
+ result: 3
126
+ }));
127
+ subFn.next.mockClear();
128
+
129
+ // Invalidate Employee object type - should trigger function refetch
130
+ await store.invalidateObjectType(Employee, undefined);
131
+
132
+ // Should refetch
133
+ await waitForCall(subFn, 2);
134
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
135
+ status: "loaded",
136
+ result: 3
137
+ }));
138
+ subscription.unsubscribe();
139
+ });
140
+ it("cache key deduplicates same function calls", async () => {
141
+ const subFn1 = mockFunctionSubCallback();
142
+ const subFn2 = mockFunctionSubCallback();
143
+ const sub1 = store.functions.observe({
144
+ queryDef: addOne,
145
+ params: {
146
+ n: 2
147
+ },
148
+ dedupeInterval: 0
149
+ }, subFn1);
150
+
151
+ // Wait for first subscription to load
152
+ await waitForCall(subFn1, 2);
153
+
154
+ // Second subscription with same params should reuse cached result
155
+ const sub2 = store.functions.observe({
156
+ queryDef: addOne,
157
+ params: {
158
+ n: 2
159
+ },
160
+ dedupeInterval: 0
161
+ }, subFn2);
162
+
163
+ // Second subscriber should get the result
164
+ await vi.waitFor(() => {
165
+ expect(subFn2.next).toHaveBeenLastCalledWith(expect.objectContaining({
166
+ result: 3
167
+ }));
168
+ });
169
+ sub1.unsubscribe();
170
+ sub2.unsubscribe();
171
+ });
172
+ it("dependsOnObjects triggers refetch when specific object is modified", async () => {
173
+ const subFn = mockFunctionSubCallback();
174
+ const mockEmployee = {
175
+ $apiName: Employee.apiName,
176
+ $primaryKey: 50030
177
+ };
178
+
179
+ // Create a function query that depends on a specific employee object
180
+ const subscription = store.functions.observe({
181
+ queryDef: addOne,
182
+ params: {
183
+ n: 2
184
+ },
185
+ dependsOnObjects: [mockEmployee],
186
+ dedupeInterval: 0
187
+ }, subFn);
188
+ await waitForCall(subFn, 2);
189
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
190
+ status: "loaded",
191
+ result: 3
192
+ }));
193
+ subFn.next.mockClear();
194
+ let functionQuery;
195
+ for (const cacheKey of store.queries.keys()) {
196
+ if (cacheKey.type === "function") {
197
+ functionQuery = store.queries.peek(cacheKey);
198
+ break;
199
+ }
200
+ }
201
+ const changes = createChangedObjects();
202
+ changes.modifiedObjects.set(Employee.apiName, createMockObjectHolder(Employee.apiName, 50030));
203
+ expect(functionQuery).toBeDefined();
204
+ const revalidatePromise = functionQuery.maybeUpdateAndRevalidate(changes, undefined);
205
+ expect(revalidatePromise).toBeInstanceOf(Promise);
206
+ await revalidatePromise;
207
+ await vi.waitFor(() => {
208
+ expect(subFn.next).toHaveBeenCalled();
209
+ });
210
+ subscription.unsubscribe();
211
+ });
212
+ it("dependsOnObjects does NOT trigger refetch for different object", async () => {
213
+ const subFn = mockFunctionSubCallback();
214
+ const mockEmployee = {
215
+ $apiName: Employee.apiName,
216
+ $primaryKey: 50030
217
+ };
218
+
219
+ // Create a function query that depends on a specific employee object
220
+ const subscription = store.functions.observe({
221
+ queryDef: addOne,
222
+ params: {
223
+ n: 2
224
+ },
225
+ dependsOnObjects: [mockEmployee],
226
+ dedupeInterval: 0
227
+ }, subFn);
228
+ await waitForCall(subFn, 2);
229
+ expect(subFn.next).toHaveBeenLastCalledWith(expect.objectContaining({
230
+ status: "loaded",
231
+ result: 3
232
+ }));
233
+ let functionQuery;
234
+ for (const cacheKey of store.queries.keys()) {
235
+ if (cacheKey.type === "function") {
236
+ functionQuery = store.queries.peek(cacheKey);
237
+ break;
238
+ }
239
+ }
240
+ const changes = createChangedObjects();
241
+ changes.modifiedObjects.set(Employee.apiName, createMockObjectHolder(Employee.apiName, 99999) // Different primary key
242
+ );
243
+ expect(functionQuery).toBeDefined();
244
+ const result = functionQuery.maybeUpdateAndRevalidate(changes, undefined);
245
+ expect(result).toBeUndefined();
246
+ subscription.unsubscribe();
247
+ });
248
+ it("dependsOnObjects triggers refetch for added objects", async () => {
249
+ const subFn = mockFunctionSubCallback();
250
+ const mockEmployee = {
251
+ $apiName: Employee.apiName,
252
+ $primaryKey: 50030
253
+ };
254
+ const subscription = store.functions.observe({
255
+ queryDef: addOne,
256
+ params: {
257
+ n: 2
258
+ },
259
+ dependsOnObjects: [mockEmployee],
260
+ dedupeInterval: 0
261
+ }, subFn);
262
+ await waitForCall(subFn, 2);
263
+ let functionQuery;
264
+ for (const cacheKey of store.queries.keys()) {
265
+ if (cacheKey.type === "function") {
266
+ functionQuery = store.queries.peek(cacheKey);
267
+ break;
268
+ }
269
+ }
270
+ const changes = createChangedObjects();
271
+ changes.addedObjects.set(Employee.apiName, createMockObjectHolder(Employee.apiName, 50030));
272
+ expect(functionQuery).toBeDefined();
273
+ const revalidatePromise = functionQuery.maybeUpdateAndRevalidate(changes, undefined);
274
+ expect(revalidatePromise).toBeInstanceOf(Promise);
275
+ subscription.unsubscribe();
276
+ });
277
+ });
278
+ //# sourceMappingURL=FunctionQuery.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionQuery.test.js","names":["addOne","Employee","LegacyFauxFoundry","startNodeApiServer","afterEach","beforeAll","beforeEach","describe","expect","it","vi","createClient","createChangedObjects","Store","mockFunctionSubCallback","next","fn","error","complete","createMockObjectHolder","apiName","primaryKey","$apiName","$primaryKey","waitForCall","mock","count","waitFor","toHaveBeenCalledTimes","client","store","testSetup","apiServer","close","undefined","clearAllMocks","subFn","subscription","functions","observe","queryDef","params","n","dedupeInterval","toHaveBeenLastCalledWith","objectContaining","status","result","unsubscribe","mockClear","invalidateFunction","dependsOn","invalidateObjectType","subFn1","subFn2","sub1","sub2","mockEmployee","dependsOnObjects","functionQuery","cacheKey","queries","keys","type","peek","changes","modifiedObjects","set","toBeDefined","revalidatePromise","maybeUpdateAndRevalidate","toBeInstanceOf","Promise","toHaveBeenCalled","toBeUndefined","addedObjects"],"sources":["FunctionQuery.test.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 { addOne, Employee } from \"@osdk/client.test.ontology\";\nimport { LegacyFauxFoundry, startNodeApiServer } from \"@osdk/shared.test\";\nimport type { MockedObject } from \"vitest\";\nimport {\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it,\n vi,\n} from \"vitest\";\nimport type { Client } from \"../../../Client.js\";\nimport { createClient } from \"../../../createClient.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { FunctionPayload } from \"../../FunctionPayload.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { createChangedObjects } from \"../Changes.js\";\nimport { Store } from \"../Store.js\";\nimport type { FunctionQuery } from \"./FunctionQuery.js\";\n\nfunction mockFunctionSubCallback(): MockedObject<\n Observer<FunctionPayload | undefined>\n> {\n return {\n next: vi.fn(),\n error: vi.fn(),\n complete: vi.fn(),\n };\n}\n\nfunction createMockObjectHolder(\n apiName: string,\n primaryKey: unknown,\n): ObjectHolder {\n return {\n $apiName: apiName,\n $primaryKey: primaryKey,\n } as ObjectHolder;\n}\n\nasync function waitForCall(\n mock: MockedObject<Observer<FunctionPayload | undefined>>,\n count = 1,\n) {\n await vi.waitFor(() => {\n expect(mock.next).toHaveBeenCalledTimes(count);\n });\n}\n\ndescribe(\"FunctionQuery\", () => {\n let client: Client;\n let store: Store;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(new LegacyFauxFoundry(), createClient);\n ({ client } = testSetup);\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n beforeEach(() => {\n store = new Store(client);\n return () => {\n store = undefined!;\n };\n });\n\n afterEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"observes function execution and returns result\", async () => {\n const subFn = mockFunctionSubCallback();\n\n const subscription = store.functions.observe(\n {\n queryDef: addOne,\n params: { n: 2 },\n dedupeInterval: 0,\n },\n subFn,\n );\n\n await waitForCall(subFn, 1);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({ status: \"loading\" }),\n );\n\n await waitForCall(subFn, 2);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({\n status: \"loaded\",\n result: 3,\n }),\n );\n\n subscription.unsubscribe();\n });\n\n it(\"invalidates function and re-fetches\", async () => {\n const subFn = mockFunctionSubCallback();\n\n const subscription = store.functions.observe(\n {\n queryDef: addOne,\n params: { n: 2 },\n dedupeInterval: 0,\n },\n subFn,\n );\n\n await waitForCall(subFn, 2);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({\n status: \"loaded\",\n result: 3,\n }),\n );\n\n subFn.next.mockClear();\n\n // Invalidate the function\n await store.invalidateFunction(addOne, { n: 2 });\n\n // Wait for refetch to complete - gets loading then loaded\n await vi.waitFor(() => {\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({\n status: \"loaded\",\n result: 3,\n }),\n );\n });\n\n subscription.unsubscribe();\n });\n\n it(\"dependsOn triggers refetch on object type invalidation\", async () => {\n const subFn = mockFunctionSubCallback();\n\n const subscription = store.functions.observe(\n {\n queryDef: addOne,\n params: { n: 2 },\n dependsOn: [Employee.apiName],\n dedupeInterval: 0,\n },\n subFn,\n );\n\n await waitForCall(subFn, 2);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({ status: \"loaded\", result: 3 }),\n );\n\n subFn.next.mockClear();\n\n // Invalidate Employee object type - should trigger function refetch\n await store.invalidateObjectType(Employee, undefined);\n\n // Should refetch\n await waitForCall(subFn, 2);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({ status: \"loaded\", result: 3 }),\n );\n\n subscription.unsubscribe();\n });\n\n it(\"cache key deduplicates same function calls\", async () => {\n const subFn1 = mockFunctionSubCallback();\n const subFn2 = mockFunctionSubCallback();\n\n const sub1 = store.functions.observe(\n { queryDef: addOne, params: { n: 2 }, dedupeInterval: 0 },\n subFn1,\n );\n\n // Wait for first subscription to load\n await waitForCall(subFn1, 2);\n\n // Second subscription with same params should reuse cached result\n const sub2 = store.functions.observe(\n { queryDef: addOne, params: { n: 2 }, dedupeInterval: 0 },\n subFn2,\n );\n\n // Second subscriber should get the result\n await vi.waitFor(() => {\n expect(subFn2.next).toHaveBeenLastCalledWith(\n expect.objectContaining({\n result: 3,\n }),\n );\n });\n\n sub1.unsubscribe();\n sub2.unsubscribe();\n });\n\n it(\"dependsOnObjects triggers refetch when specific object is modified\", async () => {\n const subFn = mockFunctionSubCallback();\n\n const mockEmployee = {\n $apiName: Employee.apiName,\n $primaryKey: 50030,\n };\n\n // Create a function query that depends on a specific employee object\n const subscription = store.functions.observe(\n {\n queryDef: addOne,\n params: { n: 2 },\n dependsOnObjects: [mockEmployee],\n dedupeInterval: 0,\n },\n subFn,\n );\n\n await waitForCall(subFn, 2);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({ status: \"loaded\", result: 3 }),\n );\n\n subFn.next.mockClear();\n\n let functionQuery: FunctionQuery | undefined;\n for (const cacheKey of store.queries.keys()) {\n if (cacheKey.type === \"function\") {\n functionQuery = store.queries.peek(cacheKey) as FunctionQuery;\n break;\n }\n }\n\n const changes = createChangedObjects();\n changes.modifiedObjects.set(\n Employee.apiName,\n createMockObjectHolder(Employee.apiName, 50030),\n );\n\n expect(functionQuery).toBeDefined();\n const revalidatePromise = functionQuery!.maybeUpdateAndRevalidate(\n changes,\n undefined,\n );\n\n expect(revalidatePromise).toBeInstanceOf(Promise);\n await revalidatePromise;\n\n await vi.waitFor(() => {\n expect(subFn.next).toHaveBeenCalled();\n });\n\n subscription.unsubscribe();\n });\n\n it(\"dependsOnObjects does NOT trigger refetch for different object\", async () => {\n const subFn = mockFunctionSubCallback();\n\n const mockEmployee = {\n $apiName: Employee.apiName,\n $primaryKey: 50030,\n };\n\n // Create a function query that depends on a specific employee object\n const subscription = store.functions.observe(\n {\n queryDef: addOne,\n params: { n: 2 },\n dependsOnObjects: [mockEmployee],\n dedupeInterval: 0,\n },\n subFn,\n );\n\n await waitForCall(subFn, 2);\n expect(subFn.next).toHaveBeenLastCalledWith(\n expect.objectContaining({ status: \"loaded\", result: 3 }),\n );\n\n let functionQuery: FunctionQuery | undefined;\n for (const cacheKey of store.queries.keys()) {\n if (cacheKey.type === \"function\") {\n functionQuery = store.queries.peek(cacheKey) as FunctionQuery;\n break;\n }\n }\n\n const changes = createChangedObjects();\n changes.modifiedObjects.set(\n Employee.apiName,\n createMockObjectHolder(Employee.apiName, 99999), // Different primary key\n );\n\n expect(functionQuery).toBeDefined();\n const result = functionQuery!.maybeUpdateAndRevalidate(changes, undefined);\n\n expect(result).toBeUndefined();\n\n subscription.unsubscribe();\n });\n\n it(\"dependsOnObjects triggers refetch for added objects\", async () => {\n const subFn = mockFunctionSubCallback();\n\n const mockEmployee = {\n $apiName: Employee.apiName,\n $primaryKey: 50030,\n };\n\n const subscription = store.functions.observe(\n {\n queryDef: addOne,\n params: { n: 2 },\n dependsOnObjects: [mockEmployee],\n dedupeInterval: 0,\n },\n subFn,\n );\n\n await waitForCall(subFn, 2);\n\n let functionQuery: FunctionQuery | undefined;\n for (const cacheKey of store.queries.keys()) {\n if (cacheKey.type === \"function\") {\n functionQuery = store.queries.peek(cacheKey) as FunctionQuery;\n break;\n }\n }\n\n const changes = createChangedObjects();\n changes.addedObjects.set(\n Employee.apiName,\n createMockObjectHolder(Employee.apiName, 50030),\n );\n\n expect(functionQuery).toBeDefined();\n const revalidatePromise = functionQuery!.maybeUpdateAndRevalidate(\n changes,\n undefined,\n );\n\n expect(revalidatePromise).toBeInstanceOf(Promise);\n\n subscription.unsubscribe();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,4BAA4B;AAC7D,SAASC,iBAAiB,EAAEC,kBAAkB,QAAQ,m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,YAAY,CAACR,GAAG,CACtBlE,QAAQ,CAACmB,OAAO,EAChBD,sBAAsB,CAAClB,QAAQ,CAACmB,OAAO,EAAE,KAAK,CAChD,CAAC;IAEDZ,MAAM,CAACmD,aAAa,CAAC,CAACS,WAAW,CAAC,CAAC;IACnC,MAAMC,iBAAiB,GAAGV,aAAa,CAAEW,wBAAwB,CAC/DL,OAAO,EACP/B,SACF,CAAC;IAED1B,MAAM,CAAC6D,iBAAiB,CAAC,CAACE,cAAc,CAACC,OAAO,CAAC;IAEjDnC,YAAY,CAACW,WAAW,CAAC,CAAC;EAC5B,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { AbstractHelper } from "../AbstractHelper.js";
18
+ import { PARAMS_IDX } from "./FunctionCacheKey.js";
19
+ import { FunctionParamsCanonicalizer } from "./FunctionParamsCanonicalizer.js";
20
+ import { FunctionQuery } from "./FunctionQuery.js";
21
+ export class FunctionsHelper extends AbstractHelper {
22
+ paramsCanonicalizer = new FunctionParamsCanonicalizer();
23
+ constructor(store, cacheKeys) {
24
+ super(store, cacheKeys);
25
+ }
26
+ observe(options, subFn) {
27
+ return super.observe(options, subFn);
28
+ }
29
+ getQuery(options) {
30
+ const {
31
+ queryDef,
32
+ params,
33
+ ...observeOpts
34
+ } = options;
35
+ const apiName = queryDef.apiName;
36
+ const version = queryDef.isFixedVersion ? queryDef.version : undefined;
37
+ const canonicalParams = this.paramsCanonicalizer.canonicalize(params);
38
+ const functionCacheKey = this.cacheKeys.get("function", apiName, version, canonicalParams);
39
+ return this.store.queries.get(functionCacheKey, () => new FunctionQuery(this.store, this.store.subjects.get(functionCacheKey), queryDef, params, functionCacheKey, observeOpts));
40
+ }
41
+ async invalidateFunction(apiName, params) {
42
+ const functionApiName = typeof apiName === "string" ? apiName : apiName.apiName;
43
+ let canonicalParams;
44
+ if (params !== undefined) {
45
+ canonicalParams = this.paramsCanonicalizer.canonicalize(params);
46
+ }
47
+ const promises = [];
48
+ for (const cacheKey of this.store.queries.keys()) {
49
+ if (cacheKey.type !== "function") {
50
+ continue;
51
+ }
52
+ const query = this.store.queries.peek(cacheKey);
53
+ if (!query) {
54
+ continue;
55
+ }
56
+
57
+ // Check if apiName matches
58
+ if (query.apiName !== functionApiName) {
59
+ continue;
60
+ }
61
+
62
+ // If params provided, check for exact match
63
+ if (canonicalParams !== undefined) {
64
+ const queryParams = cacheKey.otherKeys[PARAMS_IDX];
65
+ if (queryParams !== canonicalParams) {
66
+ continue;
67
+ }
68
+ }
69
+
70
+ // Invalidate this query
71
+ promises.push(query.revalidate(true));
72
+ }
73
+ await Promise.allSettled(promises);
74
+ }
75
+ async invalidateFunctionsByObject(apiName, primaryKey) {
76
+ const promises = [];
77
+ for (const cacheKey of this.store.queries.keys()) {
78
+ if (cacheKey.type !== "function") {
79
+ continue;
80
+ }
81
+ const query = this.store.queries.peek(cacheKey);
82
+ if (!query) {
83
+ continue;
84
+ }
85
+ if (query.dependsOnObject(apiName, primaryKey)) {
86
+ promises.push(query.revalidate(true));
87
+ }
88
+ }
89
+ await Promise.allSettled(promises);
90
+ }
91
+ }
92
+ //# sourceMappingURL=FunctionsHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionsHelper.js","names":["AbstractHelper","PARAMS_IDX","FunctionParamsCanonicalizer","FunctionQuery","FunctionsHelper","paramsCanonicalizer","constructor","store","cacheKeys","observe","options","subFn","getQuery","queryDef","params","observeOpts","apiName","version","isFixedVersion","undefined","canonicalParams","canonicalize","functionCacheKey","get","queries","subjects","invalidateFunction","functionApiName","promises","cacheKey","keys","type","query","peek","queryParams","otherKeys","push","revalidate","Promise","allSettled","invalidateFunctionsByObject","primaryKey","dependsOnObject"],"sources":["FunctionsHelper.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 { QueryDefinition } from \"@osdk/api\";\nimport type { FunctionPayload } from \"../../FunctionPayload.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { CacheKeys } from \"../CacheKeys.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { KnownCacheKey } from \"../KnownCacheKey.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { Store } from \"../Store.js\";\nimport { type FunctionCacheKey, PARAMS_IDX } from \"./FunctionCacheKey.js\";\nimport type { CanonicalFunctionParams } from \"./FunctionParamsCanonicalizer.js\";\nimport { FunctionParamsCanonicalizer } from \"./FunctionParamsCanonicalizer.js\";\nimport { type FunctionObserveOptions, FunctionQuery } from \"./FunctionQuery.js\";\n\ntype PrimaryKeyValue = string | number;\ntype FunctionParams = Record<string, unknown>;\n\nexport interface ObserveFunctionOptions extends FunctionObserveOptions {\n queryDef: QueryDefinition<unknown>;\n params?: FunctionParams;\n}\n\nexport class FunctionsHelper extends AbstractHelper<\n FunctionQuery,\n ObserveFunctionOptions\n> {\n readonly paramsCanonicalizer: FunctionParamsCanonicalizer =\n new FunctionParamsCanonicalizer();\n\n constructor(store: Store, cacheKeys: CacheKeys<KnownCacheKey>) {\n super(store, cacheKeys);\n }\n\n observe(\n options: ObserveFunctionOptions,\n subFn: Observer<FunctionPayload>,\n ): QuerySubscription<FunctionQuery> {\n return super.observe(options, subFn);\n }\n\n getQuery(options: ObserveFunctionOptions): FunctionQuery {\n const { queryDef, params, ...observeOpts } = options;\n const apiName = queryDef.apiName;\n const version = queryDef.isFixedVersion ? queryDef.version : undefined;\n\n const canonicalParams = this.paramsCanonicalizer.canonicalize(params);\n\n const functionCacheKey = this.cacheKeys.get<FunctionCacheKey>(\n \"function\",\n apiName,\n version,\n canonicalParams,\n );\n\n return this.store.queries.get(functionCacheKey, () =>\n new FunctionQuery(\n this.store,\n this.store.subjects.get(functionCacheKey),\n queryDef,\n params,\n functionCacheKey,\n observeOpts,\n ));\n }\n\n async invalidateFunction(\n apiName: string | QueryDefinition<unknown>,\n params?: FunctionParams,\n ): Promise<void> {\n const functionApiName = typeof apiName === \"string\"\n ? apiName\n : apiName.apiName;\n\n let canonicalParams: Canonical<CanonicalFunctionParams> | undefined;\n if (params !== undefined) {\n canonicalParams = this.paramsCanonicalizer.canonicalize(params);\n }\n\n const promises: Array<Promise<void>> = [];\n\n for (const cacheKey of this.store.queries.keys()) {\n if (cacheKey.type !== \"function\") {\n continue;\n }\n\n const query = this.store.queries.peek(cacheKey) as\n | FunctionQuery\n | undefined;\n if (!query) {\n continue;\n }\n\n // Check if apiName matches\n if (query.apiName !== functionApiName) {\n continue;\n }\n\n // If params provided, check for exact match\n if (canonicalParams !== undefined) {\n const queryCacheKey = cacheKey as FunctionCacheKey;\n const queryParams = queryCacheKey.otherKeys[PARAMS_IDX];\n if (queryParams !== canonicalParams) {\n continue;\n }\n }\n\n // Invalidate this query\n promises.push(query.revalidate(true));\n }\n\n await Promise.allSettled(promises);\n }\n\n async invalidateFunctionsByObject(\n apiName: string,\n primaryKey: PrimaryKeyValue,\n ): Promise<void> {\n const promises: Array<Promise<void>> = [];\n\n for (const cacheKey of this.store.queries.keys()) {\n if (cacheKey.type !== \"function\") {\n continue;\n }\n\n const query = this.store.queries.peek(cacheKey) as\n | FunctionQuery\n | undefined;\n if (!query) {\n continue;\n }\n\n if (query.dependsOnObject(apiName, primaryKey)) {\n promises.push(query.revalidate(true));\n }\n }\n\n await Promise.allSettled(promises);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,cAAc,QAAQ,sBAAsB;AAMrD,SAAgCC,UAAU,QAAQ,uBAAuB;AAEzE,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAAsCC,aAAa,QAAQ,oBAAoB;AAU/E,OAAO,MAAMC,eAAe,SAASJ,cAAc,CAGjD;EACSK,mBAAmB,GAC1B,IAAIH,2BAA2B,CAAC,CAAC;EAEnCI,WAAWA,CAACC,KAAY,EAAEC,SAAmC,EAAE;IAC7D,KAAK,CAACD,KAAK,EAAEC,SAAS,CAAC;EACzB;EAEAC,OAAOA,CACLC,OAA+B,EAC/BC,KAAgC,EACE;IAClC,OAAO,KAAK,CAACF,OAAO,CAACC,OAAO,EAAEC,KAAK,CAAC;EACtC;EAEAC,QAAQA,CAACF,OAA+B,EAAiB;IACvD,MAAM;MAAEG,QAAQ;MAAEC,MAAM;MAAE,GAAGC;IAAY,CAAC,GAAGL,OAAO;IACpD,MAAMM,OAAO,GAAGH,QAAQ,CAACG,OAAO;IAChC,MAAMC,OAAO,GAAGJ,QAAQ,CAACK,cAAc,GAAGL,QAAQ,CAACI,OAAO,GAAGE,SAAS;IAEtE,MAAMC,eAAe,GAAG,IAAI,CAACf,mBAAmB,CAACgB,YAAY,CAACP,MAAM,CAAC;IAErE,MAAMQ,gBAAgB,GAAG,IAAI,CAACd,SAAS,CAACe,GAAG,CACzC,UAAU,EACVP,OAAO,EACPC,OAAO,EACPG,eACF,CAAC;IAED,OA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;EAEA,MAAMY,2BAA2BA,CAC/BxB,OAAe,EACfyB,UAA2B,EACZ;IACf,MAAMb,QAA8B,GAAG,EAAE;IAEzC,KAAK,MAAMC,QAAQ,IAAI,IAAI,CAACtB,KAAK,CAACiB,OAAO,CAACM,IAAI,CAAC,CAAC,EAAE;MAChD,IAAID,QAAQ,CAACE,IAAI,KAAK,UAAU,EAAE;QAChC;MACF;MAEA,MAAMC,KAAK,GAAG,IAAI,CAACzB,KAAK,CAACiB,OAAO,CAACS,IAAI,CAACJ,QAAQ,CAEjC;MACb,IAAI,CAACG,KAAK,EAAE;QACV;MACF;MAEA,IAAIA,KAAK,CAACU,eAAe,CAAC1B,OAAO,EAAEyB,UAAU,CAAC,EAAE;QAC9Cb,QAAQ,CAACQ,IAAI,CAACJ,KAAK,CAACK,UAAU,CAAC,IAAI,CAAC,CAAC;MACvC;IACF;IAEA,MAAMC,OAAO,CAACC,UAAU,CAACX,QAAQ,CAAC;EACpC;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"unstable-do-not-use.js","names":["augment","computeObjectSetCacheKey","createObservableClient","getMetaTagContent","getOsdkConfig","createClientWithTransaction"],"sources":["unstable-do-not-use.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { augment } from \"../object/fetchPage.js\";\n\n// THIS IS NOT THE FINAL NAME DO NOT SHIP LIKE THIS\nexport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nexport { computeObjectSetCacheKey } from \"../observable/computeObjectSetCacheKey.js\";\nexport { createObservableClient } from \"../observable/ObservableClient.js\";\nexport type {\n ObservableClient,\n ObserveAggregationArgs,\n ObserveObjectCallbackArgs,\n ObserveObjectsCallbackArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../observable/ObservableClient.js\";\nexport type { Observer } from \"../observable/ObservableClient/common.js\";\nexport type { ObserveLinks } from \"../observable/ObservableClient/ObserveLink.js\";\nexport {\n getMetaTagContent,\n getOsdkConfig,\n} from \"../public-utils/osdkConfig.js\";\nexport type { OsdkConfig } from \"../public-utils/osdkConfig.js\";\n\nexport { createClientWithTransaction } from \"../createClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,wBAAwB;;AAEhD;;AAEA,SAASC,wBAAwB,QAAQ,2CAA2C;AACpF,SAASC,sBAAsB,QAAQ,mCAAmC;AAW1E,SACEC,iBAAiB,EACjBC,aAAa,QACR,+BAA+B;AAGtC,SAASC,2BAA2B,QAAQ,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"unstable-do-not-use.js","names":["augment","computeObjectSetCacheKey","createObservableClient","getMetaTagContent","getOsdkConfig","createClientWithTransaction"],"sources":["unstable-do-not-use.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { augment } from \"../object/fetchPage.js\";\n\n// THIS IS NOT THE FINAL NAME DO NOT SHIP LIKE THIS\nexport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nexport { computeObjectSetCacheKey } from \"../observable/computeObjectSetCacheKey.js\";\nexport { createObservableClient } from \"../observable/ObservableClient.js\";\nexport type {\n ObservableClient,\n ObserveAggregationArgs,\n ObserveFunctionCallbackArgs,\n ObserveFunctionOptions,\n ObserveObjectCallbackArgs,\n ObserveObjectsCallbackArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../observable/ObservableClient.js\";\nexport type { Observer } from \"../observable/ObservableClient/common.js\";\nexport type { ObserveLinks } from \"../observable/ObservableClient/ObserveLink.js\";\nexport {\n getMetaTagContent,\n getOsdkConfig,\n} from \"../public-utils/osdkConfig.js\";\nexport type { OsdkConfig } from \"../public-utils/osdkConfig.js\";\n\nexport { createClientWithTransaction } from \"../createClient.js\";\nexport type { QueryParameterType, QueryReturnType } from \"../queries/types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,wBAAwB;;AAEhD;;AAEA,SAASC,wBAAwB,QAAQ,2CAA2C;AACpF,SAASC,sBAAsB,QAAQ,mCAAmC;AAa1E,SACEC,iBAAiB,EACjBC,aAAa,QACR,+BAA+B;AAGtC,SAASC,2BAA2B,QAAQ,oBAAoB","ignoreList":[]}
@@ -14,6 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export const USER_AGENT = `osdk-client/${"2.7.0-beta.10"}`;
18
- export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.10"}`;
17
+ export const USER_AGENT = `osdk-client/${"2.7.0-beta.11"}`;
18
+ export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.11"}`;
19
19
  //# sourceMappingURL=UserAgent.js.map
@@ -63,4 +63,4 @@ interface Client extends SharedClient, OldSharedClient {
63
63
  fetchMetadata<Q extends (ObjectTypeDefinition | InterfaceDefinition | ActionDefinition<any> | QueryDefinition<any>)>(o: Q): Promise<Q extends ObjectTypeDefinition ? ObjectMetadata : Q extends InterfaceDefinition ? InterfaceMetadata : Q extends ActionDefinition<any> ? ActionMetadata : Q extends QueryDefinition<any> ? QueryMetadata : never>;
64
64
  }
65
65
 
66
- export type { ActionSignatureFromDef as A, Client as C };
66
+ export type { ActionSignatureFromDef as A, Client as C, QueryReturnType as Q, QueryParameterType as a };
@@ -2014,8 +2014,8 @@ var createStandardOntologyProviderFactory = (client) => {
2014
2014
 
2015
2015
  // src/util/UserAgent.ts
2016
2016
  chunkLDTMSHUZ_cjs.init_cjs_shims();
2017
- var USER_AGENT = `osdk-client/${"2.7.0-beta.10"}`;
2018
- var OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.10"}`;
2017
+ var USER_AGENT = `osdk-client/${"2.7.0-beta.11"}`;
2018
+ var OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.11"}`;
2019
2019
 
2020
2020
  // src/createMinimalClient.ts
2021
2021
  function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = chunkRDZ5NKAI_cjs.createObjectSet, createOntologyProviderFactory = createStandardOntologyProviderFactory) {
@@ -2548,6 +2548,7 @@ exports.OBSERVABLE_USER_AGENT = OBSERVABLE_USER_AGENT;
2548
2548
  exports.ObjectDefRef = ObjectDefRef;
2549
2549
  exports.USER_AGENT = USER_AGENT;
2550
2550
  exports.UnderlyingOsdkObject = UnderlyingOsdkObject;
2551
+ exports.applyQuery = applyQuery;
2551
2552
  exports.createAttachmentUpload = createAttachmentUpload;
2552
2553
  exports.createClient = createClient;
2553
2554
  exports.createClientFromContext = createClientFromContext;
@@ -2555,5 +2556,6 @@ exports.createClientWithTransaction = createClientWithTransaction;
2555
2556
  exports.createObjectSpecifierFromPrimaryKey = createObjectSpecifierFromPrimaryKey;
2556
2557
  exports.createOsdkObject = createOsdkObject;
2557
2558
  exports.extractPrimaryKeyFromObjectSpecifier = extractPrimaryKeyFromObjectSpecifier;
2558
- //# sourceMappingURL=chunk-MZZAHBN6.cjs.map
2559
- //# sourceMappingURL=chunk-MZZAHBN6.cjs.map
2559
+ exports.isObjectSpecifiersObject = isObjectSpecifiersObject;
2560
+ //# sourceMappingURL=chunk-666JN2DO.cjs.map
2561
+ //# sourceMappingURL=chunk-666JN2DO.cjs.map