| 503 | } |
| 504 | |
| 505 | export const workspaceUsage = (options: WorkspaceUsageOptions) => { |
| 506 | return { |
| 507 | queryKey: [ |
| 508 | "workspaces", |
| 509 | options.workspaceId, |
| 510 | "agents", |
| 511 | options.agentId, |
| 512 | "usage", |
| 513 | options.usageApp, |
| 514 | ], |
| 515 | enabled: |
| 516 | options.workspaceId !== undefined && |
| 517 | options.agentId !== undefined && |
| 518 | options.connectionStatus === "connected", |
| 519 | queryFn: () => { |
| 520 | if (options.workspaceId === undefined || options.agentId === undefined) { |
| 521 | return Promise.reject(); |
| 522 | } |
| 523 | |
| 524 | return API.postWorkspaceUsage(options.workspaceId, { |
| 525 | agent_id: options.agentId, |
| 526 | app_name: options.usageApp, |
| 527 | }); |
| 528 | }, |
| 529 | // ...disabledRefetchOptions, |
| 530 | refetchInterval: 60000, |
| 531 | refetchIntervalInBackground: true, |
| 532 | }; |
| 533 | }; |
| 534 | |
| 535 | export const workspacePermissions = (workspace?: Workspace) => { |
| 536 | return { |