@databricks/appkit 0.5.4 → 0.7.0
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/CLAUDE.md +23 -1
- package/NOTICE.md +3 -1
- package/bin/appkit.js +0 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -33
- package/dist/appkit/package.js +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +7 -7
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/storage/persistent.js +23 -21
- package/dist/cache/storage/persistent.js.map +1 -1
- package/dist/cli/commands/plugins-sync.js +369 -0
- package/dist/cli/commands/plugins-sync.js.map +1 -0
- package/dist/cli/commands/plugins.js +19 -0
- package/dist/cli/commands/plugins.js.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/connectors/index.js +2 -2
- package/dist/connectors/lakebase/index.d.ts +16 -0
- package/dist/connectors/lakebase/index.d.ts.map +1 -0
- package/dist/connectors/lakebase/index.js +21 -2
- package/dist/connectors/lakebase/index.js.map +1 -0
- package/dist/connectors/lakebase-v1/client.js +13 -0
- package/dist/connectors/lakebase-v1/client.js.map +1 -0
- package/dist/connectors/lakebase-v1/index.js +3 -0
- package/dist/connectors/sql-warehouse/client.js +2 -2
- package/dist/context/execution-context.js +1 -7
- package/dist/context/execution-context.js.map +1 -1
- package/dist/context/index.js +4 -16
- package/dist/context/index.js.map +1 -1
- package/dist/core/appkit.d.ts.map +1 -1
- package/dist/core/appkit.js +6 -2
- package/dist/core/appkit.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/logging/logger.js +1 -1
- package/dist/plugin/plugin.d.ts +95 -3
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +98 -10
- package/dist/plugin/plugin.js.map +1 -1
- package/dist/plugins/analytics/analytics.d.ts +3 -1
- package/dist/plugins/analytics/analytics.d.ts.map +1 -1
- package/dist/plugins/analytics/analytics.js +5 -3
- package/dist/plugins/analytics/analytics.js.map +1 -1
- package/dist/plugins/analytics/index.js +1 -0
- package/dist/plugins/analytics/manifest.js +21 -0
- package/dist/plugins/analytics/manifest.js.map +1 -0
- package/dist/plugins/analytics/manifest.json +36 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/server/index.d.ts +3 -1
- package/dist/plugins/server/index.d.ts.map +1 -1
- package/dist/plugins/server/index.js +5 -3
- package/dist/plugins/server/index.js.map +1 -1
- package/dist/plugins/server/manifest.js +21 -0
- package/dist/plugins/server/manifest.js.map +1 -0
- package/dist/plugins/server/manifest.json +36 -0
- package/dist/registry/index.js +5 -0
- package/dist/registry/manifest-loader.d.ts +44 -0
- package/dist/registry/manifest-loader.d.ts.map +1 -0
- package/dist/registry/manifest-loader.js +97 -0
- package/dist/registry/manifest-loader.js.map +1 -0
- package/dist/registry/resource-registry.d.ts +133 -0
- package/dist/registry/resource-registry.d.ts.map +1 -0
- package/dist/registry/resource-registry.js +297 -0
- package/dist/registry/resource-registry.js.map +1 -0
- package/dist/registry/types.d.ts +181 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +89 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/shared/src/plugin.d.ts +66 -1
- package/dist/shared/src/plugin.d.ts.map +1 -1
- package/docs/docs/api/appkit/Class.AppKitError/index.html +5 -5
- package/docs/docs/api/appkit/Class.AuthenticationError/index.html +4 -4
- package/docs/docs/api/appkit/Class.ConfigurationError/index.html +4 -4
- package/docs/docs/api/appkit/Class.ConnectionError/index.html +4 -4
- package/docs/docs/api/appkit/Class.ExecutionError/index.html +4 -4
- package/docs/docs/api/appkit/Class.InitializationError/index.html +4 -4
- package/docs/docs/api/appkit/Class.Plugin/index.html +28 -16
- package/docs/docs/api/appkit/Class.Plugin.md +90 -30
- package/docs/docs/api/appkit/Class.ResourceRegistry/index.html +150 -0
- package/docs/docs/api/appkit/Class.ResourceRegistry.md +301 -0
- package/docs/docs/api/appkit/Class.ServerError/index.html +5 -5
- package/docs/docs/api/appkit/Class.TunnelError/index.html +4 -4
- package/docs/docs/api/appkit/Class.ValidationError/index.html +4 -4
- package/docs/docs/api/appkit/Enumeration.RequestedClaimsPermissionSet/index.html +21 -0
- package/docs/docs/api/appkit/Enumeration.RequestedClaimsPermissionSet.md +14 -0
- package/docs/docs/api/appkit/Enumeration.ResourceType/index.html +66 -0
- package/docs/docs/api/appkit/Enumeration.ResourceType.md +135 -0
- package/docs/docs/api/appkit/Function.appKitTypesPlugin/index.html +4 -4
- package/docs/docs/api/appkit/Function.createApp/index.html +5 -5
- package/docs/docs/api/appkit/Function.createLakebasePool/index.html +24 -0
- package/docs/docs/api/appkit/Function.createLakebasePool.md +20 -0
- package/docs/docs/api/appkit/Function.generateDatabaseCredential/index.html +30 -0
- package/docs/docs/api/appkit/Function.generateDatabaseCredential.md +57 -0
- package/docs/docs/api/appkit/Function.getExecutionContext/index.html +5 -5
- package/docs/docs/api/appkit/Function.getLakebaseOrmConfig/index.html +39 -0
- package/docs/docs/api/appkit/Function.getLakebaseOrmConfig.md +90 -0
- package/docs/docs/api/appkit/Function.getLakebasePgConfig/index.html +27 -0
- package/docs/docs/api/appkit/Function.getLakebasePgConfig.md +31 -0
- package/docs/docs/api/appkit/Function.getPluginManifest/index.html +26 -0
- package/docs/docs/api/appkit/Function.getPluginManifest.md +24 -0
- package/docs/docs/api/appkit/Function.getResourceRequirements/index.html +28 -0
- package/docs/docs/api/appkit/Function.getResourceRequirements.md +42 -0
- package/docs/docs/api/appkit/Function.getWorkspaceClient/index.html +22 -0
- package/docs/docs/api/appkit/Function.getWorkspaceClient.md +18 -0
- package/docs/docs/api/appkit/Function.isSQLTypeMarker/index.html +5 -5
- package/docs/docs/api/appkit/Interface.BasePluginConfig/index.html +4 -4
- package/docs/docs/api/appkit/Interface.CacheConfig/index.html +5 -5
- package/docs/docs/api/appkit/Interface.DatabaseCredential/index.html +28 -0
- package/docs/docs/api/appkit/Interface.DatabaseCredential.md +32 -0
- package/docs/docs/api/appkit/Interface.GenerateDatabaseCredentialRequest/index.html +38 -0
- package/docs/docs/api/appkit/Interface.GenerateDatabaseCredentialRequest.md +54 -0
- package/docs/docs/api/appkit/Interface.ITelemetry/index.html +5 -5
- package/docs/docs/api/appkit/Interface.LakebasePoolConfig/index.html +79 -0
- package/docs/docs/api/appkit/Interface.LakebasePoolConfig.md +126 -0
- package/docs/docs/api/appkit/Interface.PluginManifest/index.html +63 -0
- package/docs/docs/api/appkit/Interface.PluginManifest.md +135 -0
- package/docs/docs/api/appkit/Interface.RequestedClaims/index.html +26 -0
- package/docs/docs/api/appkit/Interface.RequestedClaims.md +25 -0
- package/docs/docs/api/appkit/Interface.RequestedResource/index.html +27 -0
- package/docs/docs/api/appkit/Interface.RequestedResource.md +32 -0
- package/docs/docs/api/appkit/Interface.ResourceEntry/index.html +83 -0
- package/docs/docs/api/appkit/Interface.ResourceEntry.md +156 -0
- package/docs/docs/api/appkit/Interface.ResourceFieldEntry/index.html +26 -0
- package/docs/docs/api/appkit/Interface.ResourceFieldEntry.md +25 -0
- package/docs/docs/api/appkit/Interface.ResourceRequirement/index.html +51 -0
- package/docs/docs/api/appkit/Interface.ResourceRequirement.md +84 -0
- package/docs/docs/api/appkit/Interface.StreamExecutionSettings/index.html +5 -5
- package/docs/docs/api/appkit/Interface.TelemetryConfig/index.html +5 -5
- package/docs/docs/api/appkit/Interface.ValidationResult/index.html +29 -0
- package/docs/docs/api/appkit/Interface.ValidationResult.md +36 -0
- package/docs/docs/api/appkit/TypeAlias.ConfigSchema/index.html +21 -0
- package/docs/docs/api/appkit/TypeAlias.ConfigSchema.md +12 -0
- package/docs/docs/api/appkit/TypeAlias.IAppRouter/index.html +5 -5
- package/docs/docs/api/appkit/TypeAlias.ResourcePermission/index.html +18 -0
- package/docs/docs/api/appkit/TypeAlias.ResourcePermission.md +20 -0
- package/docs/docs/api/appkit/Variable.sql/index.html +5 -5
- package/docs/docs/api/appkit/index.html +10 -8
- package/docs/docs/api/appkit-ui/data/AreaChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/BarChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/DataTable/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/DonutChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/HeatmapChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/LineChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/PieChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/RadarChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/data/ScatterChart/index.html +3 -3
- package/docs/docs/api/appkit-ui/index.html +3 -3
- package/docs/docs/api/appkit-ui/styling/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Accordion/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Alert/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/AlertDialog/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/AspectRatio/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Avatar/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Badge/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Breadcrumb/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Button/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/ButtonGroup/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Calendar/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Card/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Carousel/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/ChartContainer/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Checkbox/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Collapsible/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Command/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/ContextMenu/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Dialog/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Drawer/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/DropdownMenu/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Empty/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Field/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/FormControl/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/HoverCard/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Input/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/InputGroup/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/InputOTP/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Item/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Kbd/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Label/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Menubar/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/NavigationMenu/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Pagination/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Popover/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Progress/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/RadioGroup/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/ResizableHandle/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/ScrollArea/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Select/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Separator/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Sheet/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Sidebar/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Skeleton/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Slider/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Spinner/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Switch/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Table/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Tabs/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Textarea/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Toaster/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Toggle/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/ToggleGroup/index.html +3 -3
- package/docs/docs/api/appkit-ui/ui/Tooltip/index.html +3 -3
- package/docs/docs/api/appkit.md +55 -28
- package/docs/docs/api/index.html +3 -3
- package/docs/docs/app-management/index.html +3 -3
- package/docs/docs/architecture/index.html +4 -4
- package/docs/docs/architecture.md +1 -1
- package/docs/docs/category/development/index.html +3 -3
- package/docs/docs/configuration/index.html +3 -3
- package/docs/docs/core-principles/index.html +3 -3
- package/docs/docs/development/ai-assisted-development/index.html +3 -3
- package/docs/docs/development/index.html +3 -3
- package/docs/docs/development/llm-guide/index.html +3 -3
- package/docs/docs/development/local-development/index.html +3 -3
- package/docs/docs/development/project-setup/index.html +3 -3
- package/docs/docs/development/remote-bridge/index.html +3 -3
- package/docs/docs/development/type-generation/index.html +3 -3
- package/docs/docs/index.html +3 -3
- package/docs/docs/plugins/index.html +18 -8
- package/docs/docs/plugins.md +82 -4
- package/llms.txt +23 -1
- package/package.json +8 -4
- package/dist/connectors/lakebase/client.js +0 -362
- package/dist/connectors/lakebase/client.js.map +0 -1
- package/dist/connectors/lakebase/defaults.js +0 -13
- package/dist/connectors/lakebase/defaults.js.map +0 -1
- package/dist/utils/env-validator.js +0 -14
- package/dist/utils/env-validator.js.map +0 -1
package/llms.txt
CHANGED
|
@@ -32,20 +32,42 @@ The CLI will display the documentation content directly in the terminal.
|
|
|
32
32
|
- [Class: ConnectionError](./docs/docs/api./docs/Class.ConnectionError.md): Error thrown when a connection or network operation fails.
|
|
33
33
|
- [Class: ExecutionError](./docs/docs/api./docs/Class.ExecutionError.md): Error thrown when an operation execution fails.
|
|
34
34
|
- [Class: InitializationError](./docs/docs/api./docs/Class.InitializationError.md): Error thrown when a service or component is not properly initialized.
|
|
35
|
-
- [Abstract Class: Plugin<TConfig>](./docs/docs/api./docs/Class.Plugin.md): Base abstract class for creating AppKit plugins
|
|
35
|
+
- [Abstract Class: Plugin<TConfig>](./docs/docs/api./docs/Class.Plugin.md): Base abstract class for creating AppKit plugins.
|
|
36
|
+
- [Class: ResourceRegistry](./docs/docs/api./docs/Class.ResourceRegistry.md): Central registry for tracking plugin resource requirements.
|
|
36
37
|
- [Class: ServerError](./docs/docs/api./docs/Class.ServerError.md): Error thrown when server lifecycle operations fail.
|
|
37
38
|
- [Class: TunnelError](./docs/docs/api./docs/Class.TunnelError.md): Error thrown when remote tunnel operations fail.
|
|
38
39
|
- [Class: ValidationError](./docs/docs/api./docs/Class.ValidationError.md): Error thrown when input validation fails.
|
|
40
|
+
- [Enumeration: RequestedClaimsPermissionSet](./docs/docs/api./docs/Enumeration.RequestedClaimsPermissionSet.md): Permission set for Unity Catalog table access
|
|
41
|
+
- [Enumeration: ResourceType](./docs/docs/api./docs/Enumeration.ResourceType.md): Supported resource types that plugins can depend on.
|
|
39
42
|
- [Function: appKitTypesPlugin()](./docs/docs/api./docs/Function.appKitTypesPlugin.md): Vite plugin to generate types for AppKit queries.
|
|
40
43
|
- [Function: createApp()](./docs/docs/api./docs/Function.createApp.md): Bootstraps AppKit with the provided configuration.
|
|
44
|
+
- [Function: createLakebasePool()](./docs/docs/api./docs/Function.createLakebasePool.md): Create a Lakebase pool with appkit's logger integration.
|
|
45
|
+
- [Function: generateDatabaseCredential()](./docs/docs/api./docs/Function.generateDatabaseCredential.md): Generate OAuth credentials for Postgres database connection using the proper Postgres API.
|
|
41
46
|
- [Function: getExecutionContext()](./docs/docs/api./docs/Function.getExecutionContext.md): Get the current execution context.
|
|
47
|
+
- [Function: getLakebaseOrmConfig()](./docs/docs/api./docs/Function.getLakebaseOrmConfig.md): Get Lakebase connection configuration for ORMs that don't accept pg.Pool directly.
|
|
48
|
+
- [Function: getLakebasePgConfig()](./docs/docs/api./docs/Function.getLakebasePgConfig.md): Get Lakebase connection configuration for PostgreSQL clients.
|
|
49
|
+
- [Function: getPluginManifest()](./docs/docs/api./docs/Function.getPluginManifest.md): Loads and validates the manifest from a plugin constructor.
|
|
50
|
+
- [Function: getResourceRequirements()](./docs/docs/api./docs/Function.getResourceRequirements.md): Gets the resource requirements from a plugin's manifest.
|
|
51
|
+
- [Function: getWorkspaceClient()](./docs/docs/api./docs/Function.getWorkspaceClient.md): Get workspace client from config or SDK default auth chain
|
|
42
52
|
- [Function: isSQLTypeMarker()](./docs/docs/api./docs/Function.isSQLTypeMarker.md): Type guard to check if a value is a SQL type marker
|
|
43
53
|
- [Interface: BasePluginConfig](./docs/docs/api./docs/Interface.BasePluginConfig.md): Base configuration interface for AppKit plugins
|
|
44
54
|
- [Interface: CacheConfig](./docs/docs/api./docs/Interface.CacheConfig.md): Configuration for caching
|
|
55
|
+
- [Interface: DatabaseCredential](./docs/docs/api./docs/Interface.DatabaseCredential.md): Database credentials with OAuth token for Postgres connection
|
|
56
|
+
- [Interface: GenerateDatabaseCredentialRequest](./docs/docs/api./docs/Interface.GenerateDatabaseCredentialRequest.md): Request parameters for generating database OAuth credentials
|
|
45
57
|
- [Interface: ITelemetry](./docs/docs/api./docs/Interface.ITelemetry.md): Plugin-facing interface for OpenTelemetry instrumentation.
|
|
58
|
+
- [Interface: LakebasePoolConfig](./docs/docs/api./docs/Interface.LakebasePoolConfig.md): Configuration for creating a Lakebase connection pool
|
|
59
|
+
- [Interface: PluginManifest](./docs/docs/api./docs/Interface.PluginManifest.md): Plugin manifest that declares metadata and resource requirements.
|
|
60
|
+
- [Interface: RequestedClaims](./docs/docs/api./docs/Interface.RequestedClaims.md): Optional claims for fine-grained Unity Catalog table permissions
|
|
61
|
+
- [Interface: RequestedResource](./docs/docs/api./docs/Interface.RequestedResource.md): Resource to request permissions for in Unity Catalog
|
|
62
|
+
- [Interface: ResourceEntry](./docs/docs/api./docs/Interface.ResourceEntry.md): Internal representation of a resource in the registry.
|
|
63
|
+
- [Interface: ResourceFieldEntry](./docs/docs/api./docs/Interface.ResourceFieldEntry.md): Defines a single field for a resource. Each field has its own environment variable and optional description.
|
|
64
|
+
- [Interface: ResourceRequirement](./docs/docs/api./docs/Interface.ResourceRequirement.md): Declares a resource requirement for a plugin.
|
|
46
65
|
- [Interface: StreamExecutionSettings](./docs/docs/api./docs/Interface.StreamExecutionSettings.md): Configuration for streaming execution with default and user-scoped settings
|
|
47
66
|
- [Interface: TelemetryConfig](./docs/docs/api./docs/Interface.TelemetryConfig.md): OpenTelemetry configuration for AppKit applications
|
|
67
|
+
- [Interface: ValidationResult](./docs/docs/api./docs/Interface.ValidationResult.md): Result of validating all registered resources against the environment.
|
|
68
|
+
- [Type Alias: ConfigSchema](./docs/docs/api./docs/TypeAlias.ConfigSchema.md): Configuration schema definition for plugin config.
|
|
48
69
|
- [Type Alias: IAppRouter](./docs/docs/api./docs/TypeAlias.IAppRouter.md): Express router type for plugin route registration
|
|
70
|
+
- [Type Alias: ResourcePermission](./docs/docs/api./docs/TypeAlias.ResourcePermission.md): Union of all possible permission levels across all resource types.
|
|
49
71
|
- [Variable: sql](./docs/docs/api./docs/Variable.sql.md): SQL helper namespace
|
|
50
72
|
- [@databricks/appkit-ui](./docs/docs/api/appkit-ui.md): The library provides a set of UI primitives for building Databricks apps in React.
|
|
51
73
|
- [AreaChart](./docs/docs/api/appkit-ui/data/AreaChart.md): Area Chart component for trend visualization with filled areas.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/appkit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"packageManager": "pnpm@10.21.0",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"postinstall": "node scripts/postinstall.js"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@databricks/
|
|
39
|
+
"@databricks/lakebase": "workspace:*",
|
|
40
|
+
"@databricks/sdk-experimental": "^0.16.0",
|
|
40
41
|
"@opentelemetry/api": "^1.9.0",
|
|
41
42
|
"@opentelemetry/api-logs": "^0.208.0",
|
|
42
43
|
"@opentelemetry/auto-instrumentations-node": "^0.67.0",
|
|
@@ -55,17 +56,20 @@
|
|
|
55
56
|
"dotenv": "^16.6.1",
|
|
56
57
|
"express": "^4.22.0",
|
|
57
58
|
"obug": "^2.1.1",
|
|
58
|
-
"pg": "^8.
|
|
59
|
+
"pg": "^8.18.0",
|
|
59
60
|
"semver": "^7.7.3",
|
|
60
61
|
"vite": "npm:rolldown-vite@7.1.14",
|
|
61
62
|
"ws": "^8.18.3",
|
|
62
63
|
"zod-to-ts": "^2.0.0",
|
|
63
64
|
"@ast-grep/napi": "^0.37.0",
|
|
65
|
+
"ajv": "^8.17.1",
|
|
66
|
+
"ajv-formats": "^3.0.1",
|
|
64
67
|
"commander": "^12.1.0"
|
|
65
68
|
},
|
|
66
69
|
"devDependencies": {
|
|
67
70
|
"@types/express": "^4.17.25",
|
|
68
|
-
"@types/
|
|
71
|
+
"@types/json-schema": "^7.0.15",
|
|
72
|
+
"@types/pg": "^8.16.0",
|
|
69
73
|
"@types/ws": "^8.18.1",
|
|
70
74
|
"@vitejs/plugin-react": "^5.1.1"
|
|
71
75
|
},
|
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import { __toCommonJS } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { createLogger } from "../../logging/logger.js";
|
|
3
|
-
import { TelemetryManager } from "../../telemetry/telemetry-manager.js";
|
|
4
|
-
import { SpanStatusCode } from "../../telemetry/index.js";
|
|
5
|
-
import { AppKitError } from "../../errors/base.js";
|
|
6
|
-
import { AuthenticationError } from "../../errors/authentication.js";
|
|
7
|
-
import { ConfigurationError } from "../../errors/configuration.js";
|
|
8
|
-
import { ConnectionError } from "../../errors/connection.js";
|
|
9
|
-
import { ValidationError } from "../../errors/validation.js";
|
|
10
|
-
import { init_errors } from "../../errors/index.js";
|
|
11
|
-
import { deepMerge } from "../../utils/merge.js";
|
|
12
|
-
import { lakebaseDefaults } from "./defaults.js";
|
|
13
|
-
import { context_exports, init_context } from "../../context/index.js";
|
|
14
|
-
import { randomUUID } from "node:crypto";
|
|
15
|
-
import { ApiClient, Config } from "@databricks/sdk-experimental";
|
|
16
|
-
import pg from "pg";
|
|
17
|
-
|
|
18
|
-
//#region src/connectors/lakebase/client.ts
|
|
19
|
-
init_errors();
|
|
20
|
-
const logger = createLogger("connectors:lakebase");
|
|
21
|
-
/**
|
|
22
|
-
* Enterprise-grade connector for Databricks Lakebase
|
|
23
|
-
* @example Simplest - everything from env/context
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const connector = new LakebaseConnector();
|
|
26
|
-
* await connector.query('SELECT * FROM users');
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @example With explicit connection string
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const connector = new LakebaseConnector({
|
|
32
|
-
* connectionString: 'postgresql://...'
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
var LakebaseConnector = class {
|
|
37
|
-
name = "lakebase";
|
|
38
|
-
CACHE_BUFFER_MS = 120 * 1e3;
|
|
39
|
-
config;
|
|
40
|
-
connectionConfig;
|
|
41
|
-
pool = null;
|
|
42
|
-
credentials = null;
|
|
43
|
-
telemetry;
|
|
44
|
-
telemetryMetrics;
|
|
45
|
-
constructor(userConfig) {
|
|
46
|
-
this.config = deepMerge(lakebaseDefaults, userConfig);
|
|
47
|
-
this.connectionConfig = this.parseConnectionConfig();
|
|
48
|
-
this.telemetry = TelemetryManager.getProvider(this.name, this.config.telemetry);
|
|
49
|
-
this.telemetryMetrics = {
|
|
50
|
-
queryCount: this.telemetry.getMeter().createCounter("lakebase.query.count", {
|
|
51
|
-
description: "Total number of queries executed",
|
|
52
|
-
unit: "1"
|
|
53
|
-
}),
|
|
54
|
-
queryDuration: this.telemetry.getMeter().createHistogram("lakebase.query.duration", {
|
|
55
|
-
description: "Duration of queries executed",
|
|
56
|
-
unit: "ms"
|
|
57
|
-
})
|
|
58
|
-
};
|
|
59
|
-
if (this.config.maxPoolSize < 1) throw ValidationError.invalidValue("maxPoolSize", this.config.maxPoolSize, "at least 1");
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Execute a SQL query
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* const users = await connector.query('SELECT * FROM users');
|
|
67
|
-
* const user = await connector.query('SELECT * FROM users WHERE id = $1', [123]);
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
async query(sql, params, retryCount = 0) {
|
|
71
|
-
const startTime = Date.now();
|
|
72
|
-
return this.telemetry.startActiveSpan("lakebase.query", { attributes: {
|
|
73
|
-
"db.system": "lakebase",
|
|
74
|
-
"db.statement": sql.substring(0, 500),
|
|
75
|
-
"db.retry_count": retryCount
|
|
76
|
-
} }, async (span) => {
|
|
77
|
-
try {
|
|
78
|
-
const result = await (await this.getPool()).query(sql, params);
|
|
79
|
-
span.setAttribute("db.rows_affected", result.rowCount ?? 0);
|
|
80
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
81
|
-
return result;
|
|
82
|
-
} catch (error) {
|
|
83
|
-
if (this.isAuthError(error)) {
|
|
84
|
-
span.addEvent("auth_error_retry");
|
|
85
|
-
await this.rotateCredentials();
|
|
86
|
-
const result = await (await this.getPool()).query(sql, params);
|
|
87
|
-
span.setAttribute("db.rows_affected", result.rowCount ?? 0);
|
|
88
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
89
|
-
return result;
|
|
90
|
-
}
|
|
91
|
-
if (this.isTransientError(error) && retryCount < 1) {
|
|
92
|
-
span.addEvent("transient_error_retry");
|
|
93
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
94
|
-
return await this.query(sql, params, retryCount + 1);
|
|
95
|
-
}
|
|
96
|
-
span.recordException(error);
|
|
97
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
98
|
-
if (error instanceof AppKitError) throw error;
|
|
99
|
-
throw ConnectionError.queryFailed(error);
|
|
100
|
-
} finally {
|
|
101
|
-
const duration = Date.now() - startTime;
|
|
102
|
-
this.telemetryMetrics.queryCount.add(1);
|
|
103
|
-
this.telemetryMetrics.queryDuration.record(duration);
|
|
104
|
-
span.end();
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Execute a transaction
|
|
110
|
-
*
|
|
111
|
-
* COMMIT and ROLLBACK are automatically managed by the transaction function.
|
|
112
|
-
*
|
|
113
|
-
* @param callback - Callback function to execute within the transaction context
|
|
114
|
-
* @example
|
|
115
|
-
* ```typescript
|
|
116
|
-
* await connector.transaction(async (client) => {
|
|
117
|
-
* await client.query('INSERT INTO accounts (name) VALUES ($1)', ['Alice']);
|
|
118
|
-
* await client.query('INSERT INTO logs (action) VALUES ($1)', ['Created Alice']);
|
|
119
|
-
* });
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
async transaction(callback, retryCount = 0) {
|
|
123
|
-
const startTime = Date.now();
|
|
124
|
-
return this.telemetry.startActiveSpan("lakebase.transaction", { attributes: {
|
|
125
|
-
"db.system": "lakebase",
|
|
126
|
-
"db.retry_count": retryCount
|
|
127
|
-
} }, async (span) => {
|
|
128
|
-
const client = await (await this.getPool()).connect();
|
|
129
|
-
try {
|
|
130
|
-
await client.query("BEGIN");
|
|
131
|
-
const result = await callback(client);
|
|
132
|
-
await client.query("COMMIT");
|
|
133
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
134
|
-
return result;
|
|
135
|
-
} catch (error) {
|
|
136
|
-
try {
|
|
137
|
-
await client.query("ROLLBACK");
|
|
138
|
-
} catch {}
|
|
139
|
-
if (this.isAuthError(error)) {
|
|
140
|
-
span.addEvent("auth_error_retry");
|
|
141
|
-
client.release();
|
|
142
|
-
await this.rotateCredentials();
|
|
143
|
-
const retryClient = await (await this.getPool()).connect();
|
|
144
|
-
try {
|
|
145
|
-
await client.query("BEGIN");
|
|
146
|
-
const result = await callback(retryClient);
|
|
147
|
-
await client.query("COMMIT");
|
|
148
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
149
|
-
return result;
|
|
150
|
-
} catch (retryError) {
|
|
151
|
-
try {
|
|
152
|
-
await retryClient.query("ROLLBACK");
|
|
153
|
-
} catch {}
|
|
154
|
-
throw retryError;
|
|
155
|
-
} finally {
|
|
156
|
-
retryClient.release();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (this.isTransientError(error) && retryCount < 1) {
|
|
160
|
-
span.addEvent("transaction_error_retry");
|
|
161
|
-
client.release();
|
|
162
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
163
|
-
return await this.transaction(callback, retryCount + 1);
|
|
164
|
-
}
|
|
165
|
-
span.recordException(error);
|
|
166
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
167
|
-
if (error instanceof AppKitError) throw error;
|
|
168
|
-
throw ConnectionError.transactionFailed(error);
|
|
169
|
-
} finally {
|
|
170
|
-
client.release();
|
|
171
|
-
const duration = Date.now() - startTime;
|
|
172
|
-
this.telemetryMetrics.queryCount.add(1);
|
|
173
|
-
this.telemetryMetrics.queryDuration.record(duration);
|
|
174
|
-
span.end();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
/** Check if database connection is healthy */
|
|
179
|
-
async healthCheck() {
|
|
180
|
-
return this.telemetry.startActiveSpan("lakebase.healthCheck", {}, async (span) => {
|
|
181
|
-
try {
|
|
182
|
-
const healthy = (await this.query("SELECT 1 as result")).rows[0]?.result === 1;
|
|
183
|
-
span.setAttribute("db.healthy", healthy);
|
|
184
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
185
|
-
return healthy;
|
|
186
|
-
} catch {
|
|
187
|
-
span.setAttribute("db.healthy", false);
|
|
188
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
189
|
-
return false;
|
|
190
|
-
} finally {
|
|
191
|
-
span.end();
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/** Close connection pool (call on shutdown) */
|
|
196
|
-
async close() {
|
|
197
|
-
if (this.pool) {
|
|
198
|
-
await this.pool.end().catch((error) => {
|
|
199
|
-
logger.error("Error closing connection pool: %O", error);
|
|
200
|
-
});
|
|
201
|
-
this.pool = null;
|
|
202
|
-
}
|
|
203
|
-
this.credentials = null;
|
|
204
|
-
}
|
|
205
|
-
/** Setup graceful shutdown to close connection pools */
|
|
206
|
-
shutdown() {
|
|
207
|
-
process.on("SIGTERM", () => this.close());
|
|
208
|
-
process.on("SIGINT", () => this.close());
|
|
209
|
-
this.close();
|
|
210
|
-
}
|
|
211
|
-
/** Get Databricks workspace client - from config or execution context */
|
|
212
|
-
getWorkspaceClient() {
|
|
213
|
-
if (this.config.workspaceClient) return this.config.workspaceClient;
|
|
214
|
-
try {
|
|
215
|
-
const { getWorkspaceClient: getClient } = (init_context(), __toCommonJS(context_exports));
|
|
216
|
-
const client = getClient();
|
|
217
|
-
this.config.workspaceClient = client;
|
|
218
|
-
return client;
|
|
219
|
-
} catch (_error) {
|
|
220
|
-
throw ConnectionError.clientUnavailable("Databricks workspace client", "Either pass it in config or ensure ServiceContext is initialized");
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/** Get or create connection pool */
|
|
224
|
-
async getPool() {
|
|
225
|
-
if (!this.connectionConfig) throw ConfigurationError.invalidConnection("Lakebase", "Set PGHOST, PGDATABASE, PGAPPNAME env vars, provide a connectionString, or pass explicit config");
|
|
226
|
-
if (!this.pool) {
|
|
227
|
-
const creds = await this.getCredentials();
|
|
228
|
-
this.pool = this.createPool(creds);
|
|
229
|
-
}
|
|
230
|
-
return this.pool;
|
|
231
|
-
}
|
|
232
|
-
/** Create PostgreSQL pool */
|
|
233
|
-
createPool(credentials) {
|
|
234
|
-
const { host, database, port, sslMode } = this.connectionConfig;
|
|
235
|
-
const pool = new pg.Pool({
|
|
236
|
-
host,
|
|
237
|
-
port,
|
|
238
|
-
database,
|
|
239
|
-
user: credentials.username,
|
|
240
|
-
password: credentials.password,
|
|
241
|
-
max: this.config.maxPoolSize,
|
|
242
|
-
idleTimeoutMillis: this.config.idleTimeoutMs,
|
|
243
|
-
connectionTimeoutMillis: this.config.connectionTimeoutMs,
|
|
244
|
-
ssl: sslMode === "require" ? { rejectUnauthorized: true } : false
|
|
245
|
-
});
|
|
246
|
-
pool.on("error", (error) => {
|
|
247
|
-
logger.error("Connection pool error: %s (code: %s)", error.message, error.code);
|
|
248
|
-
});
|
|
249
|
-
return pool;
|
|
250
|
-
}
|
|
251
|
-
/** Get or fetch credentials with caching */
|
|
252
|
-
async getCredentials() {
|
|
253
|
-
const now = Date.now();
|
|
254
|
-
if (this.credentials && now < this.credentials.expiresAt - this.CACHE_BUFFER_MS) return this.credentials;
|
|
255
|
-
const username = await this.fetchUsername();
|
|
256
|
-
const { token, expiresAt } = await this.fetchPassword();
|
|
257
|
-
this.credentials = {
|
|
258
|
-
username,
|
|
259
|
-
password: token,
|
|
260
|
-
expiresAt
|
|
261
|
-
};
|
|
262
|
-
return {
|
|
263
|
-
username,
|
|
264
|
-
password: token
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/** Rotate credentials and recreate pool */
|
|
268
|
-
async rotateCredentials() {
|
|
269
|
-
this.credentials = null;
|
|
270
|
-
if (this.pool) {
|
|
271
|
-
const oldPool = this.pool;
|
|
272
|
-
this.pool = null;
|
|
273
|
-
oldPool.end().catch((error) => {
|
|
274
|
-
logger.error("Error closing old connection pool during rotation: %O", error);
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
/** Fetch username from Databricks */
|
|
279
|
-
async fetchUsername() {
|
|
280
|
-
const user = await this.getWorkspaceClient().currentUser.me();
|
|
281
|
-
if (!user.userName) throw AuthenticationError.userLookupFailed();
|
|
282
|
-
return user.userName;
|
|
283
|
-
}
|
|
284
|
-
/** Fetch password (OAuth token) from Databricks */
|
|
285
|
-
async fetchPassword() {
|
|
286
|
-
const apiClient = new ApiClient(new Config({ host: this.getWorkspaceClient().config.host }));
|
|
287
|
-
if (!this.connectionConfig.appName) throw ConfigurationError.resourceNotFound("Database app name");
|
|
288
|
-
const credentials = await apiClient.request({
|
|
289
|
-
path: `/api/2.0/database/credentials`,
|
|
290
|
-
method: "POST",
|
|
291
|
-
headers: new Headers(),
|
|
292
|
-
raw: false,
|
|
293
|
-
payload: {
|
|
294
|
-
instance_names: [this.connectionConfig.appName],
|
|
295
|
-
request_id: randomUUID()
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
if (!this.validateCredentials(credentials)) throw AuthenticationError.credentialsFailed(this.connectionConfig.appName);
|
|
299
|
-
const expiresAt = new Date(credentials.expiration_time).getTime();
|
|
300
|
-
return {
|
|
301
|
-
token: credentials.token,
|
|
302
|
-
expiresAt
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
/** Check if error is auth failure */
|
|
306
|
-
isAuthError(error) {
|
|
307
|
-
return typeof error === "object" && error !== null && "code" in error && error.code === "28P01";
|
|
308
|
-
}
|
|
309
|
-
/** Check if error is transient */
|
|
310
|
-
isTransientError(error) {
|
|
311
|
-
if (typeof error !== "object" || error === null || !("code" in error)) return false;
|
|
312
|
-
const code = error.code;
|
|
313
|
-
return code === "ECONNRESET" || code === "ECONNREFUSED" || code === "ETIMEDOUT" || code === "57P01" || code === "57P03" || code === "08006" || code === "08003" || code === "08000";
|
|
314
|
-
}
|
|
315
|
-
/** Type guard for credentials */
|
|
316
|
-
validateCredentials(value) {
|
|
317
|
-
if (typeof value !== "object" || value === null) return false;
|
|
318
|
-
const credentials = value;
|
|
319
|
-
return "token" in credentials && typeof credentials.token === "string" && "expiration_time" in credentials && typeof credentials.expiration_time === "string" && new Date(credentials.expiration_time).getTime() > Date.now();
|
|
320
|
-
}
|
|
321
|
-
/** Parse connection configuration from config or environment */
|
|
322
|
-
parseConnectionConfig() {
|
|
323
|
-
if (this.config.connectionString) return this.parseConnectionString(this.config.connectionString);
|
|
324
|
-
if (this.config.host && this.config.database && this.config.appName) return {
|
|
325
|
-
host: this.config.host,
|
|
326
|
-
database: this.config.database,
|
|
327
|
-
port: this.config.port ?? 5432,
|
|
328
|
-
sslMode: this.config.sslMode ?? "require",
|
|
329
|
-
appName: this.config.appName
|
|
330
|
-
};
|
|
331
|
-
const pgHost = process.env.PGHOST;
|
|
332
|
-
const pgDatabase = process.env.PGDATABASE;
|
|
333
|
-
const pgAppName = process.env.PGAPPNAME;
|
|
334
|
-
if (!pgHost || !pgDatabase || !pgAppName) throw ConfigurationError.invalidConnection("Lakebase", "Required env vars: PGHOST, PGDATABASE, PGAPPNAME. Optional: PGPORT (default: 5432), PGSSLMODE (default: require)");
|
|
335
|
-
const pgPort = process.env.PGPORT;
|
|
336
|
-
const port = pgPort ? parseInt(pgPort, 10) : 5432;
|
|
337
|
-
if (Number.isNaN(port)) throw ValidationError.invalidValue("port", pgPort, "a number");
|
|
338
|
-
return {
|
|
339
|
-
host: pgHost,
|
|
340
|
-
database: pgDatabase,
|
|
341
|
-
port,
|
|
342
|
-
sslMode: process.env.PGSSLMODE || "require",
|
|
343
|
-
appName: pgAppName
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
parseConnectionString(connectionString) {
|
|
347
|
-
const url = new URL(connectionString);
|
|
348
|
-
const appName = url.searchParams.get("appName");
|
|
349
|
-
if (!appName) throw ConfigurationError.missingConnectionParam("appName");
|
|
350
|
-
return {
|
|
351
|
-
host: url.hostname,
|
|
352
|
-
database: url.pathname.slice(1),
|
|
353
|
-
port: url.port ? parseInt(url.port, 10) : 5432,
|
|
354
|
-
sslMode: url.searchParams.get("sslmode") ?? "require",
|
|
355
|
-
appName
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
//#endregion
|
|
361
|
-
export { LakebaseConnector };
|
|
362
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../../src/connectors/lakebase/client.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { WorkspaceClient } from \"@databricks/sdk-experimental\";\nimport { ApiClient, Config } from \"@databricks/sdk-experimental\";\nimport pg from \"pg\";\nimport {\n type Counter,\n type Histogram,\n SpanStatusCode,\n TelemetryManager,\n type TelemetryProvider,\n} from \"@/telemetry\";\nimport {\n AppKitError,\n AuthenticationError,\n ConfigurationError,\n ConnectionError,\n ValidationError,\n} from \"../../errors\";\nimport { createLogger } from \"../../logging/logger\";\nimport { deepMerge } from \"../../utils\";\nimport { lakebaseDefaults } from \"./defaults\";\nimport type {\n LakebaseConfig,\n LakebaseConnectionConfig,\n LakebaseCredentials,\n} from \"./types\";\n\nconst logger = createLogger(\"connectors:lakebase\");\n\n/**\n * Enterprise-grade connector for Databricks Lakebase\n * @example Simplest - everything from env/context\n * ```typescript\n * const connector = new LakebaseConnector();\n * await connector.query('SELECT * FROM users');\n * ```\n *\n * @example With explicit connection string\n * ```typescript\n * const connector = new LakebaseConnector({\n * connectionString: 'postgresql://...'\n * });\n * ```\n */\nexport class LakebaseConnector {\n private readonly name: string = \"lakebase\";\n private readonly CACHE_BUFFER_MS = 2 * 60 * 1000;\n private readonly config: LakebaseConfig;\n private readonly connectionConfig: LakebaseConnectionConfig;\n private pool: pg.Pool | null = null;\n private credentials: LakebaseCredentials | null = null;\n\n // telemetry\n private readonly telemetry: TelemetryProvider;\n private readonly telemetryMetrics: {\n queryCount: Counter;\n queryDuration: Histogram;\n };\n\n constructor(userConfig?: Partial<LakebaseConfig>) {\n this.config = deepMerge(lakebaseDefaults, userConfig);\n this.connectionConfig = this.parseConnectionConfig();\n\n this.telemetry = TelemetryManager.getProvider(\n this.name,\n this.config.telemetry,\n );\n this.telemetryMetrics = {\n queryCount: this.telemetry\n .getMeter()\n .createCounter(\"lakebase.query.count\", {\n description: \"Total number of queries executed\",\n unit: \"1\",\n }),\n queryDuration: this.telemetry\n .getMeter()\n .createHistogram(\"lakebase.query.duration\", {\n description: \"Duration of queries executed\",\n unit: \"ms\",\n }),\n };\n\n // validate configuration\n if (this.config.maxPoolSize < 1) {\n throw ValidationError.invalidValue(\n \"maxPoolSize\",\n this.config.maxPoolSize,\n \"at least 1\",\n );\n }\n }\n\n /**\n * Execute a SQL query\n *\n * @example\n * ```typescript\n * const users = await connector.query('SELECT * FROM users');\n * const user = await connector.query('SELECT * FROM users WHERE id = $1', [123]);\n * ```\n */\n async query<T extends pg.QueryResultRow>(\n sql: string,\n params?: any[],\n retryCount: number = 0,\n ): Promise<pg.QueryResult<T>> {\n const startTime = Date.now();\n\n return this.telemetry.startActiveSpan(\n \"lakebase.query\",\n {\n attributes: {\n \"db.system\": \"lakebase\",\n \"db.statement\": sql.substring(0, 500),\n \"db.retry_count\": retryCount,\n },\n },\n async (span) => {\n try {\n const pool = await this.getPool();\n const result = await pool.query<T>(sql, params);\n span.setAttribute(\"db.rows_affected\", result.rowCount ?? 0);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n // retry on auth failure\n if (this.isAuthError(error)) {\n span.addEvent(\"auth_error_retry\");\n await this.rotateCredentials();\n const newPool = await this.getPool();\n const result = await newPool.query<T>(sql, params);\n span.setAttribute(\"db.rows_affected\", result.rowCount ?? 0);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n }\n\n // retry on transient errors, but only once\n if (this.isTransientError(error) && retryCount < 1) {\n span.addEvent(\"transient_error_retry\");\n await new Promise((resolve) => setTimeout(resolve, 100));\n return await this.query<T>(sql, params, retryCount + 1);\n }\n\n span.recordException(error as Error);\n span.setStatus({ code: SpanStatusCode.ERROR });\n\n if (error instanceof AppKitError) {\n throw error;\n }\n throw ConnectionError.queryFailed(error as Error);\n } finally {\n const duration = Date.now() - startTime;\n this.telemetryMetrics.queryCount.add(1);\n this.telemetryMetrics.queryDuration.record(duration);\n span.end();\n }\n },\n );\n }\n\n /**\n * Execute a transaction\n *\n * COMMIT and ROLLBACK are automatically managed by the transaction function.\n *\n * @param callback - Callback function to execute within the transaction context\n * @example\n * ```typescript\n * await connector.transaction(async (client) => {\n * await client.query('INSERT INTO accounts (name) VALUES ($1)', ['Alice']);\n * await client.query('INSERT INTO logs (action) VALUES ($1)', ['Created Alice']);\n * });\n * ```\n */\n async transaction<T>(\n callback: (client: pg.PoolClient) => Promise<T>,\n retryCount: number = 0,\n ): Promise<T> {\n const startTime = Date.now();\n return this.telemetry.startActiveSpan(\n \"lakebase.transaction\",\n {\n attributes: {\n \"db.system\": \"lakebase\",\n \"db.retry_count\": retryCount,\n },\n },\n async (span) => {\n const pool = await this.getPool();\n const client = await pool.connect();\n try {\n await client.query(\"BEGIN\");\n const result = await callback(client);\n await client.query(\"COMMIT\");\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n try {\n await client.query(\"ROLLBACK\");\n } catch {}\n // retry on auth failure\n if (this.isAuthError(error)) {\n span.addEvent(\"auth_error_retry\");\n client.release();\n await this.rotateCredentials();\n const newPool = await this.getPool();\n const retryClient = await newPool.connect();\n try {\n await client.query(\"BEGIN\");\n const result = await callback(retryClient);\n await client.query(\"COMMIT\");\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (retryError) {\n try {\n await retryClient.query(\"ROLLBACK\");\n } catch {}\n throw retryError;\n } finally {\n retryClient.release();\n }\n }\n\n // retry on transient errors, but only once\n if (this.isTransientError(error) && retryCount < 1) {\n span.addEvent(\"transaction_error_retry\");\n client.release();\n await new Promise((resolve) => setTimeout(resolve, 100));\n return await this.transaction<T>(callback, retryCount + 1);\n }\n span.recordException(error as Error);\n span.setStatus({ code: SpanStatusCode.ERROR });\n\n if (error instanceof AppKitError) {\n throw error;\n }\n throw ConnectionError.transactionFailed(error as Error);\n } finally {\n client.release();\n const duration = Date.now() - startTime;\n this.telemetryMetrics.queryCount.add(1);\n this.telemetryMetrics.queryDuration.record(duration);\n span.end();\n }\n },\n );\n }\n\n /** Check if database connection is healthy */\n async healthCheck(): Promise<boolean> {\n return this.telemetry.startActiveSpan(\n \"lakebase.healthCheck\",\n {},\n async (span) => {\n try {\n const result = await this.query<{ result: number }>(\n \"SELECT 1 as result\",\n );\n const healthy = result.rows[0]?.result === 1;\n span.setAttribute(\"db.healthy\", healthy);\n span.setStatus({ code: SpanStatusCode.OK });\n return healthy;\n } catch {\n span.setAttribute(\"db.healthy\", false);\n span.setStatus({ code: SpanStatusCode.ERROR });\n return false;\n } finally {\n span.end();\n }\n },\n );\n }\n\n /** Close connection pool (call on shutdown) */\n async close(): Promise<void> {\n if (this.pool) {\n await this.pool.end().catch((error: unknown) => {\n logger.error(\"Error closing connection pool: %O\", error);\n });\n this.pool = null;\n }\n this.credentials = null;\n }\n\n /** Setup graceful shutdown to close connection pools */\n shutdown(): void {\n process.on(\"SIGTERM\", () => this.close());\n process.on(\"SIGINT\", () => this.close());\n this.close();\n }\n\n /** Get Databricks workspace client - from config or execution context */\n private getWorkspaceClient(): WorkspaceClient {\n if (this.config.workspaceClient) {\n return this.config.workspaceClient;\n }\n\n try {\n const { getWorkspaceClient: getClient } = require(\"../../context\");\n const client = getClient();\n\n // cache it for subsequent calls\n this.config.workspaceClient = client;\n return client;\n } catch (_error) {\n throw ConnectionError.clientUnavailable(\n \"Databricks workspace client\",\n \"Either pass it in config or ensure ServiceContext is initialized\",\n );\n }\n }\n\n /** Get or create connection pool */\n private async getPool(): Promise<pg.Pool> {\n if (!this.connectionConfig) {\n throw ConfigurationError.invalidConnection(\n \"Lakebase\",\n \"Set PGHOST, PGDATABASE, PGAPPNAME env vars, provide a connectionString, or pass explicit config\",\n );\n }\n\n if (!this.pool) {\n const creds = await this.getCredentials();\n this.pool = this.createPool(creds);\n }\n return this.pool;\n }\n\n /** Create PostgreSQL pool */\n private createPool(credentials: {\n username: string;\n password: string;\n }): pg.Pool {\n const { host, database, port, sslMode } = this.connectionConfig;\n\n const pool = new pg.Pool({\n host,\n port,\n database,\n user: credentials.username,\n password: credentials.password,\n max: this.config.maxPoolSize,\n idleTimeoutMillis: this.config.idleTimeoutMs,\n connectionTimeoutMillis: this.config.connectionTimeoutMs,\n ssl: sslMode === \"require\" ? { rejectUnauthorized: true } : false,\n });\n\n pool.on(\"error\", (error: Error & { code?: string }) => {\n logger.error(\n \"Connection pool error: %s (code: %s)\",\n error.message,\n error.code,\n );\n });\n\n return pool;\n }\n\n /** Get or fetch credentials with caching */\n private async getCredentials(): Promise<{\n username: string;\n password: string;\n }> {\n const now = Date.now();\n\n // return cached if still valid\n if (\n this.credentials &&\n now < this.credentials.expiresAt - this.CACHE_BUFFER_MS\n ) {\n return this.credentials;\n }\n\n // fetch new credentials\n const username = await this.fetchUsername();\n const { token, expiresAt } = await this.fetchPassword();\n\n this.credentials = {\n username,\n password: token,\n expiresAt,\n };\n\n return { username, password: token };\n }\n\n /** Rotate credentials and recreate pool */\n private async rotateCredentials(): Promise<void> {\n // clear cached credentials\n this.credentials = null;\n\n if (this.pool) {\n const oldPool = this.pool;\n this.pool = null;\n oldPool.end().catch((error: unknown) => {\n logger.error(\n \"Error closing old connection pool during rotation: %O\",\n error,\n );\n });\n }\n }\n\n /** Fetch username from Databricks */\n private async fetchUsername(): Promise<string> {\n const workspaceClient = this.getWorkspaceClient();\n const user = await workspaceClient.currentUser.me();\n if (!user.userName) {\n throw AuthenticationError.userLookupFailed();\n }\n return user.userName;\n }\n\n /** Fetch password (OAuth token) from Databricks */\n private async fetchPassword(): Promise<{ token: string; expiresAt: number }> {\n const workspaceClient = this.getWorkspaceClient();\n const config = new Config({ host: workspaceClient.config.host });\n const apiClient = new ApiClient(config);\n\n if (!this.connectionConfig.appName) {\n throw ConfigurationError.resourceNotFound(\"Database app name\");\n }\n\n const credentials = await apiClient.request({\n path: `/api/2.0/database/credentials`,\n method: \"POST\",\n headers: new Headers(),\n raw: false,\n payload: {\n instance_names: [this.connectionConfig.appName],\n request_id: randomUUID(),\n },\n });\n\n if (!this.validateCredentials(credentials)) {\n throw AuthenticationError.credentialsFailed(\n this.connectionConfig.appName,\n );\n }\n\n const expiresAt = new Date(credentials.expiration_time).getTime();\n\n return { token: credentials.token, expiresAt };\n }\n\n /** Check if error is auth failure */\n private isAuthError(error: unknown): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n (error as any).code === \"28P01\"\n );\n }\n\n /** Check if error is transient */\n private isTransientError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return false;\n }\n\n const code = (error as any).code;\n return (\n code === \"ECONNRESET\" ||\n code === \"ECONNREFUSED\" ||\n code === \"ETIMEDOUT\" ||\n code === \"57P01\" || // admin_shutdown\n code === \"57P03\" || // cannot_connect_now\n code === \"08006\" || // connection_failure\n code === \"08003\" || // connection_does_not_exist\n code === \"08000\" // connection_exception\n );\n }\n\n /** Type guard for credentials */\n private validateCredentials(\n value: unknown,\n ): value is { token: string; expiration_time: string } {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const credentials = value as { token: string; expiration_time: string };\n return (\n \"token\" in credentials &&\n typeof credentials.token === \"string\" &&\n \"expiration_time\" in credentials &&\n typeof credentials.expiration_time === \"string\" &&\n new Date(credentials.expiration_time).getTime() > Date.now()\n );\n }\n\n /** Parse connection configuration from config or environment */\n private parseConnectionConfig(): LakebaseConnectionConfig {\n if (this.config.connectionString) {\n return this.parseConnectionString(this.config.connectionString);\n }\n\n // get connection from config\n if (this.config.host && this.config.database && this.config.appName) {\n return {\n host: this.config.host,\n database: this.config.database,\n port: this.config.port ?? 5432,\n sslMode: this.config.sslMode ?? \"require\",\n appName: this.config.appName,\n };\n }\n\n // get connection from environment variables\n const pgHost = process.env.PGHOST;\n const pgDatabase = process.env.PGDATABASE;\n const pgAppName = process.env.PGAPPNAME;\n if (!pgHost || !pgDatabase || !pgAppName) {\n throw ConfigurationError.invalidConnection(\n \"Lakebase\",\n \"Required env vars: PGHOST, PGDATABASE, PGAPPNAME. Optional: PGPORT (default: 5432), PGSSLMODE (default: require)\",\n );\n }\n const pgPort = process.env.PGPORT;\n const port = pgPort ? parseInt(pgPort, 10) : 5432;\n\n if (Number.isNaN(port)) {\n throw ValidationError.invalidValue(\"port\", pgPort, \"a number\");\n }\n\n const pgSSLMode = process.env.PGSSLMODE;\n const sslMode =\n (pgSSLMode as \"require\" | \"disable\" | \"prefer\") || \"require\";\n\n return {\n host: pgHost,\n database: pgDatabase,\n port,\n sslMode,\n appName: pgAppName,\n };\n }\n\n private parseConnectionString(\n connectionString: string,\n ): LakebaseConnectionConfig {\n const url = new URL(connectionString);\n const appName = url.searchParams.get(\"appName\");\n if (!appName) {\n throw ConfigurationError.missingConnectionParam(\"appName\");\n }\n\n return {\n host: url.hostname,\n database: url.pathname.slice(1), // remove leading slash\n port: url.port ? parseInt(url.port, 10) : 5432,\n sslMode:\n (url.searchParams.get(\"sslmode\") as \"require\" | \"disable\" | \"prefer\") ??\n \"require\",\n appName: appName,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;aAiBsB;AAUtB,MAAM,SAAS,aAAa,sBAAsB;;;;;;;;;;;;;;;;AAiBlD,IAAa,oBAAb,MAA+B;CAC7B,AAAiB,OAAe;CAChC,AAAiB,kBAAkB,MAAS;CAC5C,AAAiB;CACjB,AAAiB;CACjB,AAAQ,OAAuB;CAC/B,AAAQ,cAA0C;CAGlD,AAAiB;CACjB,AAAiB;CAKjB,YAAY,YAAsC;AAChD,OAAK,SAAS,UAAU,kBAAkB,WAAW;AACrD,OAAK,mBAAmB,KAAK,uBAAuB;AAEpD,OAAK,YAAY,iBAAiB,YAChC,KAAK,MACL,KAAK,OAAO,UACb;AACD,OAAK,mBAAmB;GACtB,YAAY,KAAK,UACd,UAAU,CACV,cAAc,wBA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AAK,OAAO,QAC1D,QAAO;GACL,MAAM,KAAK,OAAO;GAClB,UAAU,KAAK,OAAO;GACtB,MAAM,KAAK,OAAO,QAAQ;GAC1B,SAAS,KAAK,OAAO,WAAW;GAChC,SAAS,KAAK,OAAO;GACtB;EAIH,MAAM,SAAS,QAAQ,IAAI;EAC3B,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,YAAY,QAAQ,IAAI;AAC9B,MAAI,CAAC,UAAU,CAAC,cAAc,CAAC,UAC7B,OAAM,mBAAmB,kBACvB,YACA,mHACD;EAEH,MAAM,SAAS,QAAQ,IAAI;EAC3B,MAAM,OAAO,SAAS,SAAS,QAAQ,GAAG,GAAG;AAE7C,MAAI,OAAO,MAAM,KAAK,CACpB,OAAM,gBAAgB,aAAa,QAAQ,QAAQ,WAAW;AAOhE,SAAO;GACL,MAAM;GACN,UAAU;GACV;GACA,SARgB,QAAQ,IAAI,aAEuB;GAOnD,SAAS;GACV;;CAGH,AAAQ,sBACN,kBAC0B;EAC1B,MAAM,MAAM,IAAI,IAAI,iBAAiB;EACrC,MAAM,UAAU,IAAI,aAAa,IAAI,UAAU;AAC/C,MAAI,CAAC,QACH,OAAM,mBAAmB,uBAAuB,UAAU;AAG5D,SAAO;GACL,MAAM,IAAI;GACV,UAAU,IAAI,SAAS,MAAM,EAAE;GAC/B,MAAM,IAAI,OAAO,SAAS,IAAI,MAAM,GAAG,GAAG;GAC1C,SACG,IAAI,aAAa,IAAI,UAAU,IAChC;GACO;GACV"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/connectors/lakebase/defaults.ts
|
|
2
|
-
/** Default configuration for Lakebase connector */
|
|
3
|
-
const lakebaseDefaults = {
|
|
4
|
-
port: 5432,
|
|
5
|
-
sslMode: "require",
|
|
6
|
-
maxPoolSize: 10,
|
|
7
|
-
idleTimeoutMs: 3e4,
|
|
8
|
-
connectionTimeoutMs: 1e4
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { lakebaseDefaults };
|
|
13
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","names":[],"sources":["../../../src/connectors/lakebase/defaults.ts"],"sourcesContent":["import type { LakebaseConfig } from \"./types\";\n\n/** Default configuration for Lakebase connector */\nexport const lakebaseDefaults: LakebaseConfig = {\n port: 5432,\n sslMode: \"require\",\n maxPoolSize: 10,\n idleTimeoutMs: 30_000,\n connectionTimeoutMs: 10_000,\n};\n"],"mappings":";;AAGA,MAAa,mBAAmC;CAC9C,MAAM;CACN,SAAS;CACT,aAAa;CACb,eAAe;CACf,qBAAqB;CACtB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/validation.js";
|
|
2
|
-
import { init_errors } from "../errors/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/env-validator.ts
|
|
5
|
-
init_errors();
|
|
6
|
-
function validateEnv(envVars) {
|
|
7
|
-
const missingVars = [];
|
|
8
|
-
for (const envVar of envVars) if (!process.env[envVar]) missingVars.push(envVar);
|
|
9
|
-
if (missingVars.length > 0) throw ValidationError.missingEnvVars(missingVars);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { validateEnv };
|
|
14
|
-
//# sourceMappingURL=env-validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-validator.js","names":[],"sources":["../../src/utils/env-validator.ts"],"sourcesContent":["import { ValidationError } from \"../errors\";\n\nexport function validateEnv(envVars: string[]) {\n const missingVars = [];\n\n for (const envVar of envVars) {\n if (!process.env[envVar]) {\n missingVars.push(envVar);\n }\n }\n\n if (missingVars.length > 0) {\n throw ValidationError.missingEnvVars(missingVars);\n }\n}\n"],"mappings":";;;;aAA4C;AAE5C,SAAgB,YAAY,SAAmB;CAC7C,MAAM,cAAc,EAAE;AAEtB,MAAK,MAAM,UAAU,QACnB,KAAI,CAAC,QAAQ,IAAI,QACf,aAAY,KAAK,OAAO;AAI5B,KAAI,YAAY,SAAS,EACvB,OAAM,gBAAgB,eAAe,YAAY"}
|