lemma-sdk 0.2.44 → 0.2.46
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.
- package/README.md +1 -1
- package/dist/assistant-events.d.ts +1 -0
- package/dist/assistant-events.js +37 -2
- package/dist/browser/lemma-client.js +312 -228
- package/dist/client.js +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js +2 -2
- package/dist/hey_client/client/client.gen.d.ts +2 -0
- package/dist/hey_client/client/client.gen.js +216 -0
- package/dist/hey_client/client/index.d.ts +10 -0
- package/dist/hey_client/client/index.js +6 -0
- package/dist/hey_client/client/types.gen.d.ts +120 -0
- package/dist/hey_client/client/types.gen.js +2 -0
- package/dist/hey_client/client/utils.gen.d.ts +37 -0
- package/dist/hey_client/client/utils.gen.js +228 -0
- package/dist/hey_client/client.gen.d.ts +12 -0
- package/dist/hey_client/client.gen.js +3 -0
- package/dist/hey_client/core/auth.gen.d.ts +25 -0
- package/dist/hey_client/core/auth.gen.js +14 -0
- package/dist/hey_client/core/bodySerializer.gen.d.ts +25 -0
- package/dist/hey_client/core/bodySerializer.gen.js +57 -0
- package/dist/hey_client/core/params.gen.d.ts +43 -0
- package/dist/hey_client/core/params.gen.js +100 -0
- package/dist/hey_client/core/pathSerializer.gen.d.ts +33 -0
- package/dist/hey_client/core/pathSerializer.gen.js +106 -0
- package/dist/hey_client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/hey_client/core/queryKeySerializer.gen.js +92 -0
- package/dist/hey_client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/hey_client/core/serverSentEvents.gen.js +132 -0
- package/dist/hey_client/core/types.gen.d.ts +83 -0
- package/dist/hey_client/core/types.gen.js +2 -0
- package/dist/hey_client/core/utils.gen.d.ts +19 -0
- package/dist/hey_client/core/utils.gen.js +87 -0
- package/dist/hey_client/index.d.ts +2 -0
- package/dist/hey_client/index.js +2 -0
- package/dist/hey_client/sdk.gen.d.ts +1005 -0
- package/dist/hey_client/sdk.gen.js +1438 -0
- package/dist/hey_client/types.gen.d.ts +12992 -0
- package/dist/hey_client/types.gen.js +2 -0
- package/dist/namespaces/conversations.d.ts +2 -2
- package/dist/namespaces/files.d.ts +6 -24
- package/dist/namespaces/files.js +6 -16
- package/dist/namespaces/integrations.d.ts +2 -4
- package/dist/namespaces/integrations.js +6 -6
- package/dist/namespaces/pod-surfaces.d.ts +8 -3
- package/dist/namespaces/pod-surfaces.js +15 -6
- package/dist/namespaces/pods.d.ts +2 -3
- package/dist/namespaces/pods.js +1 -6
- package/dist/namespaces/records.d.ts +10 -16
- package/dist/namespaces/records.js +4 -33
- package/dist/namespaces/resource-access.d.ts +3 -3
- package/dist/namespaces/resource-access.js +6 -6
- package/dist/namespaces/schedules.d.ts +1 -0
- package/dist/namespaces/schedules.js +1 -1
- package/dist/namespaces/tables.d.ts +2 -2
- package/dist/namespaces/workflows.d.ts +12 -8
- package/dist/namespaces/workflows.js +9 -18
- package/dist/openapi_client/index.d.ts +23 -42
- package/dist/openapi_client/index.js +5 -11
- package/dist/openapi_client/models/AgentHarnessInfo.d.ts +2 -0
- package/dist/openapi_client/models/AgentNode.d.ts +1 -1
- package/dist/openapi_client/models/AgentNodeConfig.d.ts +1 -1
- package/dist/openapi_client/models/AgentResourcePermissionRequest.d.ts +1 -1
- package/dist/openapi_client/models/AgentResourcePermissionResponse.d.ts +1 -1
- package/dist/openapi_client/models/AgentRuntimeProfileResponse.d.ts +6 -0
- package/dist/openapi_client/models/AgentSurfaceResponse.d.ts +6 -17
- package/dist/openapi_client/models/AgentSurfaceStatus.d.ts +3 -1
- package/dist/openapi_client/models/AgentSurfaceStatus.js +2 -0
- package/dist/openapi_client/models/AgentToolset.d.ts +2 -1
- package/dist/openapi_client/models/AgentToolset.js +1 -0
- package/dist/openapi_client/models/AppTriggerResponseSchema.d.ts +2 -0
- package/dist/openapi_client/models/ApplicationSkillResponse.d.ts +6 -0
- package/dist/openapi_client/models/ApprovalDecisionResponse.d.ts +6 -0
- package/dist/openapi_client/models/AuthProvider.d.ts +4 -0
- package/dist/openapi_client/models/AuthProvider.js +9 -0
- package/dist/openapi_client/models/ConnectedAccountSummary.d.ts +7 -0
- package/dist/openapi_client/models/CreateFunctionRequest.d.ts +0 -1
- package/dist/openapi_client/models/CreateScheduleRequest.d.ts +4 -0
- package/dist/openapi_client/models/CreateSurfaceRequest.d.ts +3 -10
- package/dist/openapi_client/models/CreateUserDaemonRuntimeProfileRequest.d.ts +2 -0
- package/dist/openapi_client/models/DataStoreFlowStartInput.d.ts +1 -1
- package/dist/openapi_client/models/DataStoreFlowStartOutput.d.ts +1 -1
- package/dist/openapi_client/models/DatastoreCountResponse.d.ts +6 -0
- package/dist/openapi_client/models/DecisionNode.d.ts +2 -1
- package/dist/openapi_client/models/DecisionRule.d.ts +3 -0
- package/dist/openapi_client/models/EndNode.d.ts +1 -1
- package/dist/openapi_client/models/ExpressionInputBinding.d.ts +6 -2
- package/dist/openapi_client/models/FileListResponse.d.ts +1 -0
- package/dist/openapi_client/models/FileSearchResponse.d.ts +2 -2
- package/dist/openapi_client/models/FlowRunStatus.d.ts +5 -1
- package/dist/openapi_client/models/FlowRunStatus.js +5 -1
- package/dist/openapi_client/models/FormNode.d.ts +2 -1
- package/dist/openapi_client/models/FormNodeConfig.d.ts +1 -1
- package/dist/openapi_client/models/FunctionNode.d.ts +2 -1
- package/dist/openapi_client/models/FunctionResourcePermissionRequest.d.ts +1 -1
- package/dist/openapi_client/models/FunctionResourcePermissionResponse.d.ts +1 -1
- package/dist/openapi_client/models/InstalledAppSummary.d.ts +7 -0
- package/dist/openapi_client/models/IntegrationStatusResponse.d.ts +6 -0
- package/dist/openapi_client/models/LoopNode.d.ts +2 -1
- package/dist/openapi_client/models/LoopNodeConfig.d.ts +3 -3
- package/dist/openapi_client/models/MessageKind.d.ts +14 -0
- package/dist/openapi_client/models/MessageKind.js +19 -0
- package/dist/openapi_client/models/MessageResponse.d.ts +5 -6
- package/dist/openapi_client/models/PodMemberAddRequest.d.ts +1 -3
- package/dist/openapi_client/models/PodMemberDetailResponse.d.ts +0 -2
- package/dist/openapi_client/models/PodMemberResponse.d.ts +0 -2
- package/dist/openapi_client/models/PodMemberUpdateRoleRequest.d.ts +1 -3
- package/dist/openapi_client/models/PodRoleResourcePermissionRequest.d.ts +1 -1
- package/dist/openapi_client/models/PodRoleResourcePermissionResponse.d.ts +1 -1
- package/dist/openapi_client/models/ResourceAccessGrantResponse.d.ts +1 -1
- package/dist/openapi_client/models/ResourceAccessResponse.d.ts +1 -1
- package/dist/openapi_client/models/RuntimeProfileScope.d.ts +2 -1
- package/dist/openapi_client/models/RuntimeProfileScope.js +1 -0
- package/dist/openapi_client/models/ScheduleDetailResponse.d.ts +6 -0
- package/dist/openapi_client/models/ScheduleFireStatus.d.ts +8 -0
- package/dist/openapi_client/models/ScheduleFireStatus.js +13 -0
- package/dist/openapi_client/models/StepRecordResponse.d.ts +10 -0
- package/dist/openapi_client/models/StepStatus.d.ts +7 -0
- package/dist/openapi_client/models/StepStatus.js +12 -0
- package/dist/openapi_client/models/SurfaceBehaviorConfigInput.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceChannelRouteInput.d.ts +6 -0
- package/dist/openapi_client/models/SurfaceChannelRouteResponse.d.ts +6 -0
- package/dist/openapi_client/models/SurfaceConfigResponse.d.ts +10 -0
- package/dist/openapi_client/models/SurfaceCredentialMode.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceCredentialMode.js +9 -0
- package/dist/openapi_client/models/SurfaceIdentityConfigInput.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceIdentityConfigResponse.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceSetupStatusResponse.d.ts +10 -0
- package/dist/openapi_client/models/TableListResponse.d.ts +2 -0
- package/dist/openapi_client/models/ToggleSurfaceRequest.d.ts +1 -1
- package/dist/openapi_client/models/UpdateScheduleRequest.d.ts +1 -0
- package/dist/openapi_client/models/UpdateSurfaceChannelsRequest.d.ts +4 -0
- package/dist/openapi_client/models/UpdateSurfaceRequest.d.ts +4 -11
- package/dist/openapi_client/models/UpsertSurfaceRequest.d.ts +9 -0
- package/dist/openapi_client/models/UserProfileRequest.d.ts +1 -0
- package/dist/openapi_client/models/UserResponse.d.ts +1 -0
- package/dist/openapi_client/models/WaitUntilNode.d.ts +1 -1
- package/dist/openapi_client/models/WorkflowCreateRequest.d.ts +16 -0
- package/dist/openapi_client/models/WorkflowRunFormSubmitRequest.d.ts +13 -0
- package/dist/openapi_client/models/WorkflowRunResponse.d.ts +28 -0
- package/dist/openapi_client/models/WorkflowRunSummaryResponse.d.ts +2 -3
- package/dist/openapi_client/models/WorkflowRunWaitAssignment.d.ts +4 -4
- package/dist/openapi_client/models/{WorkflowRunWaitEntity.d.ts → WorkflowRunWaitResponse.d.ts} +4 -8
- package/dist/openapi_client/models/WorkflowRunWaitType.d.ts +1 -2
- package/dist/openapi_client/models/WorkflowRunWaitType.js +0 -1
- package/dist/openapi_client/models/WorkspaceAppAccessRequest.d.ts +0 -3
- package/dist/openapi_client/models/WorkspaceMeSandbox.d.ts +1 -4
- package/dist/openapi_client/services/AgentConversationsService.d.ts +5 -5
- package/dist/openapi_client/services/AgentConversationsService.js +3 -3
- package/dist/openapi_client/services/AgentSurfacesService.d.ts +39 -10
- package/dist/openapi_client/services/AgentSurfacesService.js +86 -20
- package/dist/openapi_client/services/ApplicationsService.d.ts +29 -19
- package/dist/openapi_client/services/ApplicationsService.js +63 -36
- package/dist/openapi_client/services/FilesService.d.ts +2 -3
- package/dist/openapi_client/services/FilesService.js +1 -1
- package/dist/openapi_client/services/FunctionsService.d.ts +1 -1
- package/dist/openapi_client/services/FunctionsService.js +1 -1
- package/dist/openapi_client/services/IntegrationsService.d.ts +12 -4
- package/dist/openapi_client/services/IntegrationsService.js +22 -4
- package/dist/openapi_client/services/PodResourceAccessService.d.ts +6 -6
- package/dist/openapi_client/services/PodResourceAccessService.js +12 -12
- package/dist/openapi_client/services/RecordsService.d.ts +22 -25
- package/dist/openapi_client/services/RecordsService.js +14 -18
- package/dist/openapi_client/services/SchedulesService.d.ts +2 -1
- package/dist/openapi_client/services/SchedulesService.js +3 -1
- package/dist/openapi_client/services/TablesService.d.ts +4 -5
- package/dist/openapi_client/services/TablesService.js +2 -2
- package/dist/openapi_client/services/WorkflowsService.d.ts +35 -26
- package/dist/openapi_client/services/WorkflowsService.js +57 -39
- package/dist/react/assistant-output.d.ts +6 -0
- package/dist/react/assistant-output.js +16 -0
- package/dist/react/useAddPodMember.js +1 -1
- package/dist/react/useAssistantController.d.ts +9 -1
- package/dist/react/useAssistantController.js +92 -251
- package/dist/react/useAssistantRuntime.js +6 -17
- package/dist/react/useAssistantSession.d.ts +5 -2
- package/dist/react/useAssistantSession.js +47 -7
- package/dist/react/useBulkRecords.d.ts +5 -5
- package/dist/react/useBulkRecords.js +5 -5
- package/dist/react/useConversationMessages.d.ts +2 -2
- package/dist/react/useConversationMessages.js +3 -5
- package/dist/react/useCreateFolder.d.ts +2 -4
- package/dist/react/useCreateFolder.js +2 -3
- package/dist/react/useCreateRecord.d.ts +2 -2
- package/dist/react/useCreateRecord.js +1 -1
- package/dist/react/useDeleteFile.d.ts +1 -4
- package/dist/react/useDeleteFile.js +3 -3
- package/dist/react/useDeleteRecord.d.ts +1 -2
- package/dist/react/useDeleteRecord.js +3 -3
- package/dist/react/useFile.d.ts +2 -4
- package/dist/react/useFile.js +3 -3
- package/dist/react/useFilePreview.d.ts +1 -4
- package/dist/react/useFilePreview.js +4 -5
- package/dist/react/useFileSearch.d.ts +5 -1
- package/dist/react/useFileSearch.js +6 -4
- package/dist/react/useFileTree.d.ts +2 -4
- package/dist/react/useFileTree.js +2 -3
- package/dist/react/useFiles.d.ts +2 -4
- package/dist/react/useFiles.js +3 -5
- package/dist/react/useFlowSession.d.ts +3 -1
- package/dist/react/useFlowSession.js +24 -17
- package/dist/react/useGlobalSearch.js +1 -1
- package/dist/react/useRecord.d.ts +2 -2
- package/dist/react/useRecord.js +1 -1
- package/dist/react/useRecordForm.d.ts +2 -2
- package/dist/react/useRecordForm.js +2 -2
- package/dist/react/useRecords.d.ts +1 -1
- package/dist/react/useRecords.js +2 -13
- package/dist/react/useReferencingRecords.d.ts +4 -6
- package/dist/react/useReferencingRecords.js +5 -5
- package/dist/react/useReverseRelatedRecords.d.ts +3 -4
- package/dist/react/useReverseRelatedRecords.js +6 -6
- package/dist/react/useUpdateFile.d.ts +2 -4
- package/dist/react/useUpdateFile.js +2 -3
- package/dist/react/useUpdateRecord.d.ts +2 -2
- package/dist/react/useUpdateRecord.js +1 -1
- package/dist/react/useUploadFile.d.ts +2 -4
- package/dist/react/useUploadFile.js +2 -3
- package/dist/react/useWorkflowResume.d.ts +1 -0
- package/dist/react/useWorkflowResume.js +10 -1
- package/dist/react/useWorkflowRun.js +1 -3
- package/dist/react/useWorkflowStart.js +11 -26
- package/dist/react/utils.js +2 -0
- package/dist/types.d.ts +15 -9
- package/package.json +7 -2
- package/dist/openapi_client/models/BillingHistoryResponse.d.ts +0 -8
- package/dist/openapi_client/models/BillingInterval.d.ts +0 -7
- package/dist/openapi_client/models/BillingInterval.js +0 -12
- package/dist/openapi_client/models/BillingInvoiceResponse.d.ts +0 -27
- package/dist/openapi_client/models/BillingInvoiceStatus.d.ts +0 -10
- package/dist/openapi_client/models/BillingInvoiceStatus.js +0 -15
- package/dist/openapi_client/models/CancelSubscriptionResponse.d.ts +0 -10
- package/dist/openapi_client/models/CreateInvoicePaymentUrlRequest.d.ts +0 -7
- package/dist/openapi_client/models/CreateInvoicePaymentUrlResponse.d.ts +0 -8
- package/dist/openapi_client/models/DatastoreMessageResponse.d.ts +0 -6
- package/dist/openapi_client/models/DeskServingConfigResponse.d.ts +0 -11
- package/dist/openapi_client/models/DeskServingConfigResponse.js +0 -8
- package/dist/openapi_client/models/FlowRunEntity.d.ts +0 -36
- package/dist/openapi_client/models/GmailSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/NotificationContent.d.ts +0 -4
- package/dist/openapi_client/models/OutlookSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/PlanListResponse.d.ts +0 -8
- package/dist/openapi_client/models/PlanResponse.d.ts +0 -18
- package/dist/openapi_client/models/PlanType.d.ts +0 -7
- package/dist/openapi_client/models/PlanType.js +0 -12
- package/dist/openapi_client/models/RecordResponse.d.ts +0 -9
- package/dist/openapi_client/models/SeatInfoResponse.d.ts +0 -10
- package/dist/openapi_client/models/SlackSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/StackFrame.d.ts +0 -11
- package/dist/openapi_client/models/StartSubscriptionRequest.d.ts +0 -14
- package/dist/openapi_client/models/StartSubscriptionResponse.d.ts +0 -9
- package/dist/openapi_client/models/StartTeamBillingRequest.d.ts +0 -6
- package/dist/openapi_client/models/StartTeamBillingRequest.js +0 -1
- package/dist/openapi_client/models/StepExecution.d.ts +0 -13
- package/dist/openapi_client/models/StepExecution.js +0 -1
- package/dist/openapi_client/models/SubscriptionResponse.d.ts +0 -22
- package/dist/openapi_client/models/SubscriptionResponse.js +0 -1
- package/dist/openapi_client/models/SubscriptionStatus.d.ts +0 -10
- package/dist/openapi_client/models/SubscriptionStatus.js +0 -15
- package/dist/openapi_client/models/SubscriptionStatusResponse.d.ts +0 -10
- package/dist/openapi_client/models/SubscriptionStatusResponse.js +0 -1
- package/dist/openapi_client/models/SubscriptionWithPlanResponse.d.ts +0 -22
- package/dist/openapi_client/models/SubscriptionWithPlanResponse.js +0 -1
- package/dist/openapi_client/models/SurfaceEventMode.d.ts +0 -6
- package/dist/openapi_client/models/SurfaceEventMode.js +0 -11
- package/dist/openapi_client/models/SurfaceMode.d.ts +0 -5
- package/dist/openapi_client/models/SurfaceMode.js +0 -10
- package/dist/openapi_client/models/SurfaceRoutingScope.d.ts +0 -4
- package/dist/openapi_client/models/SurfaceRoutingScope.js +0 -9
- package/dist/openapi_client/models/TeamsSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/TeamsSurfaceConfig.js +0 -1
- package/dist/openapi_client/models/TelegramSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/TelegramSurfaceConfig.js +0 -1
- package/dist/openapi_client/models/TextContent.d.ts +0 -4
- package/dist/openapi_client/models/TextContent.js +0 -1
- package/dist/openapi_client/models/ThinkingContent.d.ts +0 -4
- package/dist/openapi_client/models/ThinkingContent.js +0 -1
- package/dist/openapi_client/models/ToolCallContent.d.ts +0 -6
- package/dist/openapi_client/models/ToolCallContent.js +0 -1
- package/dist/openapi_client/models/ToolReturnContent.d.ts +0 -6
- package/dist/openapi_client/models/ToolReturnContent.js +0 -1
- package/dist/openapi_client/models/WhatsAppSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/WhatsAppSurfaceConfig.js +0 -1
- package/dist/openapi_client/models/WorkflowRunWaitEntity.js +0 -1
- package/dist/openapi_client/services/BillingSubscriptionsService.d.ts +0 -117
- package/dist/openapi_client/services/BillingSubscriptionsService.js +0 -230
- package/dist/openapi_client/services/BillingWebhooksService.d.ts +0 -12
- package/dist/openapi_client/services/BillingWebhooksService.js +0 -25
- package/dist/openapi_client/services/PublicDesksService.d.ts +0 -10
- package/dist/openapi_client/services/PublicDesksService.js +0 -15
- /package/dist/openapi_client/models/{BillingHistoryResponse.js → ApplicationSkillResponse.js} +0 -0
- /package/dist/openapi_client/models/{BillingInvoiceResponse.js → ApprovalDecisionResponse.js} +0 -0
- /package/dist/openapi_client/models/{CancelSubscriptionResponse.js → ConnectedAccountSummary.js} +0 -0
- /package/dist/openapi_client/models/{CreateInvoicePaymentUrlRequest.js → DatastoreCountResponse.js} +0 -0
- /package/dist/openapi_client/models/{CreateInvoicePaymentUrlResponse.js → InstalledAppSummary.js} +0 -0
- /package/dist/openapi_client/models/{DatastoreMessageResponse.js → IntegrationStatusResponse.js} +0 -0
- /package/dist/openapi_client/models/{FlowRunEntity.js → StepRecordResponse.js} +0 -0
- /package/dist/openapi_client/models/{GmailSurfaceConfig.js → SurfaceChannelRouteInput.js} +0 -0
- /package/dist/openapi_client/models/{NotificationContent.js → SurfaceChannelRouteResponse.js} +0 -0
- /package/dist/openapi_client/models/{OutlookSurfaceConfig.js → SurfaceConfigResponse.js} +0 -0
- /package/dist/openapi_client/models/{PlanListResponse.js → SurfaceIdentityConfigInput.js} +0 -0
- /package/dist/openapi_client/models/{PlanResponse.js → SurfaceIdentityConfigResponse.js} +0 -0
- /package/dist/openapi_client/models/{RecordResponse.js → SurfaceSetupStatusResponse.js} +0 -0
- /package/dist/openapi_client/models/{SeatInfoResponse.js → UpdateSurfaceChannelsRequest.js} +0 -0
- /package/dist/openapi_client/models/{SlackSurfaceConfig.js → UpsertSurfaceRequest.js} +0 -0
- /package/dist/openapi_client/models/{StackFrame.js → WorkflowRunFormSubmitRequest.js} +0 -0
- /package/dist/openapi_client/models/{StartSubscriptionRequest.js → WorkflowRunResponse.js} +0 -0
- /package/dist/openapi_client/models/{StartSubscriptionResponse.js → WorkflowRunWaitResponse.js} +0 -0
package/dist/react/useFiles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useFiles({ client, podId, enabled = true, autoLoad = true, limit = 100, pageToken, directoryPath = "/", parentId,
|
|
3
|
+
export function useFiles({ client, podId, enabled = true, autoLoad = true, limit = 100, pageToken, directoryPath = "/", parentId, }) {
|
|
4
4
|
const [files, setFiles] = useState([]);
|
|
5
5
|
const [nextPageToken, setNextPageToken] = useState(null);
|
|
6
6
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -18,7 +18,6 @@ export function useFiles({ client, podId, enabled = true, autoLoad = true, limit
|
|
|
18
18
|
pageToken: overrides.pageToken ?? pageToken,
|
|
19
19
|
directoryPath: overrides.directoryPath ?? directoryPath,
|
|
20
20
|
parentId: overrides.parentId ?? parentId,
|
|
21
|
-
namespace: overrides.namespace ?? namespace,
|
|
22
21
|
});
|
|
23
22
|
if (signal?.aborted)
|
|
24
23
|
return [];
|
|
@@ -37,7 +36,7 @@ export function useFiles({ client, podId, enabled = true, autoLoad = true, limit
|
|
|
37
36
|
if (!signal?.aborted)
|
|
38
37
|
setIsLoading(false);
|
|
39
38
|
}
|
|
40
|
-
}, [client, directoryPath, enabled, limit,
|
|
39
|
+
}, [client, directoryPath, enabled, limit, pageToken, parentId, podId]);
|
|
41
40
|
const loadMore = useCallback(async (overrides = {}) => {
|
|
42
41
|
if (!enabled || !nextPageToken || isLoading || isLoadingMore)
|
|
43
42
|
return [];
|
|
@@ -50,7 +49,6 @@ export function useFiles({ client, podId, enabled = true, autoLoad = true, limit
|
|
|
50
49
|
pageToken: nextPageToken,
|
|
51
50
|
directoryPath,
|
|
52
51
|
parentId,
|
|
53
|
-
namespace,
|
|
54
52
|
});
|
|
55
53
|
const moreFiles = response.items ?? [];
|
|
56
54
|
setFiles((previous) => [...previous, ...moreFiles]);
|
|
@@ -64,7 +62,7 @@ export function useFiles({ client, podId, enabled = true, autoLoad = true, limit
|
|
|
64
62
|
finally {
|
|
65
63
|
setIsLoadingMore(false);
|
|
66
64
|
}
|
|
67
|
-
}, [client, directoryPath, enabled, isLoading, isLoadingMore, limit,
|
|
65
|
+
}, [client, directoryPath, enabled, isLoading, isLoadingMore, limit, nextPageToken, parentId, podId]);
|
|
68
66
|
useEffect(() => {
|
|
69
67
|
if (!enabled) {
|
|
70
68
|
setFiles([]);
|
|
@@ -19,11 +19,14 @@ export interface UseFlowSessionResult {
|
|
|
19
19
|
setRunId: (runId: string | null) => void;
|
|
20
20
|
start: (options?: {
|
|
21
21
|
flowName?: string;
|
|
22
|
+
/** Submitted to the entry form when the created run waits on one. */
|
|
22
23
|
inputs?: WorkflowRunInputs;
|
|
23
24
|
connect?: boolean;
|
|
24
25
|
}) => Promise<FlowRun>;
|
|
26
|
+
/** Submit the form the run is waiting on (run.active_wait). */
|
|
25
27
|
resume: (options: {
|
|
26
28
|
runId?: string | null;
|
|
29
|
+
nodeId?: string;
|
|
27
30
|
inputs?: WorkflowRunInputs;
|
|
28
31
|
connect?: boolean;
|
|
29
32
|
}) => Promise<FlowRun>;
|
|
@@ -34,6 +37,5 @@ export interface UseFlowSessionResult {
|
|
|
34
37
|
pageToken?: string;
|
|
35
38
|
}) => Promise<WorkflowRunSummary[]>;
|
|
36
39
|
cancel: (runId?: string | null) => Promise<void>;
|
|
37
|
-
retry: (runId?: string | null) => Promise<void>;
|
|
38
40
|
}
|
|
39
41
|
export declare function useFlowSession({ client, podId, flowName, runId: initialRunId, autoPoll, pollIntervalMs, onRun, onError, }: UseFlowSessionOptions): UseFlowSessionResult;
|
|
@@ -73,7 +73,19 @@ export function useFlowSession({ client, podId, flowName, runId: initialRunId =
|
|
|
73
73
|
setError(null);
|
|
74
74
|
const scopedClient = resolvePodClient(client, resolvePodId(client, podId));
|
|
75
75
|
const name = resolveFlowName(flowName, options.flowName);
|
|
76
|
-
|
|
76
|
+
// Runs are created without inputs; when the run starts on a form and
|
|
77
|
+
// inputs were provided, submit them to that form immediately.
|
|
78
|
+
let created = await scopedClient.workflows.runs.create(name);
|
|
79
|
+
const activeWait = created.active_wait;
|
|
80
|
+
if (created.id
|
|
81
|
+
&& activeWait?.wait_type === "HUMAN"
|
|
82
|
+
&& options.inputs
|
|
83
|
+
&& Object.keys(options.inputs).length > 0) {
|
|
84
|
+
created = await scopedClient.workflows.runs.submitForm(created.id, {
|
|
85
|
+
node_id: activeWait.node_id,
|
|
86
|
+
inputs: options.inputs,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
77
89
|
setRun(created);
|
|
78
90
|
setRunIdState(created.id ?? null);
|
|
79
91
|
const nextStatus = normalizeRunStatus(created.status);
|
|
@@ -88,7 +100,16 @@ export function useFlowSession({ client, podId, flowName, runId: initialRunId =
|
|
|
88
100
|
setError(null);
|
|
89
101
|
const resolvedPodId = resolvePodId(client, podId);
|
|
90
102
|
const id = resolveRunId(runId, options.runId);
|
|
91
|
-
|
|
103
|
+
let nodeId = options.nodeId;
|
|
104
|
+
if (!nodeId) {
|
|
105
|
+
const sourceRun = run?.id === id ? run : await client.workflows.runs.get(id, resolvedPodId);
|
|
106
|
+
const wait = sourceRun?.active_wait;
|
|
107
|
+
if (!wait || wait.wait_type !== "HUMAN") {
|
|
108
|
+
throw new Error("Run is not waiting on a form; pass nodeId explicitly.");
|
|
109
|
+
}
|
|
110
|
+
nodeId = wait.node_id;
|
|
111
|
+
}
|
|
112
|
+
const resumed = await client.workflows.runs.submitForm(id, { node_id: nodeId, inputs: options.inputs ?? {} }, resolvedPodId);
|
|
92
113
|
setRun(resumed);
|
|
93
114
|
setRunIdState(resumed.id ?? id);
|
|
94
115
|
const nextStatus = normalizeRunStatus(resumed.status);
|
|
@@ -98,7 +119,7 @@ export function useFlowSession({ client, podId, flowName, runId: initialRunId =
|
|
|
98
119
|
await refresh(resumed.id ?? id);
|
|
99
120
|
}
|
|
100
121
|
return resumed;
|
|
101
|
-
}, [client, podId, refresh, runId]);
|
|
122
|
+
}, [client, podId, refresh, run, runId]);
|
|
102
123
|
const cancel = useCallback(async (explicitRunId) => {
|
|
103
124
|
try {
|
|
104
125
|
const resolvedPodId = resolvePodId(client, podId);
|
|
@@ -112,19 +133,6 @@ export function useFlowSession({ client, podId, flowName, runId: initialRunId =
|
|
|
112
133
|
onErrorRef.current?.(cancelError);
|
|
113
134
|
}
|
|
114
135
|
}, [client, podId, refresh, runId]);
|
|
115
|
-
const retry = useCallback(async (explicitRunId) => {
|
|
116
|
-
try {
|
|
117
|
-
const resolvedPodId = resolvePodId(client, podId);
|
|
118
|
-
const id = resolveRunId(runId, explicitRunId);
|
|
119
|
-
await client.workflows.runs.retry(id, resolvedPodId);
|
|
120
|
-
await refresh(id);
|
|
121
|
-
}
|
|
122
|
-
catch (retryError) {
|
|
123
|
-
const normalized = normalizeError(retryError, "Failed to retry flow run.");
|
|
124
|
-
setError(normalized);
|
|
125
|
-
onErrorRef.current?.(retryError);
|
|
126
|
-
}
|
|
127
|
-
}, [client, podId, refresh, runId]);
|
|
128
136
|
useEffect(() => {
|
|
129
137
|
if (!runId) {
|
|
130
138
|
return;
|
|
@@ -198,6 +206,5 @@ export function useFlowSession({ client, podId, flowName, runId: initialRunId =
|
|
|
198
206
|
refresh,
|
|
199
207
|
listHistory,
|
|
200
208
|
cancel,
|
|
201
|
-
retry,
|
|
202
209
|
};
|
|
203
210
|
}
|
|
@@ -92,7 +92,7 @@ export function useGlobalSearch({ client, podId, query = "", tables = [], files,
|
|
|
92
92
|
limit: stableFiles?.limit ?? 8,
|
|
93
93
|
searchMethod: stableFiles?.searchMethod,
|
|
94
94
|
});
|
|
95
|
-
const mapped = (response.
|
|
95
|
+
const mapped = (response.items ?? []).map((result) => ({
|
|
96
96
|
kind: "file",
|
|
97
97
|
sourceKey,
|
|
98
98
|
sourceLabel: stableFiles?.label ?? "Files",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
2
|
/**
|
|
3
|
-
* React hook for fetching a single record by ID.
|
|
4
|
-
*
|
|
3
|
+
* React hook for fetching a single record by ID. The record API returns the
|
|
4
|
+
* plain record object directly, so `record` is that object as-is.
|
|
5
5
|
*
|
|
6
6
|
* Perfect for detail panels — pair with `useRecords` for the list.
|
|
7
7
|
*
|
package/dist/react/useRecord.js
CHANGED
|
@@ -24,7 +24,7 @@ export function useRecord({ client, podId, tableName, recordId = null, enabled =
|
|
|
24
24
|
const response = await scopedClient.records.get(trimmedTableName, nextRecordId);
|
|
25
25
|
if (signal?.aborted)
|
|
26
26
|
return null;
|
|
27
|
-
const nextRecord = (response
|
|
27
|
+
const nextRecord = (response ?? null);
|
|
28
28
|
setRecord(nextRecord);
|
|
29
29
|
return nextRecord;
|
|
30
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
2
|
import { type RecordSchemaField } from "../record-form.js";
|
|
3
|
-
import type { FunctionRun
|
|
3
|
+
import type { FunctionRun } from "../types.js";
|
|
4
4
|
import { type UseRecordSchemaResult } from "./useRecordSchema.js";
|
|
5
5
|
/**
|
|
6
6
|
* React hook for schema-driven record forms with validation, dirty tracking,
|
|
@@ -50,7 +50,7 @@ export interface UseRecordFormOptions {
|
|
|
50
50
|
submitFunctionName?: string;
|
|
51
51
|
/** Transforms the form payload before passing it as function input. Receives the validated payload, returns the function input object. */
|
|
52
52
|
submitFunctionInput?: (payload: Record<string, unknown>) => Record<string, unknown>;
|
|
53
|
-
onSubmitSuccess?: (record: Record<string, unknown>, response:
|
|
53
|
+
onSubmitSuccess?: (record: Record<string, unknown>, response: Record<string, unknown> | FunctionRun) => void;
|
|
54
54
|
onError?: (error: unknown) => void;
|
|
55
55
|
}
|
|
56
56
|
export interface UseRecordFormResult {
|
|
@@ -64,7 +64,7 @@ export function useRecordForm({ client, podId, tableName, recordId = null, initi
|
|
|
64
64
|
try {
|
|
65
65
|
const scopedClient = resolvePodClient(client, podId);
|
|
66
66
|
const response = await scopedClient.records.get(tableName, recordId);
|
|
67
|
-
const nextRecord = response
|
|
67
|
+
const nextRecord = response ?? null;
|
|
68
68
|
setRecord(nextRecord);
|
|
69
69
|
return nextRecord;
|
|
70
70
|
}
|
|
@@ -187,7 +187,7 @@ export function useRecordForm({ client, podId, tableName, recordId = null, initi
|
|
|
187
187
|
const response = resolvedMode === "update" && recordId
|
|
188
188
|
? await scopedClient.records.update(tableName, recordId, payload.data)
|
|
189
189
|
: await scopedClient.records.create(tableName, payload.data);
|
|
190
|
-
const nextRecord = response
|
|
190
|
+
const nextRecord = response ?? null;
|
|
191
191
|
setRecord(nextRecord);
|
|
192
192
|
hydrateValues({
|
|
193
193
|
...(nextRecord ?? {}),
|
|
@@ -17,4 +17,4 @@ export interface UseRecordsResult<TRecord extends Record<string, unknown> = Reco
|
|
|
17
17
|
refresh: (overrides?: Partial<ListRecordsOptions>) => Promise<TRecord[]>;
|
|
18
18
|
loadMore: (overrides?: Partial<ListRecordsOptions>) => Promise<TRecord[]>;
|
|
19
19
|
}
|
|
20
|
-
export declare function useRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>({ client, podId, tableName, filters, sort, limit, pageToken, offset,
|
|
20
|
+
export declare function useRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>({ client, podId, tableName, filters, sort, limit, pageToken, offset, enabled, autoLoad, }: UseRecordsOptions): UseRecordsResult<TRecord>;
|
package/dist/react/useRecords.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient, stringifyComparable } from "./utils.js";
|
|
3
|
-
export function useRecords({ client, podId, tableName, filters, sort, limit = 20, pageToken, offset,
|
|
3
|
+
export function useRecords({ client, podId, tableName, filters, sort, limit = 20, pageToken, offset, enabled = true, autoLoad = true, }) {
|
|
4
4
|
const [records, setRecords] = useState([]);
|
|
5
5
|
const [total, setTotal] = useState(0);
|
|
6
6
|
const [nextPageToken, setNextPageToken] = useState(null);
|
|
@@ -11,10 +11,8 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
|
|
|
11
11
|
const isEnabled = enabled && trimmedTableName.length > 0;
|
|
12
12
|
const filtersKey = stringifyComparable(filters);
|
|
13
13
|
const sortKey = stringifyComparable(sort);
|
|
14
|
-
const paramsKey = stringifyComparable(params);
|
|
15
14
|
const stableFilters = useMemo(() => filters, [filtersKey]);
|
|
16
15
|
const stableSort = useMemo(() => sort, [sortKey]);
|
|
17
|
-
const stableParams = useMemo(() => params, [paramsKey]);
|
|
18
16
|
const refresh = useCallback(async (overrides = {}, signal) => {
|
|
19
17
|
if (!isEnabled) {
|
|
20
18
|
setRecords([]);
|
|
@@ -34,9 +32,6 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
|
|
|
34
32
|
limit: overrides.limit ?? limit,
|
|
35
33
|
pageToken: overrides.pageToken ?? pageToken,
|
|
36
34
|
offset: overrides.offset ?? offset,
|
|
37
|
-
sortBy: overrides.sortBy ?? sortBy,
|
|
38
|
-
order: overrides.order ?? order,
|
|
39
|
-
params: overrides.params ?? stableParams,
|
|
40
35
|
});
|
|
41
36
|
if (signal?.aborted)
|
|
42
37
|
return [];
|
|
@@ -62,12 +57,9 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
|
|
|
62
57
|
isEnabled,
|
|
63
58
|
limit,
|
|
64
59
|
offset,
|
|
65
|
-
order,
|
|
66
60
|
pageToken,
|
|
67
61
|
podId,
|
|
68
|
-
sortBy,
|
|
69
62
|
stableFilters,
|
|
70
|
-
stableParams,
|
|
71
63
|
stableSort,
|
|
72
64
|
trimmedTableName,
|
|
73
65
|
]);
|
|
@@ -88,9 +80,6 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
|
|
|
88
80
|
limit: overrides.limit ?? limit,
|
|
89
81
|
pageToken: overrides.pageToken ?? nextPageToken ?? undefined,
|
|
90
82
|
offset: overrides.offset ?? (nextPageToken ? undefined : (offset ?? 0) + loadedCount),
|
|
91
|
-
sortBy: overrides.sortBy ?? sortBy,
|
|
92
|
-
order: overrides.order ?? order,
|
|
93
|
-
params: overrides.params ?? stableParams,
|
|
94
83
|
});
|
|
95
84
|
const moreRecords = (response.items ?? []);
|
|
96
85
|
setRecords((previous) => [...previous, ...moreRecords]);
|
|
@@ -106,7 +95,7 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
|
|
|
106
95
|
finally {
|
|
107
96
|
setIsLoadingMore(false);
|
|
108
97
|
}
|
|
109
|
-
}, [client, isEnabled, isLoading, isLoadingMore, limit, nextPageToken, offset,
|
|
98
|
+
}, [client, isEnabled, isLoading, isLoadingMore, limit, nextPageToken, offset, podId, records.length, stableFilters, stableSort, total, trimmedTableName]);
|
|
110
99
|
useEffect(() => {
|
|
111
100
|
if (!isEnabled) {
|
|
112
101
|
setRecords([]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { Table } from "../types.js";
|
|
2
|
+
import type { RecordSort, Table } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* React hook for fetching records from a referencing table that point back
|
|
5
5
|
* to a specific record via a foreign key.
|
|
@@ -25,8 +25,7 @@ import type { Table } from "../types.js";
|
|
|
25
25
|
* table: "issue_history",
|
|
26
26
|
* foreignKey: "issue_id",
|
|
27
27
|
* recordId: selectedIssueId,
|
|
28
|
-
*
|
|
29
|
-
* order: "desc",
|
|
28
|
+
* sort: [{ field: "created_at", direction: "desc" }],
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
@@ -48,8 +47,7 @@ export interface UseReferencingRecordsOptions {
|
|
|
48
47
|
fields?: string[];
|
|
49
48
|
limit?: number;
|
|
50
49
|
offset?: number;
|
|
51
|
-
|
|
52
|
-
order?: "asc" | "desc" | string;
|
|
50
|
+
sort?: RecordSort[];
|
|
53
51
|
enabled?: boolean;
|
|
54
52
|
autoLoad?: boolean;
|
|
55
53
|
}
|
|
@@ -63,4 +61,4 @@ export interface UseReferencingRecordsResult<TRow extends Record<string, unknown
|
|
|
63
61
|
error: Error | null;
|
|
64
62
|
refresh: () => Promise<TRow[]>;
|
|
65
63
|
}
|
|
66
|
-
export declare function useReferencingRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, table, foreignKey, recordId, fields, limit, offset,
|
|
64
|
+
export declare function useReferencingRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, table, foreignKey, recordId, fields, limit, offset, sort, enabled, autoLoad, }: UseReferencingRecordsOptions): UseReferencingRecordsResult<TRow>;
|
|
@@ -25,7 +25,7 @@ function pickDefaultFields(table, foreignKey) {
|
|
|
25
25
|
});
|
|
26
26
|
return next.slice(0, 6);
|
|
27
27
|
}
|
|
28
|
-
export function useReferencingRecords({ client, podId, table, foreignKey, recordId = null, fields, limit = 20, offset,
|
|
28
|
+
export function useReferencingRecords({ client, podId, table, foreignKey, recordId = null, fields, limit = 20, offset, sort, enabled = true, autoLoad = true, }) {
|
|
29
29
|
const [referencedTable, setReferencedTable] = useState(null);
|
|
30
30
|
const [columns, setColumns] = useState([]);
|
|
31
31
|
const [records, setRecords] = useState([]);
|
|
@@ -36,7 +36,9 @@ export function useReferencingRecords({ client, podId, table, foreignKey, record
|
|
|
36
36
|
const trimmedTable = table.trim();
|
|
37
37
|
const trimmedRecordId = typeof recordId === "string" ? recordId.trim() : "";
|
|
38
38
|
const fieldsKey = stringifyComparable(fields);
|
|
39
|
+
const sortKey = stringifyComparable(sort);
|
|
39
40
|
const stableFields = useMemo(() => fields, [fieldsKey]);
|
|
41
|
+
const stableSort = useMemo(() => sort, [sortKey]);
|
|
40
42
|
const isEnabled = enabled && trimmedTable.length > 0 && trimmedRecordId.length > 0;
|
|
41
43
|
const refresh = useCallback(async (signal) => {
|
|
42
44
|
if (!isEnabled) {
|
|
@@ -67,8 +69,7 @@ export function useReferencingRecords({ client, podId, table, foreignKey, record
|
|
|
67
69
|
}],
|
|
68
70
|
limit,
|
|
69
71
|
offset,
|
|
70
|
-
|
|
71
|
-
order,
|
|
72
|
+
sort: stableSort,
|
|
72
73
|
});
|
|
73
74
|
if (signal?.aborted)
|
|
74
75
|
return [];
|
|
@@ -100,10 +101,9 @@ export function useReferencingRecords({ client, podId, table, foreignKey, record
|
|
|
100
101
|
isEnabled,
|
|
101
102
|
limit,
|
|
102
103
|
offset,
|
|
103
|
-
order,
|
|
104
104
|
podId,
|
|
105
|
-
sortBy,
|
|
106
105
|
stableFields,
|
|
106
|
+
stableSort,
|
|
107
107
|
trimmedRecordId,
|
|
108
108
|
trimmedTable,
|
|
109
109
|
]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { Table } from "../types.js";
|
|
2
|
+
import type { RecordSort, Table } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* React hook for finding records in *other* tables that reference a given
|
|
5
5
|
* record. Starts from the parent table, discovers all tables with FK
|
|
@@ -45,8 +45,7 @@ export interface UseReverseRelatedRecordsOptions {
|
|
|
45
45
|
fields?: string[];
|
|
46
46
|
limit?: number;
|
|
47
47
|
offset?: number;
|
|
48
|
-
|
|
49
|
-
order?: "asc" | "desc" | string;
|
|
48
|
+
sort?: RecordSort[];
|
|
50
49
|
tablesLimit?: number;
|
|
51
50
|
enabled?: boolean;
|
|
52
51
|
autoLoad?: boolean;
|
|
@@ -65,4 +64,4 @@ export interface UseReverseRelatedRecordsResult<TRow extends Record<string, unkn
|
|
|
65
64
|
error: Error | null;
|
|
66
65
|
refresh: () => Promise<TRow[]>;
|
|
67
66
|
}
|
|
68
|
-
export declare function useReverseRelatedRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, tableName, recordId, relation, fields, limit, offset,
|
|
67
|
+
export declare function useReverseRelatedRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, tableName, recordId, relation, fields, limit, offset, sort, tablesLimit, enabled, autoLoad, }: UseReverseRelatedRecordsOptions): UseReverseRelatedRecordsResult<TRow>;
|
|
@@ -26,7 +26,7 @@ function pickDefaultFields(table, foreignKey) {
|
|
|
26
26
|
});
|
|
27
27
|
return next.slice(0, 6);
|
|
28
28
|
}
|
|
29
|
-
export function useReverseRelatedRecords({ client, podId, tableName, recordId = null, relation = null, fields, limit = 20, offset,
|
|
29
|
+
export function useReverseRelatedRecords({ client, podId, tableName, recordId = null, relation = null, fields, limit = 20, offset, sort, tablesLimit = 100, enabled = true, autoLoad = true, }) {
|
|
30
30
|
const [parentTable, setParentTable] = useState(null);
|
|
31
31
|
const [relatedTable, setRelatedTable] = useState(null);
|
|
32
32
|
const [parentRecord, setParentRecord] = useState(null);
|
|
@@ -42,8 +42,10 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
|
|
|
42
42
|
const trimmedRecordId = typeof recordId === "string" ? recordId.trim() : "";
|
|
43
43
|
const relationKey = stringifyComparable(relation);
|
|
44
44
|
const fieldsKey = stringifyComparable(fields);
|
|
45
|
+
const sortKey = stringifyComparable(sort);
|
|
45
46
|
const stableRelation = useMemo(() => relation, [relationKey]);
|
|
46
47
|
const stableFields = useMemo(() => fields, [fieldsKey]);
|
|
48
|
+
const stableSort = useMemo(() => sort, [sortKey]);
|
|
47
49
|
const isEnabled = enabled && trimmedTableName.length > 0 && trimmedRecordId.length > 0;
|
|
48
50
|
const refresh = useCallback(async (signal) => {
|
|
49
51
|
if (!isEnabled) {
|
|
@@ -73,7 +75,7 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
|
|
|
73
75
|
const listedTables = tablesResponse.items ?? [];
|
|
74
76
|
const nextParentTable = listedTables.find((tableEntry) => tableEntry.name === trimmedTableName)
|
|
75
77
|
?? await scopedClient.tables.get(trimmedTableName);
|
|
76
|
-
const nextParentRecord = parentRecordResponse
|
|
78
|
+
const nextParentRecord = parentRecordResponse ?? null;
|
|
77
79
|
if (signal?.aborted)
|
|
78
80
|
return [];
|
|
79
81
|
setParentTable(nextParentTable);
|
|
@@ -130,8 +132,7 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
|
|
|
130
132
|
}],
|
|
131
133
|
limit,
|
|
132
134
|
offset,
|
|
133
|
-
|
|
134
|
-
order,
|
|
135
|
+
sort: stableSort,
|
|
135
136
|
});
|
|
136
137
|
if (signal?.aborted)
|
|
137
138
|
return [];
|
|
@@ -162,11 +163,10 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
|
|
|
162
163
|
isEnabled,
|
|
163
164
|
limit,
|
|
164
165
|
offset,
|
|
165
|
-
order,
|
|
166
166
|
podId,
|
|
167
|
-
sortBy,
|
|
168
167
|
stableFields,
|
|
169
168
|
stableRelation,
|
|
169
|
+
stableSort,
|
|
170
170
|
tablesLimit,
|
|
171
171
|
trimmedRecordId,
|
|
172
172
|
trimmedTableName,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FileResponse } from "../types.js";
|
|
3
3
|
export interface UpdateFileInput {
|
|
4
4
|
file?: Blob;
|
|
5
5
|
name?: string;
|
|
@@ -8,13 +8,11 @@ export interface UpdateFileInput {
|
|
|
8
8
|
parentId?: string;
|
|
9
9
|
newPath?: string;
|
|
10
10
|
searchEnabled?: boolean;
|
|
11
|
-
namespace?: DatastoreFileNamespace | null;
|
|
12
11
|
}
|
|
13
12
|
export interface UseUpdateFileOptions {
|
|
14
13
|
client: LemmaClient;
|
|
15
14
|
podId?: string;
|
|
16
15
|
path?: string | null;
|
|
17
|
-
namespace?: DatastoreFileNamespace | null;
|
|
18
16
|
enabled?: boolean;
|
|
19
17
|
onSuccess?: (file: FileResponse) => void;
|
|
20
18
|
onError?: (error: unknown) => void;
|
|
@@ -28,4 +26,4 @@ export interface UseUpdateFileResult<TFile extends FileResponse = FileResponse>
|
|
|
28
26
|
}) => Promise<TFile | null>;
|
|
29
27
|
reset: () => void;
|
|
30
28
|
}
|
|
31
|
-
export declare function useUpdateFile<TFile extends FileResponse = FileResponse>({ client, podId, path,
|
|
29
|
+
export declare function useUpdateFile<TFile extends FileResponse = FileResponse>({ client, podId, path, enabled, onSuccess, onError, }: UseUpdateFileOptions): UseUpdateFileResult<TFile>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useUpdateFile({ client, podId, path = null,
|
|
3
|
+
export function useUpdateFile({ client, podId, path = null, enabled = true, onSuccess, onError, }) {
|
|
4
4
|
const [updatedFile, setUpdatedFile] = useState(null);
|
|
5
5
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -23,7 +23,6 @@ export function useUpdateFile({ client, podId, path = null, namespace, enabled =
|
|
|
23
23
|
const scopedClient = resolvePodClient(client, podId);
|
|
24
24
|
const nextFile = await scopedClient.files.update(nextPath, {
|
|
25
25
|
...input,
|
|
26
|
-
namespace: input.namespace ?? namespace,
|
|
27
26
|
});
|
|
28
27
|
setUpdatedFile(nextFile);
|
|
29
28
|
onSuccessRef.current?.(nextFile);
|
|
@@ -38,7 +37,7 @@ export function useUpdateFile({ client, podId, path = null, namespace, enabled =
|
|
|
38
37
|
finally {
|
|
39
38
|
setIsSubmitting(false);
|
|
40
39
|
}
|
|
41
|
-
}, [client, isEnabled,
|
|
40
|
+
}, [client, isEnabled, podId, trimmedPath]);
|
|
42
41
|
const reset = useCallback(() => {
|
|
43
42
|
setUpdatedFile(null);
|
|
44
43
|
setError(null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { FunctionRun
|
|
2
|
+
import type { FunctionRun } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* React hook for updating a single record. Manages loading/error state and
|
|
5
5
|
* exposes an `update` function you can call from event handlers.
|
|
@@ -37,7 +37,7 @@ export interface UseUpdateRecordOptions {
|
|
|
37
37
|
updateVia?: "direct" | "function";
|
|
38
38
|
/** Function name to run when `updateVia` is `"function"`. Falls back to `tableName` if omitted. */
|
|
39
39
|
updateFunctionName?: string;
|
|
40
|
-
onSuccess?: (record: Record<string, unknown>, response:
|
|
40
|
+
onSuccess?: (record: Record<string, unknown>, response: Record<string, unknown> | FunctionRun) => void;
|
|
41
41
|
onError?: (error: unknown) => void;
|
|
42
42
|
}
|
|
43
43
|
export interface UseUpdateRecordResult<TRecord extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -34,7 +34,7 @@ export function useUpdateRecord({ client, podId, tableName, recordId = null, ena
|
|
|
34
34
|
return nextRecord;
|
|
35
35
|
}
|
|
36
36
|
const response = await scopedClient.records.update(trimmedTableName, nextRecordId, data);
|
|
37
|
-
const nextRecord = (response
|
|
37
|
+
const nextRecord = (response ?? null);
|
|
38
38
|
setUpdatedRecord(nextRecord);
|
|
39
39
|
if (nextRecord) {
|
|
40
40
|
onSuccessRef.current?.(nextRecord, response);
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FileResponse } from "../types.js";
|
|
3
3
|
export interface UploadFileInput {
|
|
4
4
|
name?: string;
|
|
5
5
|
directoryPath?: string;
|
|
6
6
|
parentId?: string;
|
|
7
7
|
searchEnabled?: boolean;
|
|
8
8
|
description?: string;
|
|
9
|
-
namespace?: DatastoreFileNamespace | null;
|
|
10
9
|
}
|
|
11
10
|
export interface UseUploadFileOptions {
|
|
12
11
|
client: LemmaClient;
|
|
13
12
|
podId?: string;
|
|
14
|
-
namespace?: DatastoreFileNamespace | null;
|
|
15
13
|
enabled?: boolean;
|
|
16
14
|
onSuccess?: (file: FileResponse) => void;
|
|
17
15
|
onError?: (error: unknown) => void;
|
|
@@ -23,4 +21,4 @@ export interface UseUploadFileResult<TFile extends FileResponse = FileResponse>
|
|
|
23
21
|
upload: (file: Blob, options?: UploadFileInput) => Promise<TFile | null>;
|
|
24
22
|
reset: () => void;
|
|
25
23
|
}
|
|
26
|
-
export declare function useUploadFile<TFile extends FileResponse = FileResponse>({ client, podId,
|
|
24
|
+
export declare function useUploadFile<TFile extends FileResponse = FileResponse>({ client, podId, enabled, onSuccess, onError, }: UseUploadFileOptions): UseUploadFileResult<TFile>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useUploadFile({ client, podId,
|
|
3
|
+
export function useUploadFile({ client, podId, enabled = true, onSuccess, onError, }) {
|
|
4
4
|
const [uploadedFile, setUploadedFile] = useState(null);
|
|
5
5
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -18,7 +18,6 @@ export function useUploadFile({ client, podId, namespace, enabled = true, onSucc
|
|
|
18
18
|
const scopedClient = resolvePodClient(client, podId);
|
|
19
19
|
const nextFile = await scopedClient.files.upload(file, {
|
|
20
20
|
...options,
|
|
21
|
-
namespace: options.namespace ?? namespace,
|
|
22
21
|
});
|
|
23
22
|
setUploadedFile(nextFile);
|
|
24
23
|
onSuccessRef.current?.(nextFile);
|
|
@@ -33,7 +32,7 @@ export function useUploadFile({ client, podId, namespace, enabled = true, onSucc
|
|
|
33
32
|
finally {
|
|
34
33
|
setIsSubmitting(false);
|
|
35
34
|
}
|
|
36
|
-
}, [client, enabled,
|
|
35
|
+
}, [client, enabled, podId]);
|
|
37
36
|
const reset = useCallback(() => {
|
|
38
37
|
setUploadedFile(null);
|
|
39
38
|
setError(null);
|
|
@@ -13,6 +13,7 @@ export interface UseWorkflowResumeResult {
|
|
|
13
13
|
error: Error | null;
|
|
14
14
|
resume: (inputs?: WorkflowRunInputs, options?: {
|
|
15
15
|
runId?: string | null;
|
|
16
|
+
nodeId?: string;
|
|
16
17
|
}) => Promise<FlowRun>;
|
|
17
18
|
}
|
|
18
19
|
export declare function useWorkflowResume({ client, podId, runId, onRun, onError, }: UseWorkflowResumeOptions): UseWorkflowResumeResult;
|
|
@@ -21,7 +21,16 @@ export function useWorkflowResume({ client, podId, runId, onRun, onError, }) {
|
|
|
21
21
|
try {
|
|
22
22
|
const resolvedPodId = resolvePodId(client, podId);
|
|
23
23
|
const resolvedRunId = resolveRunId(runId, options.runId);
|
|
24
|
-
|
|
24
|
+
let nodeId = options.nodeId;
|
|
25
|
+
if (!nodeId) {
|
|
26
|
+
const current = await client.workflows.runs.get(resolvedRunId, resolvedPodId);
|
|
27
|
+
const wait = current.active_wait;
|
|
28
|
+
if (!wait || wait.wait_type !== "HUMAN") {
|
|
29
|
+
throw new Error("Run is not waiting on a form; pass nodeId explicitly.");
|
|
30
|
+
}
|
|
31
|
+
nodeId = wait.node_id;
|
|
32
|
+
}
|
|
33
|
+
const nextRun = await client.workflows.runs.submitForm(resolvedRunId, { node_id: nodeId, inputs }, resolvedPodId);
|
|
25
34
|
setRun(nextRun);
|
|
26
35
|
onRunRef.current?.(nextRun);
|
|
27
36
|
return nextRun;
|
|
@@ -31,9 +31,7 @@ export function useWorkflowRun({ workflowName, ...options }) {
|
|
|
31
31
|
const normalizedStatus = normalizeRunStatus(session.status);
|
|
32
32
|
const isFinished = isTerminalFlowStatus(normalizedStatus);
|
|
33
33
|
const isWaitingForInput = normalizedStatus === "WAITING"
|
|
34
|
-
|
|
35
|
-
|| !!session.run?.waiting_function_run_id
|
|
36
|
-
|| !!session.run?.waiting_timer_id;
|
|
34
|
+
&& session.run?.active_wait?.wait_type === "HUMAN";
|
|
37
35
|
const output = session.run?.execution_context ?? null;
|
|
38
36
|
const finalOutput = isFinished ? output : null;
|
|
39
37
|
return {
|
|
@@ -16,14 +16,11 @@ function findFirstFormNode(workflow) {
|
|
|
16
16
|
}
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function isWaitingOnForm(run) {
|
|
20
20
|
if (!run)
|
|
21
21
|
return false;
|
|
22
22
|
const normalizedStatus = normalizeRunStatus(run.status);
|
|
23
|
-
return normalizedStatus === "WAITING"
|
|
24
|
-
|| !!run.waiting_function_run_id
|
|
25
|
-
|| !!run.waiting_agent_conversation_id
|
|
26
|
-
|| !!run.waiting_timer_id;
|
|
23
|
+
return normalizedStatus === "WAITING" && run.active_wait?.wait_type === "HUMAN";
|
|
27
24
|
}
|
|
28
25
|
export function useWorkflowStart({ client, podId, workflowName, runId = null, enabled = true, autoLoad = true, autoPoll = true, pollIntervalMs = 2000, onRun, onError, }) {
|
|
29
26
|
const [workflow, setWorkflow] = useState(null);
|
|
@@ -93,30 +90,18 @@ export function useWorkflowStart({ client, podId, workflowName, runId = null, en
|
|
|
93
90
|
setIsStarting(true);
|
|
94
91
|
setWorkflowError(null);
|
|
95
92
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const startType = currentWorkflow?.start?.type ?? "MANUAL";
|
|
100
|
-
if (startType === "MANUAL") {
|
|
101
|
-
const created = await session.start({
|
|
102
|
-
flowName: workflowName,
|
|
103
|
-
inputs: {},
|
|
104
|
-
});
|
|
105
|
-
const shouldResume = !!created.id && (options.forceResume === true
|
|
106
|
-
|| Object.keys(inputs).length > 0
|
|
107
|
-
|| isWaitingFlowRun(created));
|
|
108
|
-
if (!shouldResume || !created.id) {
|
|
109
|
-
return created;
|
|
110
|
-
}
|
|
111
|
-
return session.resume({
|
|
112
|
-
runId: created.id,
|
|
113
|
-
inputs,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
return session.start({
|
|
93
|
+
// Runs take no start inputs; session.start submits `inputs` to the
|
|
94
|
+
// entry form when the created run waits on one.
|
|
95
|
+
const created = await session.start({
|
|
117
96
|
flowName: workflowName,
|
|
118
97
|
inputs,
|
|
119
98
|
});
|
|
99
|
+
if (options.forceResume === true
|
|
100
|
+
&& created.id
|
|
101
|
+
&& isWaitingOnForm(created)) {
|
|
102
|
+
return session.resume({ runId: created.id, inputs });
|
|
103
|
+
}
|
|
104
|
+
return created;
|
|
120
105
|
}
|
|
121
106
|
catch (startError) {
|
|
122
107
|
const normalized = normalizeError(startError, "Failed to start workflow.");
|