@osdk/react 0.9.0-beta.5 → 0.9.0-beta.7

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 (72) hide show
  1. package/AGENTS.md +253 -0
  2. package/CHANGELOG.md +31 -0
  3. package/build/browser/intellisense.test.js +1 -1
  4. package/build/browser/intellisense.test.js.map +1 -1
  5. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js +2 -2
  6. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  7. package/build/browser/new/platform-apis/admin/useFoundryUser.js +2 -2
  8. package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  9. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js +2 -2
  10. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  11. package/build/browser/new/useLinks.js +1 -1
  12. package/build/browser/new/useLinks.js.map +1 -1
  13. package/build/browser/new/useOsdkAggregation.js +1 -1
  14. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  15. package/build/browser/new/useOsdkFunction.js +101 -0
  16. package/build/browser/new/useOsdkFunction.js.map +1 -0
  17. package/build/browser/new/useOsdkObject.js +1 -1
  18. package/build/browser/new/useOsdkObject.js.map +1 -1
  19. package/build/browser/new/useOsdkObjects.js +1 -1
  20. package/build/browser/new/useOsdkObjects.js.map +1 -1
  21. package/build/browser/public/experimental.js +1 -0
  22. package/build/browser/public/experimental.js.map +1 -1
  23. package/build/browser/utils/usePlatformQuery.js +1 -1
  24. package/build/browser/utils/usePlatformQuery.js.map +1 -1
  25. package/build/cjs/public/experimental.cjs +77 -379
  26. package/build/cjs/public/experimental.cjs.map +1 -1
  27. package/build/cjs/public/experimental.d.cts +139 -27
  28. package/build/esm/intellisense.test.js +1 -1
  29. package/build/esm/intellisense.test.js.map +1 -1
  30. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js +2 -2
  31. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  32. package/build/esm/new/platform-apis/admin/useFoundryUser.js +2 -2
  33. package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  34. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js +2 -2
  35. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  36. package/build/esm/new/useLinks.js +1 -1
  37. package/build/esm/new/useLinks.js.map +1 -1
  38. package/build/esm/new/useOsdkAggregation.js +1 -1
  39. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  40. package/build/esm/new/useOsdkFunction.js +101 -0
  41. package/build/esm/new/useOsdkFunction.js.map +1 -0
  42. package/build/esm/new/useOsdkObject.js +1 -1
  43. package/build/esm/new/useOsdkObject.js.map +1 -1
  44. package/build/esm/new/useOsdkObjects.js +1 -1
  45. package/build/esm/new/useOsdkObjects.js.map +1 -1
  46. package/build/esm/public/experimental.js +1 -0
  47. package/build/esm/public/experimental.js.map +1 -1
  48. package/build/esm/utils/usePlatformQuery.js +1 -1
  49. package/build/esm/utils/usePlatformQuery.js.map +1 -1
  50. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts +2 -2
  51. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -1
  52. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts +4 -4
  53. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -1
  54. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts +4 -4
  55. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -1
  56. package/build/types/new/useLinks.d.ts +5 -5
  57. package/build/types/new/useLinks.d.ts.map +1 -1
  58. package/build/types/new/useOsdkAggregation.d.ts +4 -5
  59. package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
  60. package/build/types/new/useOsdkFunction.d.ts +112 -0
  61. package/build/types/new/useOsdkFunction.d.ts.map +1 -0
  62. package/build/types/new/useOsdkObjects.d.ts +5 -5
  63. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  64. package/build/types/public/experimental.d.ts +2 -0
  65. package/build/types/public/experimental.d.ts.map +1 -1
  66. package/docs/actions.md +414 -0
  67. package/docs/advanced-queries.md +657 -0
  68. package/docs/cache-management.md +213 -0
  69. package/docs/getting-started.md +382 -0
  70. package/docs/platform-apis.md +203 -0
  71. package/docs/querying-data.md +648 -0
  72. package/package.json +9 -6
@@ -1,8 +1,9 @@
1
- import { Client, ObjectTypeDefinition, Osdk, InterfaceDefinition, WhereClause, PropertyKeys, ActionDefinition, ActionEditResponse, ActionValidationError, ActionValidationResponse } from '@osdk/client';
2
- import { ObservableClient, ActionSignatureFromDef } from '@osdk/client/unstable-do-not-use';
1
+ import { Client, Osdk, WhereClause, PropertyKeys, ActionDefinition, ActionEditResponse, ActionValidationError, ActionValidationResponse } from '@osdk/client';
2
+ import { ObservableClient, ActionSignatureFromDef, QueryParameterType, QueryReturnType } from '@osdk/client/unstable-do-not-use';
3
3
  import React from 'react';
4
- import { Admin, Core } from '@osdk/foundry';
5
- import { LinkNames, LinkedType, ObjectTypeDefinition as ObjectTypeDefinition$1, SimplePropertyDef, ObjectSet, WhereClause as WhereClause$1, DerivedProperty, PropertyKeys as PropertyKeys$1, Osdk as Osdk$1, InterfaceDefinition as InterfaceDefinition$1, AggregateOpts, AggregationsResults, PrimaryKeyType } from '@osdk/api';
4
+ import { User, ListUsersResponse } from '@osdk/foundry.admin';
5
+ import { UserStatus } from '@osdk/foundry.core';
6
+ import { ObjectOrInterfaceDefinition, LinkNames, LinkedType, ObjectTypeDefinition, SimplePropertyDef, ObjectSet, WhereClause as WhereClause$1, DerivedProperty, PropertyKeys as PropertyKeys$1, Osdk as Osdk$1, InterfaceDefinition, AggregateOpts, AggregationsResults, QueryDefinition, CompileTimeMetadata, PrimaryKeyType } from '@osdk/api';
6
7
  export { U as UseOsdkMetadataResult, u as useOsdkClient, a as useOsdkMetadata } from '../useOsdkMetadata-DFZhnhGZ.cjs';
7
8
 
8
9
  interface OsdkProviderOptions {
@@ -29,7 +30,7 @@ interface UseCurrentFoundryUserOptions {
29
30
  enabled?: boolean;
30
31
  }
31
32
  interface UseCurrentFoundryUserResult {
32
- currentUser: Admin.User | undefined;
33
+ currentUser: User | undefined;
33
34
  isLoading: boolean;
34
35
  error: Error | undefined;
35
36
  refetch: () => void;
@@ -60,10 +61,10 @@ interface UseFoundryUserOptions {
60
61
  *
61
62
  * @default "ACTIVE"
62
63
  */
63
- status?: Core.UserStatus;
64
+ status?: UserStatus;
64
65
  }
65
66
  interface UseFoundryUserResult {
66
- user: Admin.User | undefined;
67
+ user: User | undefined;
67
68
  isLoading: boolean;
68
69
  error: Error | undefined;
69
70
  refetch: () => void;
@@ -95,7 +96,7 @@ interface UseFoundryUsersListOptions {
95
96
  *
96
97
  * @default "ACTIVE"
97
98
  */
98
- include?: Core.UserStatus;
99
+ include?: UserStatus;
99
100
  /**
100
101
  * The preferred page size for the list.
101
102
  *
@@ -110,7 +111,7 @@ interface UseFoundryUsersListOptions {
110
111
  pageToken?: string;
111
112
  }
112
113
  interface UseFoundryUsersListResult {
113
- users: Admin.ListUsersResponse["data"] | undefined;
114
+ users: ListUsersResponse["data"] | undefined;
114
115
  /**
115
116
  * The page token to be used for the next page of users. If this is undefined, there are no more
116
117
  * pages of users to load.
@@ -126,7 +127,7 @@ interface UseFoundryUsersListResult {
126
127
  */
127
128
  declare function useFoundryUsersList({ enabled, include, pageSize, pageToken }?: UseFoundryUsersListOptions): UseFoundryUsersListResult;
128
129
 
129
- interface UseLinksOptions<T extends ObjectTypeDefinition | InterfaceDefinition> {
130
+ interface UseLinksOptions<T extends ObjectOrInterfaceDefinition> {
130
131
  /**
131
132
  * Standard OSDK Where clause for filtering linked objects
132
133
  */
@@ -167,7 +168,7 @@ interface UseLinksOptions<T extends ObjectTypeDefinition | InterfaceDefinition>
167
168
  */
168
169
  enabled?: boolean;
169
170
  }
170
- interface UseLinksResult<Q extends ObjectTypeDefinition | InterfaceDefinition> {
171
+ interface UseLinksResult<Q extends ObjectOrInterfaceDefinition> {
171
172
  links: Osdk.Instance<Q>[] | undefined;
172
173
  isLoading: boolean;
173
174
  error: Error | undefined;
@@ -192,9 +193,9 @@ interface UseLinksResult<Q extends ObjectTypeDefinition | InterfaceDefinition> {
192
193
  * @param options Optional configuration for the link query
193
194
  * @returns UseLinksResult with links data and metadata
194
195
  */
195
- declare function useLinks<T extends ObjectTypeDefinition, L extends LinkNames<T>>(objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined, linkName: L, options?: UseLinksOptions<LinkedType<T, L>>): UseLinksResult<LinkedType<T, L>>;
196
+ declare function useLinks<T extends ObjectOrInterfaceDefinition, L extends LinkNames<T>>(objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined, linkName: L, options?: UseLinksOptions<LinkedType<T, L>>): UseLinksResult<LinkedType<T, L>>;
196
197
 
197
- interface UseObjectSetOptions<Q extends ObjectTypeDefinition$1, RDPs extends Record<string, SimplePropertyDef> = {}> {
198
+ interface UseObjectSetOptions<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> = {}> {
198
199
  /**
199
200
  * Where clause for filtering
200
201
  */
@@ -272,7 +273,7 @@ interface UseObjectSetOptions<Q extends ObjectTypeDefinition$1, RDPs extends Rec
272
273
  */
273
274
  enabled?: boolean;
274
275
  }
275
- interface UseObjectSetResult<Q extends ObjectTypeDefinition$1, RDPs extends Record<string, SimplePropertyDef> = {}> {
276
+ interface UseObjectSetResult<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> = {}> {
276
277
  /**
277
278
  * The fetched data with derived properties
278
279
  */
@@ -305,7 +306,7 @@ interface UseObjectSetResult<Q extends ObjectTypeDefinition$1, RDPs extends Reco
305
306
  * @param options - Options for filtering, sorting, and adding new derived properties
306
307
  * @returns Object set data with both existing and new derived properties
307
308
  */
308
- declare function useObjectSet<Q extends ObjectTypeDefinition$1, BaseRDPs extends Record<string, SimplePropertyDef> = never, RDPs extends Record<string, SimplePropertyDef> = {}>(baseObjectSet: ObjectSet<Q, BaseRDPs>, options?: UseObjectSetOptions<Q, RDPs>): UseObjectSetResult<Q, RDPs>;
309
+ declare function useObjectSet<Q extends ObjectTypeDefinition, BaseRDPs extends Record<string, SimplePropertyDef> = never, RDPs extends Record<string, SimplePropertyDef> = {}>(baseObjectSet: ObjectSet<Q, BaseRDPs>, options?: UseObjectSetOptions<Q, RDPs>): UseObjectSetResult<Q, RDPs>;
309
310
 
310
311
  type ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] & {
311
312
  [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]: ObservableClient.ApplyActionOptions[K];
@@ -331,11 +332,11 @@ interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
331
332
  }
332
333
  declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
333
334
 
334
- type InferRdpTypes<Q extends ObjectTypeDefinition$1 | InterfaceDefinition$1, WP extends DerivedProperty.Clause<Q> | undefined> = WP extends DerivedProperty.Clause<Q> ? {
335
+ type InferRdpTypes<Q extends ObjectTypeDefinition | InterfaceDefinition, WP extends DerivedProperty.Clause<Q> | undefined> = WP extends DerivedProperty.Clause<Q> ? {
335
336
  [K in keyof WP]: WP[K] extends DerivedProperty.Creator<Q, infer T> ? T : never;
336
337
  } : {};
337
338
 
338
- interface UseOsdkAggregationOptions<T extends ObjectTypeDefinition, A extends AggregateOpts<T>, WithProps extends DerivedProperty.Clause<T> | undefined = undefined> {
339
+ interface UseOsdkAggregationOptions<T extends ObjectOrInterfaceDefinition, A extends AggregateOpts<T>, WithProps extends DerivedProperty.Clause<T> | undefined = undefined> {
339
340
  /**
340
341
  * Standard OSDK Where clause to filter objects before aggregation
341
342
  */
@@ -357,7 +358,7 @@ interface UseOsdkAggregationOptions<T extends ObjectTypeDefinition, A extends Ag
357
358
  */
358
359
  dedupeIntervalMs?: number;
359
360
  }
360
- interface UseOsdkAggregationResult<T extends ObjectTypeDefinition, A extends AggregateOpts<T>> {
361
+ interface UseOsdkAggregationResult<T extends ObjectOrInterfaceDefinition, A extends AggregateOpts<T>> {
361
362
  data: AggregationsResults<T, A> | undefined;
362
363
  isLoading: boolean;
363
364
  error: Error | undefined;
@@ -387,9 +388,120 @@ interface UseOsdkAggregationResult<T extends ObjectTypeDefinition, A extends Agg
387
388
  * });
388
389
  * ```
389
390
  */
390
- declare function useOsdkAggregation<Q extends ObjectTypeDefinition, A extends AggregateOpts<Q>, WP extends DerivedProperty.Clause<Q> | undefined = undefined>(type: Q, { where, withProperties, aggregate, dedupeIntervalMs, }: UseOsdkAggregationOptions<Q, A, WP>): UseOsdkAggregationResult<Q, A>;
391
+ declare function useOsdkAggregation<Q extends ObjectOrInterfaceDefinition, A extends AggregateOpts<Q>, WP extends DerivedProperty.Clause<Q> | undefined = undefined>(type: Q, { where, withProperties, aggregate, dedupeIntervalMs, }: UseOsdkAggregationOptions<Q, A, WP>): UseOsdkAggregationResult<Q, A>;
391
392
 
392
- interface UseOsdkObjectResult<Q extends ObjectTypeDefinition$1> {
393
+ interface UseOsdkFunctionOptions<Q extends QueryDefinition<unknown>> {
394
+ /**
395
+ * Parameters to pass to the function.
396
+ * Must include all required parameters; optional parameters can be omitted.
397
+ */
398
+ params?: CompileTimeMetadata<Q>["parameters"] extends Record<string, never> ? undefined : QueryParameterType<CompileTimeMetadata<Q>["parameters"]>;
399
+ /**
400
+ * Object types this function depends on.
401
+ * When actions modify objects of these types, the function will automatically refetch.
402
+ *
403
+ * @example
404
+ * ```tsx
405
+ * // Refetch when any Employee object changes
406
+ * { dependsOn: [Employee] }
407
+ * ```
408
+ */
409
+ dependsOn?: Array<ObjectTypeDefinition | string>;
410
+ /**
411
+ * Specific object instances this function depends on.
412
+ * When any of these specific objects change, the function will refetch.
413
+ * More fine-grained than dependsOn for precise invalidation control.
414
+ *
415
+ * @example
416
+ * ```tsx
417
+ * // Refetch when this specific employee changes
418
+ * { dependsOnObjects: [employee] }
419
+ * ```
420
+ */
421
+ dependsOnObjects?: Array<Osdk$1.Instance<ObjectTypeDefinition>>;
422
+ /**
423
+ * The number of milliseconds to dedupe identical function calls.
424
+ * Two calls with the same function and params will share results
425
+ * if the second call is within this interval of the first.
426
+ * @default 2000
427
+ */
428
+ dedupeIntervalMs?: number;
429
+ /**
430
+ * Whether to enable the query. When false, the query will not execute.
431
+ * Useful for:
432
+ * - Dependent queries that need to wait for other data
433
+ * - Conditional queries based on component state
434
+ *
435
+ * @default true
436
+ * @example
437
+ * // Dependent query - wait for required data
438
+ * const { data: employee } = useOsdkObject(Employee, employeeId);
439
+ * const { data: report } = useOsdkFunction(getEmployeeReport, {
440
+ * params: { employeeId: employee?.$primaryKey },
441
+ * enabled: !!employee
442
+ * });
443
+ */
444
+ enabled?: boolean;
445
+ }
446
+ interface UseOsdkFunctionResult<Q extends QueryDefinition<unknown>> {
447
+ /**
448
+ * The function result, or undefined if not yet loaded or on error.
449
+ */
450
+ data: QueryReturnType<CompileTimeMetadata<Q>["output"]> | undefined;
451
+ /**
452
+ * True while the function is executing.
453
+ */
454
+ isLoading: boolean;
455
+ /**
456
+ * Error if the function execution failed.
457
+ */
458
+ error: Error | undefined;
459
+ /**
460
+ * Timestamp (ms since epoch) of when the result was last fetched.
461
+ */
462
+ lastUpdated: number;
463
+ /**
464
+ * Manually refetch the function.
465
+ * Useful for "pull to refresh" or retry patterns.
466
+ */
467
+ refetch: () => void;
468
+ }
469
+ /**
470
+ * React hook for executing and observing OSDK functions.
471
+ *
472
+ * Provides automatic caching, deduplication, and reactive updates for function calls.
473
+ * Functions are automatically re-fetched when dependencies change (configured via options).
474
+ *
475
+ * @param queryDef - The QueryDefinition to execute
476
+ * @param options - Configuration options for the function call
477
+ * @returns Object containing result, loading state, error, and refetch function
478
+ *
479
+ * @example Basic usage
480
+ * ```tsx
481
+ * const { data, isLoading, error } = useOsdkFunction(getEmployeeStats, {
482
+ * params: { departmentId: "engineering" }
483
+ * });
484
+ * ```
485
+ *
486
+ * @example With dependency tracking
487
+ * ```tsx
488
+ * const { data, refetch } = useOsdkFunction(calculateMetrics, {
489
+ * params: { startDate, endDate },
490
+ * dependsOn: [Employee, Project],
491
+ * });
492
+ * ```
493
+ *
494
+ * @example With specific object dependencies
495
+ * ```tsx
496
+ * const { data } = useOsdkFunction(getEmployeeReport, {
497
+ * params: { employeeId: employee.$primaryKey },
498
+ * dependsOnObjects: [employee],
499
+ * });
500
+ * ```
501
+ */
502
+ declare function useOsdkFunction<Q extends QueryDefinition<unknown>>(queryDef: Q, options?: UseOsdkFunctionOptions<Q>): UseOsdkFunctionResult<Q>;
503
+
504
+ interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {
393
505
  object: Osdk$1.Instance<Q> | undefined;
394
506
  isLoading: boolean;
395
507
  error: Error | undefined;
@@ -403,7 +515,7 @@ interface UseOsdkObjectResult<Q extends ObjectTypeDefinition$1> {
403
515
  * @param obj an existing `Osdk.Instance` object to get metadata for.
404
516
  * @param enabled Enable or disable the query (defaults to true)
405
517
  */
406
- declare function useOsdkObject<Q extends ObjectTypeDefinition$1>(obj: Osdk$1.Instance<Q>, enabled?: boolean): UseOsdkObjectResult<Q>;
518
+ declare function useOsdkObject<Q extends ObjectTypeDefinition>(obj: Osdk$1.Instance<Q>, enabled?: boolean): UseOsdkObjectResult<Q>;
407
519
  /**
408
520
  * Loads an object by type and primary key.
409
521
  *
@@ -411,9 +523,9 @@ declare function useOsdkObject<Q extends ObjectTypeDefinition$1>(obj: Osdk$1.Ins
411
523
  * @param primaryKey
412
524
  * @param enabled Enable or disable the query (defaults to true)
413
525
  */
414
- declare function useOsdkObject<Q extends ObjectTypeDefinition$1>(type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean): UseOsdkObjectResult<Q>;
526
+ declare function useOsdkObject<Q extends ObjectTypeDefinition>(type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean): UseOsdkObjectResult<Q>;
415
527
 
416
- interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition$1 | InterfaceDefinition$1, WithProps extends DerivedProperty.Clause<T> | undefined = undefined> {
528
+ interface UseOsdkObjectsOptions<T extends ObjectOrInterfaceDefinition, WithProps extends DerivedProperty.Clause<T> | undefined = undefined> {
417
529
  /**
418
530
  * Standard OSDK Where with RDP support
419
531
  */
@@ -518,7 +630,7 @@ interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition$1 | InterfaceDefi
518
630
  */
519
631
  enabled?: boolean;
520
632
  }
521
- interface UseOsdkListResult<T extends ObjectTypeDefinition$1 | InterfaceDefinition$1, RDPs extends Record<string, SimplePropertyDef> = {}> {
633
+ interface UseOsdkListResult<T extends ObjectOrInterfaceDefinition, RDPs extends Record<string, SimplePropertyDef> = {}> {
522
634
  fetchMore: (() => Promise<void>) | undefined;
523
635
  data: Osdk$1.Instance<T, "$allBaseProperties", PropertyKeys$1<T>, RDPs>[] | undefined;
524
636
  isLoading: boolean;
@@ -532,10 +644,10 @@ interface UseOsdkListResult<T extends ObjectTypeDefinition$1 | InterfaceDefiniti
532
644
  */
533
645
  isOptimistic: boolean;
534
646
  }
535
- declare function useOsdkObjects<Q extends ObjectTypeDefinition$1, L extends LinkNames<Q>>(type: Q, options: UseOsdkObjectsOptions<Q> & {
647
+ declare function useOsdkObjects<Q extends ObjectOrInterfaceDefinition, L extends LinkNames<Q>>(type: Q, options: UseOsdkObjectsOptions<Q> & {
536
648
  pivotTo: L;
537
649
  }): UseOsdkListResult<LinkedType<Q, L>>;
538
- declare function useOsdkObjects<Q extends ObjectTypeDefinition$1 | InterfaceDefinition$1, WP extends DerivedProperty.Clause<Q> | undefined>(type: Q, options?: UseOsdkObjectsOptions<Q, WP>): UseOsdkListResult<Q, InferRdpTypes<Q, WP>>;
650
+ declare function useOsdkObjects<Q extends ObjectOrInterfaceDefinition, WP extends DerivedProperty.Clause<Q> | undefined>(type: Q, options?: UseOsdkObjectsOptions<Q, WP>): UseOsdkListResult<Q, InferRdpTypes<Q, WP>>;
539
651
 
540
652
  interface DebouncedCallback<TArgs extends readonly unknown[]> {
541
653
  (...args: TArgs): void;
@@ -572,4 +684,4 @@ interface DebouncedCallback<TArgs extends readonly unknown[]> {
572
684
  */
573
685
  declare function useDebouncedCallback<TArgs extends readonly unknown[]>(callback: (...args: TArgs) => void | Promise<void>, delay: number): DebouncedCallback<TArgs>;
574
686
 
575
- export { OsdkProvider2, type UseOsdkAggregationResult, type UseOsdkListResult, useCurrentFoundryUser, useDebouncedCallback, useFoundryUser, useFoundryUsersList, useLinks, useObjectSet, useOsdkAction, useOsdkAggregation, useOsdkObject, useOsdkObjects };
687
+ export { OsdkProvider2, type UseOsdkAggregationResult, type UseOsdkFunctionOptions, type UseOsdkFunctionResult, type UseOsdkListResult, useCurrentFoundryUser, useDebouncedCallback, useFoundryUser, useFoundryUsersList, useLinks, useObjectSet, useOsdkAction, useOsdkAggregation, useOsdkFunction, useOsdkObject, useOsdkObjects };
@@ -90,7 +90,7 @@ describe("intellisense", () => {
90
90
  throw error;
91
91
  }
92
92
  });
93
- afterEach(async () => {
93
+ afterEach(() => {
94
94
  if (tsServer) {
95
95
  tsServer.stop();
96
96
  tsServer = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"intellisense.test.js","names":["startTsServer","findUpSync","path","invariant","ts","afterEach","beforeAll","beforeEach","describe","expect","it","vi","rootLogger","hoisted","pino","pinoPretty","EventEmitter","Promise","resolve","level","build","sync","timestampKey","undefined","errorLikeObjectKeys","errorProps","ignore","destination","write","a","at","slice","console","log","packagesDir","reactPackagePath","reactPackageJson","cwd","import","meta","dirname","process","env","NODE_ENV","join","tsServer","intellisenseFilePath","task","name","sys","fileExists","toBeTruthy","sendOpenRequest","file","error","stop","timeout","resp","sendCompletionsRequest","line","offset","triggerKind","CompletionTriggerKind","Invoked","completions","body","entries","map","e","toContain","typeResp","sendQuickInfoRequest","displayString","toBeDefined","dataResp"],"sources":["intellisense.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 type { Logger } from \"@osdk/api\";\nimport type { TsServer } from \"@osdk/client/internal-node\";\nimport { startTsServer } from \"@osdk/client/internal-node\";\nimport { findUpSync } from \"find-up\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport * as ts from \"typescript\";\nimport {\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it,\n vi,\n} from \"vitest\";\n\n// it needs to be hoisted because its referenced from our mocked WebSocket\n// which must be hoisted to work\nconst rootLogger = await vi.hoisted(async (): Promise<Logger> => {\n const pino = (await import(\"pino\")).pino;\n const pinoPretty = await import(\"pino-pretty\");\n const { EventEmitter } = await import(\"node:events\");\n class PinoConsoleLogDestination extends EventEmitter {\n write(a: string) {\n // remove trailing newline since console.log adds one\n if (a.at(-1) === \"\\n\") a = a.slice(0, -1);\n\n // This lets the test framework aggregate the logs per test, whereas direct to stdout does not\n console.log(a);\n }\n }\n return Promise.resolve(pino(\n { level: \"info\" },\n (pinoPretty.build)({\n sync: true,\n timestampKey: undefined,\n errorLikeObjectKeys: [\"error\", \"err\", \"exception\"],\n errorProps: \"stack,cause,properties\",\n ignore: \"time,hostname,pid\",\n destination: new PinoConsoleLogDestination(),\n }),\n ));\n});\n\n/**\n * @vitest-environment node\n * @vitest-pool forks\n */\ndescribe(\"intellisense\", () => {\n let packagesDir: string;\n let reactPackagePath: string;\n\n beforeAll(() => {\n const reactPackageJson = findUpSync(\"package.json\", {\n cwd: import.meta.dirname,\n });\n console.log({ reactPackageJson });\n invariant(reactPackageJson != null);\n packagesDir = path.join(\n path.dirname(reactPackageJson),\n \"..\",\n );\n\n reactPackagePath = path.join(packagesDir, \"react\");\n });\n\n let tsServer: TsServer | undefined;\n let intellisenseFilePath: string;\n\n beforeEach(async (a) => {\n intellisenseFilePath = path.join(\n reactPackagePath,\n \"src\",\n \"intellisense.test.helpers\",\n `${a.task.name}.ts`,\n );\n\n console.log(intellisenseFilePath);\n\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n\n try {\n tsServer = await startTsServer(rootLogger);\n await tsServer.sendOpenRequest({ file: intellisenseFilePath });\n } catch (error) {\n if (tsServer) {\n try {\n tsServer.stop();\n } catch {\n // Ignore cleanup errors\n }\n tsServer = undefined;\n }\n throw error;\n }\n });\n\n afterEach(async () => {\n if (tsServer) {\n tsServer.stop();\n tsServer = undefined;\n }\n });\n\n it(\"useOsdkObjectsWithPivot\", { timeout: 40_000 }, async () => {\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n invariant(tsServer);\n\n const { resp } = await tsServer.sendCompletionsRequest({\n file: intellisenseFilePath,\n line: 29,\n offset: 15,\n triggerKind: ts.CompletionTriggerKind.Invoked,\n });\n\n const completions = resp.body?.entries.map(e => e.name) ?? [];\n expect(completions).toContain(\"lead\");\n\n const { resp: typeResp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 33,\n offset: 10,\n });\n\n expect(typeResp.body?.displayString).toBeDefined();\n expect(typeResp.body?.displayString).toContain(\"Employee\");\n });\n\n it(\"useOsdkObjectsWithProperties\", { timeout: 40_000 }, async () => {\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n invariant(tsServer);\n\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 27,\n offset: 10,\n });\n\n expect(resp.body?.displayString).toContain(\"DerivedProperty.Clause\");\n\n const { resp: dataResp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 31,\n offset: 11,\n });\n\n expect(dataResp.body?.displayString).toBeDefined();\n expect(dataResp.body?.displayString).toContain(\"Osdk.Instance<Employee\");\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,UAAU,QAAQ,SAAS;AACpC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,KAAKC,EAAE,MAAM,YAAY;AAChC,SACEC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,EAAE,EACFC,EAAE,QACG,QAAQ;;AAEf;AACA;AACA,MAAMC,UAAU,GAAG,MAAMD,EAAE,CAACE,OAAO,CAAC,YAA6B;EAC/D,MAAMC,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,EAAEA,IAAI;EACxC,MAAMC,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAC9C,MAAM;IAAEC;EAAa,CAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAUpD,OAAOC,OAAO,CAACC,OAAO,CAACJ,IAAI,CACzB;IAAEK,KAAK,EAAE;EAAO,CAAC,EAChBJ,UAAU,CAACK,KAAK,CAAE;IACjBC,IAAI,EAAE,IAAI;IACVC,YAAY,EAAEC,SAAS;IACvBC,mBAAmB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC;IAClDC,UAAU,EAAE,wBAAwB;IACpCC,MAAM,EAAE,mBAAmB;IAC3BC,WAAW,EAAE,IAjBjB,cAAwCX,YAAY,CAAC;MACnDY,KAAKA,CAACC,CAAS,EAAE;QACf;QACA,IAAIA,CAAC,CAACC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAED,CAAC,GAAGA,CAAC,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;QAE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ts","afterEach","beforeAll","beforeEach","describe","expect","it","vi","rootLogger","hoisted","pino","pinoPretty","EventEmitter","Promise","resolve","level","build","sync","timestampKey","undefined","errorLikeObjectKeys","errorProps","ignore","destination","write","a","at","slice","console","log","packagesDir","reactPackagePath","reactPackageJson","cwd","import","meta","dirname","process","env","NODE_ENV","join","tsServer","intellisenseFilePath","task","name","sys","fileExists","toBeTruthy","sendOpenRequest","file","error","stop","timeout","resp","sendCompletionsRequest","line","offset","triggerKind","CompletionTriggerKind","Invoked","completions","body","entries","map","e","toContain","typeResp","sendQuickInfoRequest","displayString","toBeDefined","dataResp"],"sources":["intellisense.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 type { Logger } from \"@osdk/api\";\nimport type { TsServer } from \"@osdk/client/internal-node\";\nimport { startTsServer } from \"@osdk/client/internal-node\";\nimport { findUpSync } from \"find-up\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport * as ts from \"typescript\";\nimport {\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it,\n vi,\n} from \"vitest\";\n\n// it needs to be hoisted because its referenced from our mocked WebSocket\n// which must be hoisted to work\nconst rootLogger = await vi.hoisted(async (): Promise<Logger> => {\n const pino = (await import(\"pino\")).pino;\n const pinoPretty = await import(\"pino-pretty\");\n const { EventEmitter } = await import(\"node:events\");\n class PinoConsoleLogDestination extends EventEmitter {\n write(a: string) {\n // remove trailing newline since console.log adds one\n if (a.at(-1) === \"\\n\") a = a.slice(0, -1);\n\n // This lets the test framework aggregate the logs per test, whereas direct to stdout does not\n console.log(a);\n }\n }\n return Promise.resolve(pino(\n { level: \"info\" },\n (pinoPretty.build)({\n sync: true,\n timestampKey: undefined,\n errorLikeObjectKeys: [\"error\", \"err\", \"exception\"],\n errorProps: \"stack,cause,properties\",\n ignore: \"time,hostname,pid\",\n destination: new PinoConsoleLogDestination(),\n }),\n ));\n});\n\n/**\n * @vitest-environment node\n * @vitest-pool forks\n */\ndescribe(\"intellisense\", () => {\n let packagesDir: string;\n let reactPackagePath: string;\n\n beforeAll(() => {\n const reactPackageJson = findUpSync(\"package.json\", {\n cwd: import.meta.dirname,\n });\n console.log({ reactPackageJson });\n invariant(reactPackageJson != null);\n packagesDir = path.join(\n path.dirname(reactPackageJson),\n \"..\",\n );\n\n reactPackagePath = path.join(packagesDir, \"react\");\n });\n\n let tsServer: TsServer | undefined;\n let intellisenseFilePath: string;\n\n beforeEach(async (a) => {\n intellisenseFilePath = path.join(\n reactPackagePath,\n \"src\",\n \"intellisense.test.helpers\",\n `${a.task.name}.ts`,\n );\n\n console.log(intellisenseFilePath);\n\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n\n try {\n tsServer = await startTsServer(rootLogger);\n await tsServer.sendOpenRequest({ file: intellisenseFilePath });\n } catch (error) {\n if (tsServer) {\n try {\n tsServer.stop();\n } catch {\n // Ignore cleanup errors\n }\n tsServer = undefined;\n }\n throw error;\n }\n });\n\n afterEach(() => {\n if (tsServer) {\n tsServer.stop();\n tsServer = undefined;\n }\n });\n\n it(\"useOsdkObjectsWithPivot\", { timeout: 40_000 }, async () => {\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n invariant(tsServer);\n\n const { resp } = await tsServer.sendCompletionsRequest({\n file: intellisenseFilePath,\n line: 29,\n offset: 15,\n triggerKind: ts.CompletionTriggerKind.Invoked,\n });\n\n const completions = resp.body?.entries.map(e => e.name) ?? [];\n expect(completions).toContain(\"lead\");\n\n const { resp: typeResp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 33,\n offset: 10,\n });\n\n expect(typeResp.body?.displayString).toBeDefined();\n expect(typeResp.body?.displayString).toContain(\"Employee\");\n });\n\n it(\"useOsdkObjectsWithProperties\", { timeout: 40_000 }, async () => {\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n invariant(tsServer);\n\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 27,\n offset: 10,\n });\n\n expect(resp.body?.displayString).toContain(\"DerivedProperty.Clause\");\n\n const { resp: dataResp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 31,\n offset: 11,\n });\n\n expect(dataResp.body?.displayString).toBeDefined();\n expect(dataResp.body?.displayString).toContain(\"Osdk.Instance<Employee\");\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,UAAU,QAAQ,SAAS;AACpC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,KAAKC,EAAE,MAAM,YAAY;AAChC,SACEC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,EAAE,EACFC,EAAE,QACG,QAAQ;;AAEf;AACA;AACA,MAAMC,UAAU,GAAG,MAAMD,EAAE,CAACE,OAAO,CAAC,YAA6B;EAC/D,MAAMC,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,EAAEA,IAAI;EACxC,MAAMC,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAC9C,MAAM;IAAEC;EAAa,CAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAUpD,OAAOC,OAAO,CAACC,OAAO,CAACJ,IAAI,CACzB;IAAEK,KAAK,EAAE;EAAO,CAAC,EAChBJ,UAAU,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AAG,MAAM7B,QAAQ,CAAC0B,oBAAoB,CAAC;MAC7DlB,IAAI,EAAEP,oBAAoB;MAC1Ba,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE;IACV,CAAC,CAAC;IAEFnD,MAAM,CAACiE,QAAQ,CAACT,IAAI,EAAEO,aAAa,CAAC,CAACC,WAAW,CAAC,CAAC;IAClDhE,MAAM,CAACiE,QAAQ,CAACT,IAAI,EAAEO,aAAa,CAAC,CAACH,SAAS,CAAC,wBAAwB,CAAC;EAC1E,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { Admin } from "@osdk/foundry";
17
+ import { Users } from "@osdk/foundry.admin";
18
18
  import React from "react";
19
19
  import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
20
  import { OsdkContext2 } from "../../OsdkContext2.js";
@@ -28,7 +28,7 @@ export function useCurrentFoundryUser({
28
28
  const {
29
29
  client
30
30
  } = React.useContext(OsdkContext2);
31
- const handleQuery = React.useCallback(() => Admin.Users.getCurrent(client), [client]);
31
+ const handleQuery = React.useCallback(() => Users.getCurrent(client), [client]);
32
32
  const query = usePlatformQuery({
33
33
  query: handleQuery,
34
34
  enabled,
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentFoundryUser.js","names":["Admin","React","usePlatformQuery","OsdkContext2","useCurrentFoundryUser","enabled","client","useContext","handleQuery","useCallback","Users","getCurrent","query","queryName","currentUser","data","isLoading","error","refetch"],"sources":["useCurrentFoundryUser.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 { Admin } from \"@osdk/foundry\";\n\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseCurrentFoundryUserOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseCurrentFoundryUserResult {\n currentUser: Admin.User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the currently signed in User.\n * @param options Options to control the query.\n */\nexport function useCurrentFoundryUser(\n { enabled = true }: UseCurrentFoundryUserOptions = {},\n): UseCurrentFoundryUserResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(\n () => Admin.Users.getCurrent(client),\n [client],\n );\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-current-user\",\n });\n\n return {\n currentUser: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,eAAe;AAErC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AA4BpD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnC;EAAEC,OAAO,GAAG;AAAmC,CAAC,GAAG,CAAC,CAAC,EACxB;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;EAEjD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CACnC,MAAMT,KAAK,CAACU,KAAK,CAACC,UAAU,CAACL,MAAM,CAAC,EACpC,CAACA,MAAM,CACT,CAAC;EAED,MAAMM,KAAK,GAAGV,gBAAgB,CAAC;IAC7BU,KAAK,EAAEJ,WAAW;IAClBH,OAAO;IACPQ,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,WAAW,EAAEF,KAAK,CAACG,IAAI;IACvBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useCurrentFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext2","useCurrentFoundryUser","enabled","client","useContext","handleQuery","useCallback","getCurrent","query","queryName","currentUser","data","isLoading","error","refetch"],"sources":["useCurrentFoundryUser.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 User, Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseCurrentFoundryUserOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseCurrentFoundryUserResult {\n currentUser: User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the currently signed in User.\n * @param options Options to control the query.\n */\nexport function useCurrentFoundryUser(\n { enabled = true }: UseCurrentFoundryUserOptions = {},\n): UseCurrentFoundryUserResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(\n () => Users.getCurrent(client),\n [client],\n );\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-current-user\",\n });\n\n return {\n currentUser: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AACtD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AA4BpD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnC;EAAEC,OAAO,GAAG;AAAmC,CAAC,GAAG,CAAC,CAAC,EACxB;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;EAEjD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CACnC,MAAMT,KAAK,CAACU,UAAU,CAACJ,MAAM,CAAC,EAC9B,CAACA,MAAM,CACT,CAAC;EAED,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,WAAW,EAAEF,KAAK,CAACG,IAAI;IACvBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { Admin } from "@osdk/foundry";
17
+ import { Users } from "@osdk/foundry.admin";
18
18
  import React from "react";
19
19
  import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
20
  import { OsdkContext2 } from "../../OsdkContext2.js";
@@ -31,7 +31,7 @@ export function useFoundryUser(userId, {
31
31
  client
32
32
  } = React.useContext(OsdkContext2);
33
33
  const handleQuery = React.useCallback(() => {
34
- return Admin.Users.get(client, userId, {
34
+ return Users.get(client, userId, {
35
35
  status
36
36
  });
37
37
  }, [client, userId, status]);
@@ -1 +1 @@
1
- {"version":3,"file":"useFoundryUser.js","names":["Admin","React","usePlatformQuery","OsdkContext2","useFoundryUser","userId","enabled","status","client","useContext","handleQuery","useCallback","Users","get","query","queryName","user","data","isLoading","error","refetch"],"sources":["useFoundryUser.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 { Core } from \"@osdk/foundry\";\nimport { Admin } from \"@osdk/foundry\";\n\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseFoundryUserOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n status?: Core.UserStatus;\n}\n\nexport interface UseFoundryUserResult {\n user: Admin.User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the User with the specified id.\n * @param userId A Foundry User ID.\n * @param options Options to control the query.\n */\nexport function useFoundryUser(\n userId: string,\n { enabled = true, status = \"ACTIVE\" }: UseFoundryUserOptions = {},\n): UseFoundryUserResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Admin.Users.get(client, userId, { status });\n }, [client, userId, status]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-user\",\n });\n\n return {\n user: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,KAAK,QAAQ,eAAe;AAErC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAmCpD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,MAAc,EACd;EAAEC,OAAO,GAAG,IAAI;EAAEC,MAAM,GAAG;AAAgC,CAAC,GAAG,CAAC,CAAC,EAC3C;EACtB,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,YAAY,CAAC;EAEjD,MAAMO,WAAW,GAAGT,KAAK,CAACU,WAAW,CAAC,MAAM;IAC1C,OAAOX,KAAK,CAACY,KAAK,CAACC,GAAG,CAACL,MAAM,EAAEH,MAAM,EAAE;MAAEE;IAAO,CAAC,CAAC;EACpD,CAAC,EAAE,CAACC,MAAM,EAAEH,MAAM,EAAEE,MAAM,CAAC,CAAC;EAE5B,MAAMO,KAAK,GAAGZ,gBAAgB,CAAC;IAC7BY,KAAK,EAAEJ,WAAW;IAClBJ,OAAO;IACPS,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAEF,KAAK,CAACG,IAAI;IAChBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext2","useFoundryUser","userId","enabled","status","client","useContext","handleQuery","useCallback","get","query","queryName","user","data","isLoading","error","refetch"],"sources":["useFoundryUser.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 User, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseFoundryUserOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n status?: UserStatus;\n}\n\nexport interface UseFoundryUserResult {\n user: User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the User with the specified id.\n * @param userId A Foundry User ID.\n * @param options Options to control the query.\n */\nexport function useFoundryUser(\n userId: string,\n { enabled = true, status = \"ACTIVE\" }: UseFoundryUserOptions = {},\n): UseFoundryUserResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Users.get(client, userId, { status });\n }, [client, userId, status]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-user\",\n });\n\n return {\n user: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AAEtD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAmCpD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,MAAc,EACd;EAAEC,OAAO,GAAG,IAAI;EAAEC,MAAM,GAAG;AAAgC,CAAC,GAAG,CAAC,CAAC,EAC3C;EACtB,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,YAAY,CAAC;EAEjD,MAAMO,WAAW,GAAGT,KAAK,CAACU,WAAW,CAAC,MAAM;IAC1C,OAAOX,KAAK,CAACY,GAAG,CAACJ,MAAM,EAAEH,MAAM,EAAE;MAAEE;IAAO,CAAC,CAAC;EAC9C,CAAC,EAAE,CAACC,MAAM,EAAEH,MAAM,EAAEE,MAAM,CAAC,CAAC;EAE5B,MAAMM,KAAK,GAAGX,gBAAgB,CAAC;IAC7BW,KAAK,EAAEH,WAAW;IAClBJ,OAAO;IACPQ,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAEF,KAAK,CAACG,IAAI;IAChBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { Admin } from "@osdk/foundry";
17
+ import { Users } from "@osdk/foundry.admin";
18
18
  import React from "react";
19
19
  import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
20
  import { OsdkContext2 } from "../../OsdkContext2.js";
@@ -32,7 +32,7 @@ export function useFoundryUsersList({
32
32
  client
33
33
  } = React.useContext(OsdkContext2);
34
34
  const handleQuery = React.useCallback(() => {
35
- return Admin.Users.list(client, {
35
+ return Users.list(client, {
36
36
  include,
37
37
  pageSize,
38
38
  pageToken
@@ -1 +1 @@
1
- {"version":3,"file":"useFoundryUsersList.js","names":["Admin","React","usePlatformQuery","OsdkContext2","useFoundryUsersList","enabled","include","pageSize","pageToken","client","useContext","handleQuery","useCallback","Users","list","query","queryName","users","data","nextPageToken","isLoading","error","refetch"],"sources":["useFoundryUsersList.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 { Core } from \"@osdk/foundry\";\nimport { Admin } from \"@osdk/foundry\";\n\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseFoundryUsersListOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n include?: Core.UserStatus;\n\n /**\n * The preferred page size for the list.\n *\n * @default 1000\n */\n pageSize?: number;\n\n /**\n * The page token indicates where to start paging. This should be omitted from the first page's request.\n * To fetch the next page, clients should take the value from the nextPageToken field of the previous\n * response and use it to populate the pageToken field of the next request.\n */\n pageToken?: string;\n}\n\nexport interface UseFoundryUsersListResult {\n users: Admin.ListUsersResponse[\"data\"] | undefined;\n /**\n * The page token to be used for the next page of users. If this is undefined, there are no more\n * pages of users to load.\n */\n nextPageToken: string | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.\n * @param options Options to control the query.\n */\nexport function useFoundryUsersList(\n { enabled = true, include = \"ACTIVE\", pageSize = 1000, pageToken }:\n UseFoundryUsersListOptions = {},\n): UseFoundryUsersListResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Admin.Users.list(client, { include, pageSize, pageToken });\n }, [client, include, pageSize, pageToken]);\n\n const query = usePlatformQuery(\n {\n query: handleQuery,\n enabled,\n queryName: \"foundry-users-list\",\n },\n );\n\n return {\n users: query.data?.data,\n nextPageToken: query.data?.nextPageToken,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,KAAK,QAAQ,eAAe;AAErC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAsDpD;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjC;EAAEC,OAAO,GAAG,IAAI;EAAEC,OAAO,GAAG,QAAQ;EAAEC,QAAQ,GAAG,IAAI;EAAEC;AAC5B,CAAC,GAAG,CAAC,CAAC,EACN;EAC3B,MAAM;IAAEC;EAAO,CAAC,GAAGR,KAAK,CAACS,UAAU,CAACP,YAAY,CAAC;EAEjD,MAAMQ,WAAW,GAAGV,KAAK,CAACW,WAAW,CAAC,MAAM;IAC1C,OAAOZ,KAAK,CAACa,KAAK,CAACC,IAAI,CAACL,MAAM,EAAE;MAAEH,OAAO;MAAEC,QAAQ;MAAEC;IAAU,CAAC,CAAC;EACnE,CAAC,EAAE,CAACC,MAAM,EAAEH,OAAO,EAAEC,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAE1C,MAAMO,KAAK,GAAGb,gBAAgB,CAC5B;IACEa,KAAK,EAAEJ,WAAW;IAClBN,OAAO;IACPW,SAAS,EAAE;EACb,CACF,CAAC;EAED,OAAO;IACLC,KAAK,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IACvBC,aAAa,EAAEJ,KAAK,CAACG,IAAI,EAAEC,aAAa;IACxCC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useFoundryUsersList.js","names":["Users","React","usePlatformQuery","OsdkContext2","useFoundryUsersList","enabled","include","pageSize","pageToken","client","useContext","handleQuery","useCallback","list","query","queryName","users","data","nextPageToken","isLoading","error","refetch"],"sources":["useFoundryUsersList.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 ListUsersResponse, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseFoundryUsersListOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n include?: UserStatus;\n\n /**\n * The preferred page size for the list.\n *\n * @default 1000\n */\n pageSize?: number;\n\n /**\n * The page token indicates where to start paging. This should be omitted from the first page's request.\n * To fetch the next page, clients should take the value from the nextPageToken field of the previous\n * response and use it to populate the pageToken field of the next request.\n */\n pageToken?: string;\n}\n\nexport interface UseFoundryUsersListResult {\n users: ListUsersResponse[\"data\"] | undefined;\n /**\n * The page token to be used for the next page of users. If this is undefined, there are no more\n * pages of users to load.\n */\n nextPageToken: string | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.\n * @param options Options to control the query.\n */\nexport function useFoundryUsersList(\n { enabled = true, include = \"ACTIVE\", pageSize = 1000, pageToken }:\n UseFoundryUsersListOptions = {},\n): UseFoundryUsersListResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Users.list(client, { include, pageSize, pageToken });\n }, [client, include, pageSize, pageToken]);\n\n const query = usePlatformQuery(\n {\n query: handleQuery,\n enabled,\n queryName: \"foundry-users-list\",\n },\n );\n\n return {\n users: query.data?.data,\n nextPageToken: query.data?.nextPageToken,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAiCA,KAAK,QAAQ,qBAAqB;AAEnE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAsDpD;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjC;EAAEC,OAAO,GAAG,IAAI;EAAEC,OAAO,GAAG,QAAQ;EAAEC,QAAQ,GAAG,IAAI;EAAEC;AAC5B,CAAC,GAAG,CAAC,CAAC,EACN;EAC3B,MAAM;IAAEC;EAAO,CAAC,GAAGR,KAAK,CAACS,UAAU,CAACP,YAAY,CAAC;EAEjD,MAAMQ,WAAW,GAAGV,KAAK,CAACW,WAAW,CAAC,MAAM;IAC1C,OAAOZ,KAAK,CAACa,IAAI,CAACJ,MAAM,EAAE;MAAEH,OAAO;MAAEC,QAAQ;MAAEC;IAAU,CAAC,CAAC;EAC7D,CAAC,EAAE,CAACC,MAAM,EAAEH,OAAO,EAAEC,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAE1C,MAAMM,KAAK,GAAGZ,gBAAgB,CAC5B;IACEY,KAAK,EAAEH,WAAW;IAClBN,OAAO;IACPU,SAAS,EAAE;EACb,CACF,CAAC;EAED,OAAO;IACLC,KAAK,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IACvBC,aAAa,EAAEJ,KAAK,CAACG,IAAI,EAAEC,aAAa;IACxCC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
@@ -60,7 +60,7 @@ export function useLinks(objects, linkName, options = {}) {
60
60
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
61
61
  return {
62
62
  links: payload?.resolvedList,
63
- isLoading: payload?.status === "loading",
63
+ isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
64
64
  isOptimistic: payload?.isOptimistic ?? false,
65
65
  error: payload?.error,
66
66
  fetchMore: payload?.fetchMore,
@@ -1 +1 @@
1
- {"version":3,"file":"useLinks.js","names":["React","makeExternalStore","OsdkContext2","emptyArray","Object","freeze","useLinks","objects","linkName","options","observableClient","useContext","enabled","otherOptions","objectsArray","useMemo","undefined","Array","isArray","subscribe","getSnapShot","unsubscribe","map","obj","$apiName","$primaryKey","join","observer","observeLinks","where","pageSize","orderBy","mode","payload","useSyncExternalStore","links","resolvedList","isLoading","status","isOptimistic","error","fetchMore","hasMore"],"sources":["useLinks.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 { LinkedType, LinkNames } from \"@osdk/api\";\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ObserveLinks } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseLinksOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n /**\n * Standard OSDK Where clause for filtering linked objects\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the links list.\n */\n pageSize?: number;\n\n /** Sorting options for the linked objects */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The mode to use for fetching data.\n * - undefined: Fetch data if not already in cache\n * - \"force\": Always fetch fresh data\n * - \"offline\": Only use cached data, don't make network requests\n */\n mode?: \"force\" | \"offline\";\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for employee data\n * const { object: employee } = useOsdkObject(Employee, employeeId);\n * const { links: reports } = useLinks(employee, \"reports\", {\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseLinksResult<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n links: Osdk.Instance<Q>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the links are optimistic or not.\n */\n isOptimistic: boolean;\n\n /**\n * Fetch more linked objects if pagination is supported\n */\n fetchMore: (() => Promise<unknown>) | undefined;\n\n /**\n * Indicates if there are more linked objects available to fetch\n */\n hasMore: boolean;\n}\n\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks<\n T extends ObjectTypeDefinition,\n L extends LinkNames<T>,\n>(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined,\n linkName: L,\n options: UseLinksOptions<LinkedType<T, L>> = {},\n): UseLinksResult<LinkedType<T, L>> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, ...otherOptions } = options;\n\n // Convert single object to array for consistent handling\n const objectsArray: ReadonlyArray<Osdk.Instance<T>> = React.useMemo(() => {\n return objects === undefined\n ? emptyArray\n : Array.isArray(objects)\n ? objects\n : [objects];\n }, [objects]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n () => ({ unsubscribe: () => {} }),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n } [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n (observer) =>\n observableClient.observeLinks(\n objectsArray,\n linkName,\n {\n linkName,\n where: otherOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n mode: otherOptions.mode,\n },\n observer,\n ),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n }`,\n );\n },\n [\n enabled,\n observableClient,\n objectsArray,\n linkName,\n otherOptions.where,\n otherOptions.pageSize,\n otherOptions.orderBy,\n otherOptions.mode,\n ],\n );\n\n const payload = React.useSyncExternalStore(\n subscribe,\n getSnapShot,\n );\n\n return {\n links: payload?.resolvedList,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyEhD,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAItBC,OAA+D,EAC/DC,QAAW,EACXC,OAA0C,GAAG,CAAC,CAAC,EACb;EAClC,MAAM;IAAEC;EAAiB,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;EAE3D,MAAM;IAAEU,OAAO,GAAG,IAAI;IAAE,GAAGC;EAAa,CAAC,GAAGJ,OAAO;;EAEnD;EACA,MAAM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AI,CAErB,CAAC;EAED,MAAMC,OAAO,GAAGjC,KAAK,CAACkC,oBAAoB,CACxCf,SAAS,EACTC,WACF,CAAC;EAED,OAAO;IACLe,KAAK,EAAEF,OAAO,EAAEG,YAAY;IAC5BC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS;IACxCC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,KAAK,EAAEP,OAAO,EAAEO,KAAK;IACrBC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,OAAO,EAAET,OAAO,EAAES,OAAO,IAAI;EAC/B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useLinks.js","names":["React","makeExternalStore","OsdkContext2","emptyArray","Object","freeze","useLinks","objects","linkName","options","observableClient","useContext","enabled","otherOptions","objectsArray","useMemo","undefined","Array","isArray","subscribe","getSnapShot","unsubscribe","map","obj","$apiName","$primaryKey","join","observer","observeLinks","where","pageSize","orderBy","mode","payload","useSyncExternalStore","links","resolvedList","isLoading","status","isOptimistic","error","fetchMore","hasMore"],"sources":["useLinks.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 LinkedType,\n LinkNames,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type { Osdk, PropertyKeys, WhereClause } from \"@osdk/client\";\nimport type { ObserveLinks } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseLinksOptions<\n T extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Standard OSDK Where clause for filtering linked objects\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the links list.\n */\n pageSize?: number;\n\n /** Sorting options for the linked objects */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The mode to use for fetching data.\n * - undefined: Fetch data if not already in cache\n * - \"force\": Always fetch fresh data\n * - \"offline\": Only use cached data, don't make network requests\n */\n mode?: \"force\" | \"offline\";\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for employee data\n * const { object: employee } = useOsdkObject(Employee, employeeId);\n * const { links: reports } = useLinks(employee, \"reports\", {\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseLinksResult<\n Q extends ObjectOrInterfaceDefinition,\n> {\n links: Osdk.Instance<Q>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the links are optimistic or not.\n */\n isOptimistic: boolean;\n\n /**\n * Fetch more linked objects if pagination is supported\n */\n fetchMore: (() => Promise<unknown>) | undefined;\n\n /**\n * Indicates if there are more linked objects available to fetch\n */\n hasMore: boolean;\n}\n\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks<\n T extends ObjectOrInterfaceDefinition,\n L extends LinkNames<T>,\n>(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined,\n linkName: L,\n options: UseLinksOptions<LinkedType<T, L>> = {},\n): UseLinksResult<LinkedType<T, L>> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, ...otherOptions } = options;\n\n // Convert single object to array for consistent handling\n const objectsArray: ReadonlyArray<Osdk.Instance<T>> = React.useMemo(() => {\n return objects === undefined\n ? emptyArray\n : Array.isArray(objects)\n ? objects\n : [objects];\n }, [objects]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n () => ({ unsubscribe: () => {} }),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n } [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n (observer) =>\n observableClient.observeLinks(\n objectsArray,\n linkName,\n {\n linkName,\n where: otherOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n mode: otherOptions.mode,\n },\n observer,\n ),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n }`,\n );\n },\n [\n enabled,\n observableClient,\n objectsArray,\n linkName,\n otherOptions.where,\n otherOptions.pageSize,\n otherOptions.orderBy,\n otherOptions.mode,\n ],\n );\n\n const payload = React.useSyncExternalStore(\n subscribe,\n getSnapShot,\n );\n\n return {\n links: payload?.resolvedList,\n isLoading: enabled\n ? (payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload)\n : false,\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyEhD,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;;A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AAG,CAACC,GAAG,IAAI,GAAGA,GAAG,CAACC,QAAQ,IAAID,GAAG,CAACE,WAAW,EAAE,CAAC,CAACC,IAAI,CAChE,GACF,CAAC,EAEL,CAAC;EACH,CAAC,EACD,CACEd,OAAO,EACPF,gBAAgB,EAChBI,YAAY,EACZN,QAAQ,EACRK,YAAY,CAACgB,KAAK,EAClBhB,YAAY,CAACiB,QAAQ,EACrBjB,YAAY,CAACkB,OAAO,EACpBlB,YAAY,CAACmB,IAAI,CAErB,CAAC;EAED,MAAMC,OAAO,GAAGjC,KAAK,CAACkC,oBAAoB,CACxCf,SAAS,EACTC,WACF,CAAC;EAED,OAAO;IACLe,KAAK,EAAEF,OAAO,EAAEG,YAAY;IAC5BC,SAAS,EAAEzB,OAAO,GACbqB,OAAO,EAAEK,MAAM,KAAK,SAAS,IAAIL,OAAO,EAAEK,MAAM,KAAK,MAAM,IACzD,CAACL,OAAO,GACX,KAAK;IACTM,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,KAAK,EAAEP,OAAO,EAAEO,KAAK;IACrBC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,OAAO,EAAET,OAAO,EAAES,OAAO,IAAI;EAC/B,CAAC;AACH","ignoreList":[]}
@@ -75,7 +75,7 @@ export function useOsdkAggregation(type, {
75
75
  }, [observableClient, type.apiName]);
76
76
  return {
77
77
  data: payload?.result,
78
- isLoading: payload?.status === "loading",
78
+ isLoading: payload?.status === "loading" || payload?.status === "init" || !payload,
79
79
  error,
80
80
  refetch
81
81
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAggregation.js","names":["React","makeExternalStore","OsdkContext2","useOsdkAggregation","type","where","withProperties","aggregate","dedupeIntervalMs","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableAggregate","subscribe","getSnapShot","observer","observeAggregation","dedupeInterval","process","env","NODE_ENV","apiName","payload","useSyncExternalStore","error","status","Error","refetch","useCallback","invalidateObjectType","data","result","isLoading"],"sources":["useOsdkAggregation.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 AggregateOpts,\n AggregationsResults,\n DerivedProperty,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObjectTypeDefinition } from \"@osdk/client\";\nimport type { ObserveAggregationArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type { InferRdpTypes } from \"./types.js\";\n\nexport interface UseOsdkAggregationOptions<\n T extends ObjectTypeDefinition,\n A extends AggregateOpts<T>,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where clause to filter objects before aggregation\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * Define derived properties (RDPs) to be computed server-side.\n * The derived properties can be used in the where clause and aggregation groupBy/select.\n */\n withProperties?: WithProps;\n\n /**\n * Aggregation options including groupBy and select\n */\n aggregate: A;\n\n /**\n * The number of milliseconds to wait after the last observed aggregation change.\n *\n * Two uses of `useOsdkAggregation` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n}\n\nexport interface UseOsdkAggregationResult<\n T extends ObjectTypeDefinition,\n A extends AggregateOpts<T>,\n> {\n data: AggregationsResults<T, A> | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for performing aggregations on OSDK object sets.\n *\n * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.\n * Supports runtime derived properties and where clauses.\n *\n * @param type - The object or interface type to aggregate\n * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties\n * @returns Object containing aggregation results, loading state, error state, and refetch function\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useOsdkAggregation(Employee, {\n * where: { department: \"Engineering\" },\n * aggregate: {\n * groupBy: { department: \"exact\" },\n * select: {\n * avgSalary: { $avg: \"salary\" },\n * count: { $count: {} }\n * }\n * }\n * });\n * ```\n */\nexport function useOsdkAggregation<\n Q extends ObjectTypeDefinition,\n A extends AggregateOpts<Q>,\n WP extends DerivedProperty.Clause<Q> | undefined = undefined,\n>(\n type: Q,\n {\n where = {},\n withProperties,\n aggregate,\n dedupeIntervalMs,\n }: UseOsdkAggregationOptions<Q, A, WP>,\n): UseOsdkAggregationResult<Q, A> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableAggregate = React.useMemo(\n () => aggregate,\n [JSON.stringify(aggregate)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveAggregationArgs<Q, A>>(\n (observer) =>\n observableClient.observeAggregation(\n {\n type: type,\n where: canonWhere,\n withProperties: stableWithProperties,\n aggregate: stableAggregate,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n observer,\n ),\n process.env.NODE_ENV !== \"production\"\n ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [\n observableClient,\n type.apiName,\n type.type,\n canonWhere,\n stableWithProperties,\n stableAggregate,\n dedupeIntervalMs,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to execute aggregation\");\n }\n\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n\n return {\n data: payload?.result as AggregationsResults<Q, A> | undefined,\n isLoading: payload?.status === \"loading\",\n error,\n refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAiDhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAKhCC,IAAO,EACP;EACEC,KAAK,GAAG,CAAC,CAAC;EACVC,cAAc;EACdC,SAAS;EACTC;AACmC,CAAC,EACN;EAChC,MAAM;IAAEC;EAAiB,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACR,YAAY,CAAC;EAE3D,MAAMS,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAAIP,KAAK,IAAI,CAAC,CAAC,CAAC;EAE3E,MAAMQ,oBAAoB,GAAGb,KAAK,CAACc,OAAO,CACxC,MAAMR,cAAc,EACpB,CAACS,IAAI,CAACC,SAAS,CAACV,cAAc,CAAC,CACjC,CAAC;EAED,MAAMW,eAAe,GAAGjB,KAAK,CAACc,OAAO,CACnC,MAAMP,SAAS,EACf,CAACQ,IAAI,CAACC,SAAS,CAACT,SAAS,CAAC,CAC5B,CAAC;EAED,MAAM;IAAEW,SAAS;IAAEC;EAAY,CAAC,GAAGnB,KAAK,CAACc,OAAO,CAC9C,MACEb,iBAAiB,CACdmB,QAAQ,IACPX,gBAAgB,CAACY,kBAAkB,CACjC;IACEjB,IAAI,EAAEA,IAAI;IACVC,KAAK,EAAEM,UAAU;IACjBL,cAAc,EAAEO,oBAAoB;IACpCN,SAAS,EAAEU,eAAe;IAC1BK,cAAc,EAAEd,gBAAgB,IAAI;EACtC,CAAC,EACDY,QACF,CAAC,EACHG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,eAAerB,IAAI,CAACsB,OAAO,IAAIX,IAAI,CAACC,SAAS,CAACL,UAAU,CAAC,EAAE,GAC3D,KAAK,CACX,CAAC,EACH,CACEF,gBAAgB,EAChBL,IAAI,CAACsB,OAAO,EACZtB,IAAI,CAACA,IAAI,EACTO,UAAU,EACVE,oBAAoB,EACpBI,eAAe,EACfT,gBAAgB,CAEpB,CAAC;EAED,MAAMmB,OAAO,GAAG3B,KAAK,CAAC4B,oBAAoB,CAACV,SAAS,EAAEC,WAAW,CAAC;EAElE,IAAIU,KAAwB;EAC5B,IAAIF,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAIA,OAAO,CAACE,KAAK,EAAE;IAClDA,KAAK,GAAGF,OAAO,CAACE,KAAK;EACvB,CAAC,MAAM,IAAIF,OAAO,EAAEG,MAAM,KAAK,OAAO,EAAE;IACtCD,KAAK,GAAG,IAAIE,KAAK,CAAC,+BAA+B,CAAC;EACpD;EAEA,MAAMC,OAAO,GAAGhC,KAAK,CAACiC,WAAW,CAAC,YAAY;IAC5C,MAAMxB,gBAAgB,CAACyB,oBAAoB,CAAC9B,IAAI,CAACsB,OAAO,CAAC;EAC3D,CAAC,EAAE,CAACjB,gBAAgB,EAAEL,IAAI,CAACsB,OAAO,CAAC,CAAC;EAEpC,OAAO;IACLS,IAAI,EAAER,OAAO,EAAES,MAA+C;IAC9DC,SAAS,EAAEV,OAAO,EAAEG,MAAM,KAAK,SAAS;IACxCD,KAAK;IACLG;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAggregation.js","names":["React","makeExternalStore","OsdkContext2","useOsdkAggregation","type","where","withProperties","aggregate","dedupeIntervalMs","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableAggregate","subscribe","getSnapShot","observer","observeAggregation","dedupeInterval","process","env","NODE_ENV","apiName","payload","useSyncExternalStore","error","status","Error","refetch","useCallback","invalidateObjectType","data","result","isLoading"],"sources":["useOsdkAggregation.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 AggregateOpts,\n AggregationsResults,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveAggregationArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type { InferRdpTypes } from \"./types.js\";\n\nexport interface UseOsdkAggregationOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where clause to filter objects before aggregation\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * Define derived properties (RDPs) to be computed server-side.\n * The derived properties can be used in the where clause and aggregation groupBy/select.\n */\n withProperties?: WithProps;\n\n /**\n * Aggregation options including groupBy and select\n */\n aggregate: A;\n\n /**\n * The number of milliseconds to wait after the last observed aggregation change.\n *\n * Two uses of `useOsdkAggregation` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n}\n\nexport interface UseOsdkAggregationResult<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n> {\n data: AggregationsResults<T, A> | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for performing aggregations on OSDK object sets.\n *\n * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.\n * Supports runtime derived properties and where clauses.\n *\n * @param type - The object or interface type to aggregate\n * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties\n * @returns Object containing aggregation results, loading state, error state, and refetch function\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useOsdkAggregation(Employee, {\n * where: { department: \"Engineering\" },\n * aggregate: {\n * groupBy: { department: \"exact\" },\n * select: {\n * avgSalary: { $avg: \"salary\" },\n * count: { $count: {} }\n * }\n * }\n * });\n * ```\n */\nexport function useOsdkAggregation<\n Q extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<Q>,\n WP extends DerivedProperty.Clause<Q> | undefined = undefined,\n>(\n type: Q,\n {\n where = {},\n withProperties,\n aggregate,\n dedupeIntervalMs,\n }: UseOsdkAggregationOptions<Q, A, WP>,\n): UseOsdkAggregationResult<Q, A> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableAggregate = React.useMemo(\n () => aggregate,\n [JSON.stringify(aggregate)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveAggregationArgs<Q, A>>(\n (observer) =>\n observableClient.observeAggregation(\n {\n type: type,\n where: canonWhere,\n withProperties: stableWithProperties,\n aggregate: stableAggregate,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n observer,\n ),\n process.env.NODE_ENV !== \"production\"\n ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [\n observableClient,\n type.apiName,\n type.type,\n canonWhere,\n stableWithProperties,\n stableAggregate,\n dedupeIntervalMs,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to execute aggregation\");\n }\n\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n\n return {\n data: payload?.result as AggregationsResults<Q, A> | undefined,\n isLoading: payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload,\n error,\n refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAiDhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAKhCC,IAAO,EACP;EACEC,KAAK,GAAG,CAAC,CAAC;EACVC,cAAc;EACdC,SAAS;EACTC;AACmC,CAAC,EACN;EAChC,MAAM;IAAEC;EAAiB,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACR,YAAY,CAAC;EAE3D,MAAMS,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAAIP,KAAK,IAAI,CAAC,CAAC,CAAC;EAE3E,MAAMQ,oBAAoB,GAAGb,KAAK,CAACc,OAAO,CACxC,MAAMR,cAAc,EACpB,CAACS,IAAI,CAACC,SAAS,CAACV,cAAc,CAAC,CACjC,CAAC;EAED,MAAMW,eAAe,GAAGjB,KAAK,CAACc,OAAO,CACnC,MAAMP,SA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