@datalayer/core 1.1.60 → 1.1.66
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 +2 -2
- package/lib/api/DatalayerApi.d.ts +42 -1
- package/lib/api/DatalayerApi.js +90 -3
- package/lib/api/constants.d.ts +18 -0
- package/lib/api/constants.js +18 -0
- package/lib/api/contents/attachments.d.ts +9 -0
- package/lib/api/contents/attachments.js +43 -0
- package/lib/api/contents/bridges.d.ts +22 -0
- package/lib/api/contents/bridges.js +79 -0
- package/lib/api/contents/capabilities.d.ts +11 -0
- package/lib/api/contents/capabilities.js +21 -0
- package/lib/api/contents/cloudStorage.d.ts +31 -0
- package/lib/api/contents/cloudStorage.js +89 -0
- package/lib/api/contents/dataservers.d.ts +37 -0
- package/lib/api/contents/dataservers.js +121 -0
- package/lib/api/contents/datasets.d.ts +15 -0
- package/lib/api/contents/datasets.js +45 -0
- package/lib/api/contents/datasources.d.ts +70 -0
- package/lib/api/contents/datasources.js +149 -0
- package/lib/api/contents/generated.d.ts +1070 -0
- package/lib/api/contents/index.d.ts +16 -0
- package/lib/api/contents/index.js +20 -0
- package/lib/api/contents/mcp.d.ts +46 -0
- package/lib/api/contents/mcp.js +157 -0
- package/lib/api/contents/objects.d.ts +31 -0
- package/lib/api/contents/objects.js +88 -0
- package/lib/api/contents/operations.d.ts +3 -0
- package/lib/api/contents/operations.js +19 -0
- package/lib/api/contents/runtimeMounts.d.ts +40 -0
- package/lib/api/contents/runtimeMounts.js +59 -0
- package/lib/api/contents/sandboxUid.d.ts +53 -0
- package/lib/api/contents/sandboxUid.js +78 -0
- package/lib/api/contents/sources.d.ts +19 -0
- package/lib/api/contents/sources.js +119 -0
- package/lib/api/contents/sync.d.ts +18 -0
- package/lib/api/contents/sync.js +69 -0
- package/lib/api/contents/transfers.d.ts +38 -0
- package/lib/api/contents/transfers.js +123 -0
- package/lib/api/iam/connectedAgents.d.ts +39 -0
- package/lib/api/iam/connectedAgents.js +52 -0
- package/lib/api/iam/index.d.ts +2 -1
- package/lib/api/iam/index.js +2 -1
- package/lib/api/iam/mcpAlertRules.d.ts +51 -0
- package/lib/api/iam/mcpAlertRules.js +198 -0
- package/lib/api/iam/mcpAuditSettings.d.ts +46 -0
- package/lib/api/iam/mcpAuditSettings.js +120 -0
- package/lib/api/iam/mcpPolicy.d.ts +80 -0
- package/lib/api/iam/mcpPolicy.js +132 -0
- package/lib/api/iam/organizationTeams.d.ts +13 -0
- package/lib/api/iam/organizationTeams.js +43 -0
- package/lib/api/iam/serviceAgents.d.ts +68 -0
- package/lib/api/iam/serviceAgents.js +119 -0
- package/lib/api/index.d.ts +4 -1
- package/lib/api/index.js +3 -1
- package/lib/api/mcp/activity.d.ts +37 -0
- package/lib/api/mcp/activity.js +26 -0
- package/lib/api/mcp/alerts.d.ts +25 -0
- package/lib/api/mcp/alerts.js +51 -0
- package/lib/api/mcp/audit.d.ts +29 -0
- package/lib/api/mcp/audit.js +55 -0
- package/lib/api/mcp/bindings.d.ts +18 -0
- package/lib/api/mcp/bindings.js +42 -0
- package/lib/api/mcp/forwarding.d.ts +25 -0
- package/lib/api/mcp/forwarding.js +46 -0
- package/lib/api/mcp/gateway.d.ts +16 -0
- package/lib/api/mcp/gateway.js +70 -0
- package/lib/api/mcp/generated.d.ts +22 -0
- package/lib/api/mcp/generated.js +213 -0
- package/lib/api/mcp/index.d.ts +17 -0
- package/lib/api/mcp/index.js +25 -0
- package/lib/api/mcp/observability.d.ts +125 -0
- package/lib/api/mcp/observability.js +254 -0
- package/lib/api/mcp/operations.d.ts +83 -0
- package/lib/api/mcp/operations.js +50 -0
- package/lib/api/mcp/organizations.d.ts +102 -0
- package/lib/api/mcp/organizations.js +46 -0
- package/lib/api/mcp/policy.d.ts +9 -0
- package/lib/api/mcp/policy.js +23 -0
- package/lib/api/mcp/tasks.d.ts +49 -0
- package/lib/api/mcp/tasks.js +147 -0
- package/lib/api/utils/validation.d.ts +1 -1
- package/lib/api/utils/validation.js +1 -1
- package/lib/client/auth/index.js +0 -5
- package/lib/client/auth/storage.js +0 -5
- package/lib/client/auth/strategies.js +0 -5
- package/lib/client/base.d.ts +6 -0
- package/lib/client/base.js +8 -0
- package/lib/client/index.d.ts +0 -10
- package/lib/client/index.js +2 -2
- package/lib/client/mixins/ContentsMixin.d.ts +71 -0
- package/lib/client/mixins/ContentsMixin.js +157 -0
- package/lib/client/mixins/IAMMixin.d.ts +0 -31
- package/lib/client/mixins/IAMMixin.js +0 -58
- package/lib/components/animation/AnimatedText.d.ts +1 -0
- package/lib/components/animation/AnimatedText.js +0 -4
- package/lib/components/auth/SigInAPIKey.d.ts +1 -0
- package/lib/components/auth/SigInAPIKey.js +0 -6
- package/lib/components/auth/SignIn.d.ts +1 -0
- package/lib/components/auth/SignIn.js +0 -4
- package/lib/components/auth/SignIn.stories.d.ts +2 -2
- package/lib/components/avatars/BoringAvatar.d.ts +1 -1
- package/lib/components/avatars/BoringAvatar.stories.d.ts +1 -1
- package/lib/components/avatars/DLAvatar.d.ts +1 -1
- package/lib/components/avatars/DLAvatar.js +0 -4
- package/lib/components/avatars/UserAvatar.d.ts +9 -0
- package/lib/components/avatars/UserAvatar.js +0 -12
- package/lib/components/avatars/UserProfileAvatar.d.ts +1 -1
- package/lib/components/banners/NoAutomationBanner.d.ts +1 -1
- package/lib/components/billing/BillingEntitySelect.d.ts +10 -0
- package/lib/components/billing/BillingEntitySelect.js +0 -17
- package/lib/components/billing/index.js +0 -4
- package/lib/components/buttons/DownloadCSVButton.d.ts +1 -1
- package/lib/components/buttons/DownloadJsonButton.d.ts +1 -1
- package/lib/components/buttons/LongActionButton.d.ts +1 -0
- package/lib/components/buttons/LongActionButton.js +0 -4
- package/lib/components/buttons/UploadButton.d.ts +1 -0
- package/lib/components/buttons/UploadButton.js +0 -4
- package/lib/components/checkout/StripeCheckout.d.ts +1 -1
- package/lib/components/collaboration/LiveEditorCollaborators.d.ts +31 -0
- package/lib/components/collaboration/LiveEditorCollaborators.js +86 -53
- package/lib/components/collaboration/index.js +0 -4
- package/lib/components/confetti/ConfettiSuccess.d.ts +1 -1
- package/lib/components/contents/ContentSourceCard.d.ts +8 -0
- package/lib/components/contents/ContentSourceCard.js +23 -0
- package/lib/components/contents/HomeFolderObjectsBrowser.d.ts +10 -0
- package/lib/components/contents/HomeFolderObjectsBrowser.js +148 -0
- package/lib/components/contents/index.d.ts +2 -0
- package/lib/components/contents/index.js +6 -0
- package/lib/components/context/OrganizationSelect.d.ts +1 -1
- package/lib/components/display/AvatarSkeleton.d.ts +1 -1
- package/lib/components/display/BusyDots.d.ts +1 -1
- package/lib/components/display/CenteredSpinner.d.ts +1 -1
- package/lib/components/display/CodePreview.d.ts +1 -1
- package/lib/components/display/DatalayerBox.d.ts +7 -2
- package/lib/components/display/DatalayerBox.js +6 -6
- package/lib/components/display/HorizontalCenter.d.ts +1 -1
- package/lib/components/display/JupyterDialog.d.ts +1 -0
- package/lib/components/display/JupyterDialog.js +1 -7
- package/lib/components/display/Markdown.d.ts +1 -0
- package/lib/components/display/NotebookSkeleton.d.ts +1 -1
- package/lib/components/display/Placeholder.d.ts +1 -1
- package/lib/components/display/ToTopBranded.d.ts +1 -1
- package/lib/components/echarts/EChartsReact.d.ts +1 -1
- package/lib/components/flashes/FlashClosable.d.ts +1 -0
- package/lib/components/flashes/FlashClosable.js +0 -4
- package/lib/components/flashes/FlashGuest.d.ts +1 -1
- package/lib/components/flashes/FlashSurveys.d.ts +1 -1
- package/lib/components/flashes/FlashUnauthorized.d.ts +1 -0
- package/lib/components/flashes/FlashUnauthorized.js +0 -6
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +1 -1
- package/lib/components/iam/ExternalTokenSilentLogin.d.ts +1 -1
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +2 -0
- package/lib/components/labels/StatusLabels.d.ts +1 -0
- package/lib/components/labels/VisibilityLabel.d.ts +1 -1
- package/lib/components/landings/StepBlock.d.ts +1 -1
- package/lib/components/mcp/ClientBadge.d.ts +41 -0
- package/lib/components/mcp/ClientBadge.js +33 -0
- package/lib/components/mcp/McpErrorBlankslate.d.ts +21 -0
- package/lib/components/mcp/McpErrorBlankslate.js +17 -0
- package/lib/components/mcp/ScopeList.d.ts +28 -0
- package/lib/components/mcp/ScopeList.js +14 -0
- package/lib/components/mcp/index.d.ts +10 -0
- package/lib/components/mcp/index.js +18 -0
- package/lib/components/navbar/NavigationVisbilityObserver.d.ts +2 -1
- package/lib/components/navbar/SubdomainNavBar.d.ts +10 -5
- package/lib/components/navbar/SubdomainNavBar.js +2 -1
- package/lib/components/notebooks/JupyterNotebook.d.ts +1 -1
- package/lib/components/notebooks/JupyterNotebookToolbar.d.ts +1 -1
- package/lib/components/principal/PrincipalAppearance.d.ts +1 -0
- package/lib/components/principal/PrincipalAppearance.js +0 -8
- package/lib/components/principal/PrincipalAvatar.d.ts +1 -0
- package/lib/components/principal/PrincipalAvatar.js +17 -9
- package/lib/components/principal/PrincipalBadge.d.ts +1 -1
- package/lib/components/principal/PrincipalBanner.d.ts +1 -1
- package/lib/components/principal/PrincipalDetailsOverlay.d.ts +31 -1
- package/lib/components/principal/PrincipalDetailsOverlay.js +64 -33
- package/lib/components/principal/PrincipalHoverCard.d.ts +31 -0
- package/lib/components/principal/PrincipalHoverCard.js +52 -0
- package/lib/components/principal/PrincipalSwitcherMenu.d.ts +1 -0
- package/lib/components/principal/PrincipalSwitcherMenu.js +5 -14
- package/lib/components/principal/index.d.ts +2 -1
- package/lib/components/principal/index.js +2 -1
- package/lib/components/progress/ConsumptionBar.d.ts +1 -0
- package/lib/components/progress/ConsumptionBar.js +0 -4
- package/lib/components/progress/ProgressRing.d.ts +1 -0
- package/lib/components/progress/SpinnerBar.d.ts +1 -1
- package/lib/components/progress/Timer.d.ts +1 -0
- package/lib/components/progress/Timer.js +0 -4
- package/lib/components/screencapture/ScreencaptureButton.d.ts +1 -1
- package/lib/components/sharing/ShareAccessComponent.d.ts +15 -1
- package/lib/components/sharing/ShareAccessComponent.js +36 -23
- package/lib/components/sharing/SharingEditor.d.ts +17 -0
- package/lib/components/sharing/SharingEditor.js +0 -24
- package/lib/components/sparklines/Sparklines.js +3 -4
- package/lib/components/sparklines/index.js +0 -4
- package/lib/components/storage/ContentsBrowser.d.ts +25 -1
- package/lib/components/storage/ContentsBrowser.js +145 -52
- package/lib/components/storage/ContentsBrowserMock.d.ts +3 -0
- package/lib/components/storage/ContentsBrowserMock.js +75 -0
- package/lib/components/storage/ContentsItems.d.ts +2 -1
- package/lib/components/storage/ContentsItems.js +0 -4
- package/lib/components/storage/ContentsTable.d.ts +50 -0
- package/lib/components/storage/ContentsTable.js +134 -0
- package/lib/components/storage/HomeFolderDrive.d.ts +71 -0
- package/lib/components/storage/HomeFolderDrive.js +248 -0
- package/lib/components/storage/index.d.ts +2 -0
- package/lib/components/storage/index.js +2 -0
- package/lib/components/students/StudentItemStatus.d.ts +1 -1
- package/lib/components/students/StudentResultCircle.d.ts +1 -1
- package/lib/components/subnav/SubNav.d.ts +5 -5
- package/lib/components/subnav/SubNav.js +11 -9
- package/lib/components/tables/DataTable.d.ts +1 -1
- package/lib/components/text-reveal/TextRevealAnimation.d.ts +2 -2
- package/lib/components/text-reveal/useTextRevealAnimationLines.d.ts +1 -1
- package/lib/components/time/LiveRelativeTime.d.ts +1 -0
- package/lib/components/time/LiveRelativeTime.js +0 -8
- package/lib/components/time/index.js +0 -4
- package/lib/components/timeline/Timeline.d.ts +1 -1
- package/lib/components/timeline/index.js +0 -4
- package/lib/components/users/PeerIndicator.d.ts +1 -0
- package/lib/components/users/PeerIndicator.js +0 -4
- package/lib/config/Configuration.d.ts +15 -17
- package/lib/config/Configuration.js +7 -0
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/layouts/LayoutBackdrop.d.ts +1 -1
- package/lib/hooks/layouts/LayoutScreencapture.d.ts +1 -1
- package/lib/hooks/useBackdrop.d.ts +1 -1
- package/lib/hooks/useBackdropJupyterLab.d.ts +3 -2
- package/lib/hooks/useBackdropJupyterLab.js +0 -4
- package/lib/hooks/useCache.d.ts +310 -105
- package/lib/hooks/useCache.js +142 -355
- package/lib/hooks/useContainsFocus.d.ts +1 -1
- package/lib/hooks/useContents.d.ts +313 -0
- package/lib/hooks/useContents.js +964 -0
- package/lib/hooks/useFocusTrap.d.ts +4 -4
- package/lib/hooks/useFocusTrap.js +1 -1
- package/lib/hooks/useMcp.d.ts +229 -0
- package/lib/hooks/useMcp.js +656 -0
- package/lib/hooks/useMobile.js +0 -5
- package/lib/hooks/useProjectStore.d.ts +3 -3
- package/lib/hooks/useProjectStore.js +4 -4
- package/lib/hooks/useRef.d.ts +1 -1
- package/lib/hooks/useRef.js +3 -0
- package/lib/hooks/useScreencapture.d.ts +2 -1
- package/lib/hooks/useScreencapture.js +0 -4
- package/lib/hooks/useToast.js +0 -4
- package/lib/hooks/useVisibilityObserver.d.ts +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +3 -1
- package/lib/mocks/components/FlashMock.d.ts +1 -1
- package/lib/mocks/views/ActionMenuMock.d.ts +1 -1
- package/lib/mocks/views/ChartMock.d.ts +1 -1
- package/lib/mocks/views/DashboardMock.d.ts +1 -1
- package/lib/mocks/views/FormMock.d.ts +1 -1
- package/lib/mocks/views/TableMock.d.ts +1 -1
- package/lib/mocks/views/WipMock.d.ts +1 -1
- package/lib/models/Credits.d.ts +16 -0
- package/lib/models/Credits.js +22 -0
- package/lib/models/McpAuditEvent.d.ts +52 -0
- package/lib/models/McpAuditEvent.js +5 -0
- package/lib/models/McpBinding.d.ts +51 -0
- package/lib/models/McpBinding.js +5 -0
- package/lib/models/McpPolicy.d.ts +77 -0
- package/lib/models/McpPolicy.js +5 -0
- package/lib/models/McpTask.d.ts +94 -0
- package/lib/models/McpTask.js +7 -0
- package/lib/models/StartedBy.d.ts +57 -0
- package/lib/models/StartedBy.js +81 -0
- package/lib/models/UserDTO.js +4 -2
- package/lib/models/contents/__fixtures__/solr-codec.json +57 -0
- package/lib/models/contents/__fixtures__/v1-contracts.json +66 -0
- package/lib/models/contents/fieldCase.d.ts +8 -0
- package/lib/models/contents/fieldCase.js +37 -0
- package/lib/models/contents/index.d.ts +2 -0
- package/lib/models/contents/index.js +6 -0
- package/lib/models/contents/permissions.d.ts +16 -0
- package/lib/models/contents/permissions.js +34 -0
- package/lib/models/index.d.ts +5 -1
- package/lib/models/index.js +5 -1
- package/lib/state/substates/CoreState.d.ts +15 -7
- package/lib/state/substates/CoreState.js +18 -14
- package/lib/state/substates/IAMState.d.ts +1 -1
- package/lib/state/substates/IAMState.js +5 -5
- package/lib/state/substates/ProfileState.js +0 -4
- package/lib/state/substates/index.d.ts +0 -1
- package/lib/state/substates/index.js +0 -1
- package/lib/utils/Jwt.d.ts +26 -0
- package/lib/utils/Jwt.js +37 -0
- package/lib/utils/WithSuspense.d.ts +1 -1
- package/lib/views/api-keys/APIKeyEdit.d.ts +1 -1
- package/lib/views/api-keys/APIKeyNew.d.ts +1 -1
- package/lib/views/api-keys/APIKeys.d.ts +1 -1
- package/lib/views/api-keys/APIKeys.js +30 -4
- package/lib/views/api-keys/APIKeysStandalone.d.ts +5 -1
- package/lib/views/api-keys/APIKeysStandalone.js +2 -2
- package/lib/views/datasources/DatasourceDetail.d.ts +12 -5
- package/lib/views/datasources/DatasourceDetail.js +80 -110
- package/lib/views/datasources/DatasourceNew.d.ts +14 -8
- package/lib/views/datasources/DatasourceNew.js +129 -118
- package/lib/views/datasources/Datasources.d.ts +39 -7
- package/lib/views/datasources/Datasources.js +95 -40
- package/lib/views/datasources/DatasourcesMock.d.ts +3 -0
- package/lib/views/datasources/DatasourcesMock.js +57 -0
- package/lib/views/iam/SignInSimple.d.ts +12 -0
- package/lib/views/iam/SignInSimple.js +4 -4
- package/lib/views/index.d.ts +1 -0
- package/lib/views/index.js +1 -0
- package/lib/views/mcp/AlertDestinations.d.ts +34 -0
- package/lib/views/mcp/AlertDestinations.js +75 -0
- package/lib/views/mcp/AlertRules.d.ts +32 -0
- package/lib/views/mcp/AlertRules.js +245 -0
- package/lib/views/mcp/AuditLog.d.ts +42 -0
- package/lib/views/mcp/AuditLog.js +144 -0
- package/lib/views/mcp/ConnectedAgents.d.ts +34 -0
- package/lib/views/mcp/ConnectedAgents.js +100 -0
- package/lib/views/mcp/EnterpriseConsole.d.ts +74 -0
- package/lib/views/mcp/EnterpriseConsole.js +173 -0
- package/lib/views/mcp/McpDashboard.d.ts +50 -0
- package/lib/views/mcp/McpDashboard.js +347 -0
- package/lib/views/mcp/McpHome.d.ts +92 -0
- package/lib/views/mcp/McpHome.js +153 -0
- package/lib/views/mcp/McpObservability.d.ts +50 -0
- package/lib/views/mcp/McpObservability.js +150 -0
- package/lib/views/mcp/OrganizationPolicy.d.ts +45 -0
- package/lib/views/mcp/OrganizationPolicy.js +107 -0
- package/lib/views/mcp/OrganizationUsage.d.ts +69 -0
- package/lib/views/mcp/OrganizationUsage.js +113 -0
- package/lib/views/mcp/PersonalPolicy.d.ts +54 -0
- package/lib/views/mcp/PersonalPolicy.js +125 -0
- package/lib/views/mcp/Policies.d.ts +53 -0
- package/lib/views/mcp/Policies.js +210 -0
- package/lib/views/mcp/PolicyForm.d.ts +67 -0
- package/lib/views/mcp/PolicyForm.js +91 -0
- package/lib/views/mcp/PolicyHistory.d.ts +45 -0
- package/lib/views/mcp/PolicyHistory.js +62 -0
- package/lib/views/mcp/ServiceAgents.d.ts +46 -0
- package/lib/views/mcp/ServiceAgents.js +194 -0
- package/lib/views/mcp/TeamPolicies.d.ts +33 -0
- package/lib/views/mcp/TeamPolicies.js +98 -0
- package/lib/views/mcp/format.d.ts +25 -0
- package/lib/views/mcp/format.js +77 -0
- package/lib/views/mcp/index.d.ts +29 -0
- package/lib/views/mcp/index.js +37 -0
- package/lib/views/mcp/types.d.ts +66 -0
- package/lib/views/mcp/types.js +5 -0
- package/lib/views/secrets/SecretEdit.d.ts +5 -1
- package/lib/views/secrets/SecretEdit.js +2 -2
- package/lib/views/secrets/SecretNew.d.ts +11 -1
- package/lib/views/secrets/SecretNew.js +2 -2
- package/lib/views/secrets/Secrets.d.ts +12 -1
- package/lib/views/secrets/Secrets.js +2 -2
- package/package.json +28 -24
- package/scripts/generate-contents-types.py +169 -0
- package/scripts/generate-mcp-types.py +233 -0
- package/lib/api/iam/datasources.d.ts +0 -86
- package/lib/api/iam/datasources.js +0 -185
- package/lib/components/toolbars/index.d.ts +0 -1
- package/lib/models/Datasource.d.ts +0 -181
- package/lib/models/Datasource.js +0 -154
- package/lib/state/substates/DatasourceState.d.ts +0 -11
- package/lib/state/substates/DatasourceState.js +0 -16
- /package/lib/{components/toolbars/index.js → api/contents/generated.js} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2023-2026 Datalayer, Inc.
|
|
7
|
+
* Distributed under the terms of the Modified BSD License.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A Dataserver registration through the service: read, moved, re-identified.
|
|
11
|
+
*
|
|
12
|
+
* The gateway itself runs in a customer's network. What is here is what it
|
|
13
|
+
* last said of itself — a heartbeat lease, the connectors it advertises,
|
|
14
|
+
* its queue — and the levers the catalog has on it: drain, resume, revoke,
|
|
15
|
+
* and a certificate issued or rotated from a CSR the gateway made, so the
|
|
16
|
+
* private key never travels.
|
|
17
|
+
*
|
|
18
|
+
* The wire types are the generated ones; what is declared here is what the
|
|
19
|
+
* contract does not name — the state union as a standalone type, its labels,
|
|
20
|
+
* and which action a reader may take on a gateway in a given state.
|
|
21
|
+
*/
|
|
22
|
+
import { requestDatalayerAPI } from '../DatalayerApi.js';
|
|
23
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants.js';
|
|
24
|
+
import { contentsToCamelCase } from '../../models/contents/index.js';
|
|
25
|
+
export const DATASERVER_STATES = [
|
|
26
|
+
'registering',
|
|
27
|
+
'ready',
|
|
28
|
+
'degraded',
|
|
29
|
+
'unavailable',
|
|
30
|
+
'draining',
|
|
31
|
+
'revoked',
|
|
32
|
+
];
|
|
33
|
+
/** The state as a person reads it. */
|
|
34
|
+
export const DATASERVER_STATE_LABELS = {
|
|
35
|
+
registering: 'Registering',
|
|
36
|
+
ready: 'Online',
|
|
37
|
+
degraded: 'Degraded',
|
|
38
|
+
unavailable: 'Offline',
|
|
39
|
+
draining: 'Draining',
|
|
40
|
+
revoked: 'Revoked',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Which actions a reader may take on a gateway in this state, and why not.
|
|
44
|
+
*
|
|
45
|
+
* `view` inspects; `execute` tests; owner or update-holder registers,
|
|
46
|
+
* rotates, drains, resumes, revokes, archives and deletes. A gateway that is
|
|
47
|
+
* revoked, or one that has gone quiet, keeps its record — the disabled
|
|
48
|
+
* actions name the state as the reason rather than disappearing.
|
|
49
|
+
*/
|
|
50
|
+
export const dataserverActionAvailability = (state, permissions, options = {}) => {
|
|
51
|
+
const manages = permissions.isOwner || permissions.update;
|
|
52
|
+
const needsManage = 'Only the owner or an update-holder may do this.';
|
|
53
|
+
const revoked = state === 'revoked';
|
|
54
|
+
const decide = (allowed, permissionReason, stateReason) => {
|
|
55
|
+
if (!allowed) {
|
|
56
|
+
return { enabled: false, reason: permissionReason };
|
|
57
|
+
}
|
|
58
|
+
if (stateReason) {
|
|
59
|
+
return { enabled: false, reason: stateReason };
|
|
60
|
+
}
|
|
61
|
+
return { enabled: true };
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
test: decide(permissions.execute || manages, 'Only someone who may execute through this gateway can test it.', revoked ? 'The gateway is revoked; its identity is no longer accepted.' : undefined),
|
|
65
|
+
rotateIdentity: decide(manages, needsManage, revoked ? 'A revoked gateway is re-admitted with a new identity, not a rotation.' : undefined),
|
|
66
|
+
drain: decide(manages, needsManage, revoked
|
|
67
|
+
? 'The gateway is revoked.'
|
|
68
|
+
: state === 'draining'
|
|
69
|
+
? 'The gateway is already draining.'
|
|
70
|
+
: state === 'registering' || state === 'unavailable' || !state
|
|
71
|
+
? 'Nothing routes to a gateway that is not online; there is nothing to drain.'
|
|
72
|
+
: undefined),
|
|
73
|
+
resume: decide(manages, needsManage, revoked
|
|
74
|
+
? 'The gateway is revoked.'
|
|
75
|
+
: state !== 'draining'
|
|
76
|
+
? 'Only a draining gateway is resumed.'
|
|
77
|
+
: undefined),
|
|
78
|
+
revoke: decide(manages, needsManage, revoked ? 'The gateway is already revoked.' : undefined),
|
|
79
|
+
archive: decide(manages, needsManage, options.archived ? 'The registration is already archived.' : undefined),
|
|
80
|
+
delete: decide(manages, needsManage),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const convertResponse = (value) => contentsToCamelCase(value);
|
|
84
|
+
const dataserverUrl = (baseUrl, sourceUid, suffix = '') => `${baseUrl}${API_BASE_PATHS.CONTENTS}/dataservers/${encodeURIComponent(sourceUid)}${suffix}`;
|
|
85
|
+
/** The gateway as last heard: its lease, its connectors, its queue. */
|
|
86
|
+
export const getDataserverStatus = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
87
|
+
url: dataserverUrl(baseUrl, sourceUid, '/status'),
|
|
88
|
+
method: 'GET',
|
|
89
|
+
token,
|
|
90
|
+
}));
|
|
91
|
+
/** Try the gateway on Flight and on the HTTPS fallback; the answer is a verdict per path. */
|
|
92
|
+
export const testDataserver = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
93
|
+
url: dataserverUrl(baseUrl, sourceUid, '/test'),
|
|
94
|
+
method: 'POST',
|
|
95
|
+
token,
|
|
96
|
+
}));
|
|
97
|
+
const transition = async (token, sourceUid, action, baseUrl) => convertResponse(await requestDatalayerAPI({
|
|
98
|
+
url: dataserverUrl(baseUrl, sourceUid, `/${action}`),
|
|
99
|
+
method: 'POST',
|
|
100
|
+
token,
|
|
101
|
+
}));
|
|
102
|
+
/** Stop routing new queries; the ones running finish. */
|
|
103
|
+
export const drainDataserver = (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => transition(token, sourceUid, 'drain', baseUrl);
|
|
104
|
+
/** Route to the gateway again. */
|
|
105
|
+
export const resumeDataserver = (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => transition(token, sourceUid, 'resume', baseUrl);
|
|
106
|
+
/** Refuse the gateway's identity from now on. Nothing in its network changes. */
|
|
107
|
+
export const revokeDataserver = (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => transition(token, sourceUid, 'revoke', baseUrl);
|
|
108
|
+
/** A first certificate for the identity the CSR names. */
|
|
109
|
+
export const issueDataserverIdentity = async (token, sourceUid, request, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
110
|
+
url: dataserverUrl(baseUrl, sourceUid, '/identity'),
|
|
111
|
+
method: 'POST',
|
|
112
|
+
token,
|
|
113
|
+
body: { csr: request.csr },
|
|
114
|
+
}));
|
|
115
|
+
/** A new certificate that overlaps the current one, so nothing stops. */
|
|
116
|
+
export const rotateDataserverIdentity = async (token, sourceUid, request, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
117
|
+
url: dataserverUrl(baseUrl, sourceUid, '/identity/rotate'),
|
|
118
|
+
method: 'POST',
|
|
119
|
+
token,
|
|
120
|
+
body: { csr: request.csr },
|
|
121
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DatasetPublication, DatasetPublicationCreate, DatasetPublicationList, DatasetRevision, DatasetRevisionCreate, DatasetRevisionList } from './generated';
|
|
2
|
+
export declare const createDatasetRevision: (token: string, sourceUid: string, request: DatasetRevisionCreate, idempotencyKey: string, baseUrl?: string) => Promise<DatasetRevision>;
|
|
3
|
+
export declare const listDatasetRevisions: (token: string, sourceUid: string, baseUrl?: string) => Promise<DatasetRevisionList>;
|
|
4
|
+
export declare const getDatasetRevision: (token: string, sourceUid: string, revisionUid: string, baseUrl?: string) => Promise<DatasetRevision>;
|
|
5
|
+
export declare const createDatasetPublication: (token: string, sourceUid: string, request: DatasetPublicationCreate, idempotencyKey: string, baseUrl?: string) => Promise<DatasetPublication>;
|
|
6
|
+
export declare const listDatasetPublications: (token: string, sourceUid: string, baseUrl?: string) => Promise<DatasetPublicationList>;
|
|
7
|
+
export declare const unpublishDataset: (token: string, sourceUid: string, publicationUid: string, baseUrl?: string) => Promise<DatasetPublication>;
|
|
8
|
+
/**
|
|
9
|
+
* Every Dataset currently published, across sources.
|
|
10
|
+
*
|
|
11
|
+
* What the Library shows: a publication names one immutable revision of a
|
|
12
|
+
* Dataset, so this is the list of what has been made public, not of Datasets.
|
|
13
|
+
* Any signed-in caller may read it — published means public.
|
|
14
|
+
*/
|
|
15
|
+
export declare const listPublishedDatasets: (token: string, baseUrl?: string) => Promise<DatasetPublicationList>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { requestDatalayerAPI } from '../DatalayerApi.js';
|
|
6
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants.js';
|
|
7
|
+
import { contentsToCamelCase, contentsToSnakeCase } from '../../models/contents/index.js';
|
|
8
|
+
const convert = (value) => contentsToCamelCase(value);
|
|
9
|
+
const resourceUrl = (baseUrl, sourceUid, resource, suffix = '') => `${baseUrl}${API_BASE_PATHS.CONTENTS}/sources/${encodeURIComponent(sourceUid)}/${resource}${suffix}`;
|
|
10
|
+
export const createDatasetRevision = async (token, sourceUid, request, idempotencyKey, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
11
|
+
url: resourceUrl(baseUrl, sourceUid, 'revisions'), method: 'POST', token,
|
|
12
|
+
headers: { 'Idempotency-Key': idempotencyKey },
|
|
13
|
+
body: contentsToSnakeCase(request),
|
|
14
|
+
}));
|
|
15
|
+
export const listDatasetRevisions = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
16
|
+
url: resourceUrl(baseUrl, sourceUid, 'revisions'), method: 'GET', token,
|
|
17
|
+
}));
|
|
18
|
+
export const getDatasetRevision = async (token, sourceUid, revisionUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
19
|
+
url: resourceUrl(baseUrl, sourceUid, 'revisions', `/${encodeURIComponent(revisionUid)}`),
|
|
20
|
+
method: 'GET', token,
|
|
21
|
+
}));
|
|
22
|
+
export const createDatasetPublication = async (token, sourceUid, request, idempotencyKey, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
23
|
+
url: resourceUrl(baseUrl, sourceUid, 'publications'), method: 'POST', token,
|
|
24
|
+
headers: { 'Idempotency-Key': idempotencyKey },
|
|
25
|
+
body: contentsToSnakeCase(request),
|
|
26
|
+
}));
|
|
27
|
+
export const listDatasetPublications = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
28
|
+
url: resourceUrl(baseUrl, sourceUid, 'publications'), method: 'GET', token,
|
|
29
|
+
}));
|
|
30
|
+
export const unpublishDataset = async (token, sourceUid, publicationUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
31
|
+
url: resourceUrl(baseUrl, sourceUid, 'publications', `/${encodeURIComponent(publicationUid)}`),
|
|
32
|
+
method: 'DELETE', token,
|
|
33
|
+
}));
|
|
34
|
+
/**
|
|
35
|
+
* Every Dataset currently published, across sources.
|
|
36
|
+
*
|
|
37
|
+
* What the Library shows: a publication names one immutable revision of a
|
|
38
|
+
* Dataset, so this is the list of what has been made public, not of Datasets.
|
|
39
|
+
* Any signed-in caller may read it — published means public.
|
|
40
|
+
*/
|
|
41
|
+
export const listPublishedDatasets = async (token, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convert(await requestDatalayerAPI({
|
|
42
|
+
url: `${baseUrl}${API_BASE_PATHS.CONTENTS}/publications`,
|
|
43
|
+
method: 'GET',
|
|
44
|
+
token,
|
|
45
|
+
}));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { CapabilityTicket, CapabilityTicketRequest, DatasetRevision, DatasourceCapabilities, DatasourceConfiguration, DatasourceQuery, DatasourceQueryCreate, DatasourceQueryList, DatasourceSchema, DatasourceTest, QuerySave } from './generated';
|
|
2
|
+
export type DatasourceConnectorType = DatasourceConfiguration['connectorType'];
|
|
3
|
+
export type DatasourceNetworkRoute = NonNullable<DatasourceConfiguration['networkRoute']>;
|
|
4
|
+
export type DatasourceOperation = DatasourceCapabilities['operations'][number];
|
|
5
|
+
export type DatasourceQueryStatus = DatasourceQuery['status'];
|
|
6
|
+
/** The operations a Datasource may allow, in the order a form lists them. */
|
|
7
|
+
export declare const DATASOURCE_OPERATIONS: ReadonlyArray<DatasourceOperation>;
|
|
8
|
+
/**
|
|
9
|
+
* The connectors a person can pick in a form.
|
|
10
|
+
*
|
|
11
|
+
* `table` is not one of them: a published table is created by publishing it
|
|
12
|
+
* from a sandbox, and `POST /sources` refuses one made by hand
|
|
13
|
+
* (`PUBLISHED_TABLE_MANAGED`) because the record and its files have to come
|
|
14
|
+
* into being together. Saying that in the type keeps a creation form from
|
|
15
|
+
* having to invent labels and hints for something it cannot create.
|
|
16
|
+
*/
|
|
17
|
+
export type CreatableDatasourceConnectorType = Exclude<DatasourceConnectorType, 'table' | 'live'>;
|
|
18
|
+
export declare const DATASOURCE_CONNECTOR_LABELS: Record<DatasourceConnectorType, string>;
|
|
19
|
+
/** A query the service has finished with, one way or another. */
|
|
20
|
+
export declare const DATASOURCE_QUERY_TERMINAL_STATUSES: ReadonlySet<DatasourceQueryStatus>;
|
|
21
|
+
export declare const isDatasourceQueryTerminal: (status: DatasourceQueryStatus) => boolean;
|
|
22
|
+
/** The bytes of a result, or a range of them, with what the headers said. */
|
|
23
|
+
export interface DatasourceQueryResultBytes {
|
|
24
|
+
body: ArrayBuffer;
|
|
25
|
+
status: number;
|
|
26
|
+
headers: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
/** Does the database answer through this source, right now? A verdict, not a stack trace. */
|
|
29
|
+
export declare const testDatasource: (token: string, sourceUid: string, baseUrl?: string) => Promise<DatasourceTest>;
|
|
30
|
+
/** The tables and columns the source exposes, as the service saw them. */
|
|
31
|
+
export declare const discoverDatasourceSchema: (token: string, sourceUid: string, baseUrl?: string) => Promise<DatasourceSchema>;
|
|
32
|
+
/** What the source may be asked, and how the answer can travel. */
|
|
33
|
+
export declare const getDatasourceCapabilities: (token: string, sourceUid: string, baseUrl?: string) => Promise<DatasourceCapabilities>;
|
|
34
|
+
/**
|
|
35
|
+
* Submit a statement; the answer is the job, not the rows.
|
|
36
|
+
*
|
|
37
|
+
* The service checks the statement against the source's operation allowlist
|
|
38
|
+
* and the limits against its policy before the job exists, so a refused
|
|
39
|
+
* query is refused here, with a reason, and not later on the stream.
|
|
40
|
+
*/
|
|
41
|
+
export declare const createDatasourceQuery: (token: string, sourceUid: string, request: DatasourceQueryCreate, idempotencyKey: string, baseUrl?: string) => Promise<DatasourceQuery>;
|
|
42
|
+
/** The queries run against a source, newest first: its history. */
|
|
43
|
+
export declare const listDatasourceQueries: (token: string, sourceUid: string, options?: {
|
|
44
|
+
cursor?: string;
|
|
45
|
+
limit?: number;
|
|
46
|
+
}, baseUrl?: string) => Promise<DatasourceQueryList>;
|
|
47
|
+
export declare const getDatasourceQuery: (token: string, queryUid: string, baseUrl?: string) => Promise<DatasourceQuery>;
|
|
48
|
+
/** Ask for the query to stop; the cancellation reaches the connector. */
|
|
49
|
+
export declare const cancelDatasourceQuery: (token: string, queryUid: string, baseUrl?: string) => Promise<DatasourceQuery>;
|
|
50
|
+
/** Where a browser fetches a result from; a link, for a download. */
|
|
51
|
+
export declare const datasourceQueryResultsUrl: (queryUid: string, baseUrl?: string) => string;
|
|
52
|
+
/**
|
|
53
|
+
* The result of a finished query, as Arrow IPC bytes, or a `Range` of them.
|
|
54
|
+
*
|
|
55
|
+
* A range is how a stream that broke halfway is resumed rather than
|
|
56
|
+
* restarted — and how a preview reads the first bytes of a large result
|
|
57
|
+
* without the rest.
|
|
58
|
+
*/
|
|
59
|
+
export declare const downloadDatasourceQueryResults: (token: string, queryUid: string, options?: {
|
|
60
|
+
range?: string;
|
|
61
|
+
}, baseUrl?: string) => Promise<DatasourceQueryResultBytes>;
|
|
62
|
+
/**
|
|
63
|
+
* Keep a result: written into a Dataset as a verified revision.
|
|
64
|
+
*
|
|
65
|
+
* The bytes go from the service into the Dataset; nothing is downloaded to
|
|
66
|
+
* be uploaded again, and the answer is the revision that now holds them.
|
|
67
|
+
*/
|
|
68
|
+
export declare const saveDatasourceQueryAsDataset: (token: string, queryUid: string, request: QuerySave, baseUrl?: string) => Promise<DatasetRevision>;
|
|
69
|
+
/** A Flight ticket for the result, for a client inside a sandbox. Never for the browser. */
|
|
70
|
+
export declare const createDatasourceQueryTicket: (token: string, queryUid: string, request?: CapabilityTicketRequest, baseUrl?: string) => Promise<CapabilityTicket>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2023-2026 Datalayer, Inc.
|
|
7
|
+
* Distributed under the terms of the Modified BSD License.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A Datasource through the service: tested, described, queried.
|
|
11
|
+
*
|
|
12
|
+
* Nothing here talks to the database. Contents does, with the credential it
|
|
13
|
+
* holds — directly, or through a Dataserver in the customer's network — and
|
|
14
|
+
* answers with a verdict, a schema, or a query job. A job is polled to its
|
|
15
|
+
* end; its result is Arrow IPC bytes read by range, and it can be kept as a
|
|
16
|
+
* Dataset revision rather than downloaded to be uploaded again.
|
|
17
|
+
*
|
|
18
|
+
* The wire types are the generated ones; what is declared here is what the
|
|
19
|
+
* contract does not name — the unions as standalone types, the labels a
|
|
20
|
+
* form shows, which statuses are terminal, and the bytes of a result.
|
|
21
|
+
*/
|
|
22
|
+
import { requestDatalayerAPI, requestDatalayerAPIWithResponse, } from '../DatalayerApi.js';
|
|
23
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants.js';
|
|
24
|
+
import { contentsToCamelCase, contentsToSnakeCase, } from '../../models/contents/index.js';
|
|
25
|
+
/** The operations a Datasource may allow, in the order a form lists them. */
|
|
26
|
+
export const DATASOURCE_OPERATIONS = [
|
|
27
|
+
'select',
|
|
28
|
+
'describe',
|
|
29
|
+
'list',
|
|
30
|
+
];
|
|
31
|
+
export const DATASOURCE_CONNECTOR_LABELS = {
|
|
32
|
+
athena: 'Amazon Athena',
|
|
33
|
+
bigquery: 'Google BigQuery',
|
|
34
|
+
sql: 'SQL database',
|
|
35
|
+
// Listed, unlike above: a published table is a Datasource people see in
|
|
36
|
+
// the catalog and query like any other, even though no form makes one.
|
|
37
|
+
table: 'Published table',
|
|
38
|
+
// The same table while its kernel is up: answered from the live frame,
|
|
39
|
+
// and from the published snapshot once the kernel is gone.
|
|
40
|
+
live: 'Live table',
|
|
41
|
+
};
|
|
42
|
+
/** A query the service has finished with, one way or another. */
|
|
43
|
+
export const DATASOURCE_QUERY_TERMINAL_STATUSES = new Set(['succeeded', 'failed', 'cancelled']);
|
|
44
|
+
export const isDatasourceQueryTerminal = (status) => DATASOURCE_QUERY_TERMINAL_STATUSES.has(status);
|
|
45
|
+
const convertResponse = (value) => contentsToCamelCase(value);
|
|
46
|
+
const convertRequest = (value) => contentsToSnakeCase(value);
|
|
47
|
+
const datasourceUrl = (baseUrl, sourceUid, suffix = '') => `${baseUrl}${API_BASE_PATHS.CONTENTS}/sources/${encodeURIComponent(sourceUid)}/datasource${suffix}`;
|
|
48
|
+
const queryUrl = (baseUrl, queryUid, suffix = '') => `${baseUrl}${API_BASE_PATHS.CONTENTS}/queries/${encodeURIComponent(queryUid)}${suffix}`;
|
|
49
|
+
/** Does the database answer through this source, right now? A verdict, not a stack trace. */
|
|
50
|
+
export const testDatasource = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
51
|
+
url: datasourceUrl(baseUrl, sourceUid, '/test'),
|
|
52
|
+
method: 'POST',
|
|
53
|
+
token,
|
|
54
|
+
}));
|
|
55
|
+
/** The tables and columns the source exposes, as the service saw them. */
|
|
56
|
+
export const discoverDatasourceSchema = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
57
|
+
url: datasourceUrl(baseUrl, sourceUid, '/schema'),
|
|
58
|
+
method: 'GET',
|
|
59
|
+
token,
|
|
60
|
+
}));
|
|
61
|
+
/** What the source may be asked, and how the answer can travel. */
|
|
62
|
+
export const getDatasourceCapabilities = async (token, sourceUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
63
|
+
url: datasourceUrl(baseUrl, sourceUid, '/capabilities'),
|
|
64
|
+
method: 'GET',
|
|
65
|
+
token,
|
|
66
|
+
}));
|
|
67
|
+
/**
|
|
68
|
+
* Submit a statement; the answer is the job, not the rows.
|
|
69
|
+
*
|
|
70
|
+
* The service checks the statement against the source's operation allowlist
|
|
71
|
+
* and the limits against its policy before the job exists, so a refused
|
|
72
|
+
* query is refused here, with a reason, and not later on the stream.
|
|
73
|
+
*/
|
|
74
|
+
export const createDatasourceQuery = async (token, sourceUid, request, idempotencyKey, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
75
|
+
url: `${baseUrl}${API_BASE_PATHS.CONTENTS}/sources/${encodeURIComponent(sourceUid)}/queries`,
|
|
76
|
+
method: 'POST',
|
|
77
|
+
token,
|
|
78
|
+
headers: { 'Idempotency-Key': idempotencyKey },
|
|
79
|
+
body: convertRequest(request),
|
|
80
|
+
}));
|
|
81
|
+
/** The queries run against a source, newest first: its history. */
|
|
82
|
+
export const listDatasourceQueries = async (token, sourceUid, options = {}, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => {
|
|
83
|
+
const parameters = new URLSearchParams();
|
|
84
|
+
parameters.set('limit', String(options.limit ?? 50));
|
|
85
|
+
if (options.cursor) {
|
|
86
|
+
parameters.set('cursor', options.cursor);
|
|
87
|
+
}
|
|
88
|
+
return convertResponse(await requestDatalayerAPI({
|
|
89
|
+
url: `${baseUrl}${API_BASE_PATHS.CONTENTS}/sources/${encodeURIComponent(sourceUid)}/queries?${parameters.toString()}`,
|
|
90
|
+
method: 'GET',
|
|
91
|
+
token,
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
export const getDatasourceQuery = async (token, queryUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
95
|
+
url: queryUrl(baseUrl, queryUid),
|
|
96
|
+
method: 'GET',
|
|
97
|
+
token,
|
|
98
|
+
}));
|
|
99
|
+
/** Ask for the query to stop; the cancellation reaches the connector. */
|
|
100
|
+
export const cancelDatasourceQuery = async (token, queryUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
101
|
+
url: queryUrl(baseUrl, queryUid, '/cancel'),
|
|
102
|
+
method: 'POST',
|
|
103
|
+
token,
|
|
104
|
+
}));
|
|
105
|
+
/** Where a browser fetches a result from; a link, for a download. */
|
|
106
|
+
export const datasourceQueryResultsUrl = (queryUid, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => queryUrl(baseUrl, queryUid, '/results');
|
|
107
|
+
/**
|
|
108
|
+
* The result of a finished query, as Arrow IPC bytes, or a `Range` of them.
|
|
109
|
+
*
|
|
110
|
+
* A range is how a stream that broke halfway is resumed rather than
|
|
111
|
+
* restarted — and how a preview reads the first bytes of a large result
|
|
112
|
+
* without the rest.
|
|
113
|
+
*/
|
|
114
|
+
export const downloadDatasourceQueryResults = async (token, queryUid, options = {}, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => {
|
|
115
|
+
const response = await requestDatalayerAPIWithResponse({
|
|
116
|
+
url: datasourceQueryResultsUrl(queryUid, baseUrl),
|
|
117
|
+
method: 'GET',
|
|
118
|
+
token,
|
|
119
|
+
headers: options.range ? { Range: options.range } : undefined,
|
|
120
|
+
responseType: 'arraybuffer',
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
body: response.data,
|
|
124
|
+
status: response.status,
|
|
125
|
+
headers: response.headers,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Keep a result: written into a Dataset as a verified revision.
|
|
130
|
+
*
|
|
131
|
+
* The bytes go from the service into the Dataset; nothing is downloaded to
|
|
132
|
+
* be uploaded again, and the answer is the revision that now holds them.
|
|
133
|
+
*/
|
|
134
|
+
export const saveDatasourceQueryAsDataset = async (token, queryUid, request, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
135
|
+
url: queryUrl(baseUrl, queryUid, '/save'),
|
|
136
|
+
method: 'POST',
|
|
137
|
+
token,
|
|
138
|
+
body: convertRequest({
|
|
139
|
+
...request,
|
|
140
|
+
path: request.path.replace(/^\/+/, ''),
|
|
141
|
+
}),
|
|
142
|
+
}));
|
|
143
|
+
/** A Flight ticket for the result, for a client inside a sandbox. Never for the browser. */
|
|
144
|
+
export const createDatasourceQueryTicket = async (token, queryUid, request = {}, baseUrl = DEFAULT_SERVICE_URLS.CONTENTS) => convertResponse(await requestDatalayerAPI({
|
|
145
|
+
url: queryUrl(baseUrl, queryUid, '/ticket'),
|
|
146
|
+
method: 'POST',
|
|
147
|
+
token,
|
|
148
|
+
body: convertRequest(request),
|
|
149
|
+
}));
|