@databricks/appkit 0.10.1 → 0.11.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.
Files changed (164) hide show
  1. package/CLAUDE.md +7 -0
  2. package/dist/appkit/package.js +1 -1
  3. package/dist/cli/commands/plugin/sync/sync.js +6 -3
  4. package/dist/cli/commands/plugin/sync/sync.js.map +1 -1
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.js +2 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/plugins/index.js +3 -0
  9. package/dist/plugins/lakebase/index.js +4 -0
  10. package/dist/plugins/lakebase/lakebase.d.ts +117 -0
  11. package/dist/plugins/lakebase/lakebase.d.ts.map +1 -0
  12. package/dist/plugins/lakebase/lakebase.js +108 -0
  13. package/dist/plugins/lakebase/lakebase.js.map +1 -0
  14. package/dist/plugins/lakebase/manifest.js +11 -0
  15. package/dist/plugins/lakebase/manifest.js.map +1 -0
  16. package/dist/plugins/lakebase/manifest.json +11 -0
  17. package/dist/plugins/lakebase/types.d.ts +25 -0
  18. package/dist/plugins/lakebase/types.d.ts.map +1 -0
  19. package/dist/schemas/plugin-manifest.schema.json +4 -0
  20. package/dist/schemas/template-plugins.schema.json +4 -0
  21. package/dist/shared/src/plugin.d.ts +1 -0
  22. package/dist/shared/src/plugin.d.ts.map +1 -1
  23. package/docs/docs/api/appkit/Class.AppKitError/index.html +3 -3
  24. package/docs/docs/api/appkit/Class.AuthenticationError/index.html +3 -3
  25. package/docs/docs/api/appkit/Class.ConfigurationError/index.html +3 -3
  26. package/docs/docs/api/appkit/Class.ConnectionError/index.html +3 -3
  27. package/docs/docs/api/appkit/Class.ExecutionError/index.html +3 -3
  28. package/docs/docs/api/appkit/Class.InitializationError/index.html +3 -3
  29. package/docs/docs/api/appkit/Class.Plugin/index.html +3 -3
  30. package/docs/docs/api/appkit/Class.ResourceRegistry/index.html +3 -3
  31. package/docs/docs/api/appkit/Class.ServerError/index.html +3 -3
  32. package/docs/docs/api/appkit/Class.TunnelError/index.html +3 -3
  33. package/docs/docs/api/appkit/Class.ValidationError/index.html +3 -3
  34. package/docs/docs/api/appkit/Enumeration.RequestedClaimsPermissionSet/index.html +3 -3
  35. package/docs/docs/api/appkit/Enumeration.ResourceType/index.html +3 -3
  36. package/docs/docs/api/appkit/Function.appKitTypesPlugin/index.html +3 -3
  37. package/docs/docs/api/appkit/Function.createApp/index.html +3 -3
  38. package/docs/docs/api/appkit/Function.createLakebasePool/index.html +3 -3
  39. package/docs/docs/api/appkit/Function.generateDatabaseCredential/index.html +3 -3
  40. package/docs/docs/api/appkit/Function.getExecutionContext/index.html +3 -3
  41. package/docs/docs/api/appkit/Function.getLakebaseOrmConfig/index.html +3 -3
  42. package/docs/docs/api/appkit/Function.getLakebasePgConfig/index.html +3 -3
  43. package/docs/docs/api/appkit/Function.getPluginManifest/index.html +3 -3
  44. package/docs/docs/api/appkit/Function.getResourceRequirements/index.html +3 -3
  45. package/docs/docs/api/appkit/Function.getUsernameWithApiLookup/index.html +3 -3
  46. package/docs/docs/api/appkit/Function.getWorkspaceClient/index.html +3 -3
  47. package/docs/docs/api/appkit/Function.isSQLTypeMarker/index.html +3 -3
  48. package/docs/docs/api/appkit/Interface.BasePluginConfig/index.html +3 -3
  49. package/docs/docs/api/appkit/Interface.CacheConfig/index.html +3 -3
  50. package/docs/docs/api/appkit/Interface.DatabaseCredential/index.html +3 -3
  51. package/docs/docs/api/appkit/Interface.GenerateDatabaseCredentialRequest/index.html +3 -3
  52. package/docs/docs/api/appkit/Interface.ITelemetry/index.html +3 -3
  53. package/docs/docs/api/appkit/Interface.LakebasePoolConfig/index.html +3 -3
  54. package/docs/docs/api/appkit/Interface.PluginManifest/index.html +3 -3
  55. package/docs/docs/api/appkit/Interface.RequestedClaims/index.html +3 -3
  56. package/docs/docs/api/appkit/Interface.RequestedResource/index.html +3 -3
  57. package/docs/docs/api/appkit/Interface.ResourceEntry/index.html +3 -3
  58. package/docs/docs/api/appkit/Interface.ResourceFieldEntry/index.html +3 -3
  59. package/docs/docs/api/appkit/Interface.ResourceRequirement/index.html +3 -3
  60. package/docs/docs/api/appkit/Interface.StreamExecutionSettings/index.html +3 -3
  61. package/docs/docs/api/appkit/Interface.TelemetryConfig/index.html +3 -3
  62. package/docs/docs/api/appkit/Interface.ValidationResult/index.html +3 -3
  63. package/docs/docs/api/appkit/TypeAlias.ConfigSchema/index.html +3 -3
  64. package/docs/docs/api/appkit/TypeAlias.IAppRouter/index.html +3 -3
  65. package/docs/docs/api/appkit/TypeAlias.ResourcePermission/index.html +3 -3
  66. package/docs/docs/api/appkit/TypeAlias.ToPlugin/index.html +3 -3
  67. package/docs/docs/api/appkit/Variable.sql/index.html +3 -3
  68. package/docs/docs/api/appkit/index.html +3 -3
  69. package/docs/docs/api/appkit-ui/data/AreaChart/index.html +3 -3
  70. package/docs/docs/api/appkit-ui/data/BarChart/index.html +3 -3
  71. package/docs/docs/api/appkit-ui/data/DataTable/index.html +3 -3
  72. package/docs/docs/api/appkit-ui/data/DonutChart/index.html +3 -3
  73. package/docs/docs/api/appkit-ui/data/HeatmapChart/index.html +3 -3
  74. package/docs/docs/api/appkit-ui/data/LineChart/index.html +3 -3
  75. package/docs/docs/api/appkit-ui/data/PieChart/index.html +3 -3
  76. package/docs/docs/api/appkit-ui/data/RadarChart/index.html +3 -3
  77. package/docs/docs/api/appkit-ui/data/ScatterChart/index.html +3 -3
  78. package/docs/docs/api/appkit-ui/index.html +3 -3
  79. package/docs/docs/api/appkit-ui/styling/index.html +3 -3
  80. package/docs/docs/api/appkit-ui/ui/Accordion/index.html +3 -3
  81. package/docs/docs/api/appkit-ui/ui/Alert/index.html +3 -3
  82. package/docs/docs/api/appkit-ui/ui/AlertDialog/index.html +3 -3
  83. package/docs/docs/api/appkit-ui/ui/AspectRatio/index.html +3 -3
  84. package/docs/docs/api/appkit-ui/ui/Avatar/index.html +3 -3
  85. package/docs/docs/api/appkit-ui/ui/Badge/index.html +3 -3
  86. package/docs/docs/api/appkit-ui/ui/Breadcrumb/index.html +3 -3
  87. package/docs/docs/api/appkit-ui/ui/Button/index.html +3 -3
  88. package/docs/docs/api/appkit-ui/ui/ButtonGroup/index.html +3 -3
  89. package/docs/docs/api/appkit-ui/ui/Calendar/index.html +3 -3
  90. package/docs/docs/api/appkit-ui/ui/Card/index.html +3 -3
  91. package/docs/docs/api/appkit-ui/ui/Carousel/index.html +3 -3
  92. package/docs/docs/api/appkit-ui/ui/ChartContainer/index.html +3 -3
  93. package/docs/docs/api/appkit-ui/ui/Checkbox/index.html +3 -3
  94. package/docs/docs/api/appkit-ui/ui/Collapsible/index.html +3 -3
  95. package/docs/docs/api/appkit-ui/ui/Command/index.html +3 -3
  96. package/docs/docs/api/appkit-ui/ui/ContextMenu/index.html +3 -3
  97. package/docs/docs/api/appkit-ui/ui/Dialog/index.html +3 -3
  98. package/docs/docs/api/appkit-ui/ui/Drawer/index.html +3 -3
  99. package/docs/docs/api/appkit-ui/ui/DropdownMenu/index.html +3 -3
  100. package/docs/docs/api/appkit-ui/ui/Empty/index.html +3 -3
  101. package/docs/docs/api/appkit-ui/ui/Field/index.html +3 -3
  102. package/docs/docs/api/appkit-ui/ui/FormControl/index.html +3 -3
  103. package/docs/docs/api/appkit-ui/ui/HoverCard/index.html +3 -3
  104. package/docs/docs/api/appkit-ui/ui/Input/index.html +3 -3
  105. package/docs/docs/api/appkit-ui/ui/InputGroup/index.html +3 -3
  106. package/docs/docs/api/appkit-ui/ui/InputOTP/index.html +3 -3
  107. package/docs/docs/api/appkit-ui/ui/Item/index.html +3 -3
  108. package/docs/docs/api/appkit-ui/ui/Kbd/index.html +3 -3
  109. package/docs/docs/api/appkit-ui/ui/Label/index.html +3 -3
  110. package/docs/docs/api/appkit-ui/ui/Menubar/index.html +3 -3
  111. package/docs/docs/api/appkit-ui/ui/NavigationMenu/index.html +3 -3
  112. package/docs/docs/api/appkit-ui/ui/Pagination/index.html +3 -3
  113. package/docs/docs/api/appkit-ui/ui/Popover/index.html +3 -3
  114. package/docs/docs/api/appkit-ui/ui/Progress/index.html +3 -3
  115. package/docs/docs/api/appkit-ui/ui/RadioGroup/index.html +3 -3
  116. package/docs/docs/api/appkit-ui/ui/ResizableHandle/index.html +3 -3
  117. package/docs/docs/api/appkit-ui/ui/ScrollArea/index.html +3 -3
  118. package/docs/docs/api/appkit-ui/ui/Select/index.html +3 -3
  119. package/docs/docs/api/appkit-ui/ui/Separator/index.html +3 -3
  120. package/docs/docs/api/appkit-ui/ui/Sheet/index.html +3 -3
  121. package/docs/docs/api/appkit-ui/ui/Sidebar/index.html +3 -3
  122. package/docs/docs/api/appkit-ui/ui/Skeleton/index.html +3 -3
  123. package/docs/docs/api/appkit-ui/ui/Slider/index.html +3 -3
  124. package/docs/docs/api/appkit-ui/ui/Spinner/index.html +3 -3
  125. package/docs/docs/api/appkit-ui/ui/Switch/index.html +3 -3
  126. package/docs/docs/api/appkit-ui/ui/Table/index.html +3 -3
  127. package/docs/docs/api/appkit-ui/ui/Tabs/index.html +3 -3
  128. package/docs/docs/api/appkit-ui/ui/Textarea/index.html +3 -3
  129. package/docs/docs/api/appkit-ui/ui/Toaster/index.html +3 -3
  130. package/docs/docs/api/appkit-ui/ui/Toggle/index.html +3 -3
  131. package/docs/docs/api/appkit-ui/ui/ToggleGroup/index.html +3 -3
  132. package/docs/docs/api/appkit-ui/ui/Tooltip/index.html +3 -3
  133. package/docs/docs/api/index.html +3 -3
  134. package/docs/docs/app-management/index.html +4 -4
  135. package/docs/docs/architecture/index.html +6 -6
  136. package/docs/docs/category/development/index.html +3 -3
  137. package/docs/docs/configuration/index.html +4 -4
  138. package/docs/docs/core-principles/index.html +3 -3
  139. package/docs/docs/development/ai-assisted-development/index.html +3 -3
  140. package/docs/docs/development/index.html +3 -3
  141. package/docs/docs/development/llm-guide/index.html +3 -3
  142. package/docs/docs/development/local-development/index.html +3 -3
  143. package/docs/docs/development/project-setup/index.html +4 -4
  144. package/docs/docs/development/remote-bridge/index.html +3 -3
  145. package/docs/docs/development/type-generation/index.html +4 -4
  146. package/docs/docs/index.html +3 -3
  147. package/docs/docs/plugins/analytics/index.html +53 -0
  148. package/docs/docs/plugins/analytics.md +66 -0
  149. package/docs/docs/plugins/caching/index.html +23 -0
  150. package/docs/docs/plugins/caching.md +33 -0
  151. package/docs/docs/plugins/custom-plugins/index.html +49 -0
  152. package/docs/docs/plugins/custom-plugins.md +161 -0
  153. package/docs/docs/plugins/execution-context/index.html +40 -0
  154. package/docs/docs/plugins/execution-context.md +45 -0
  155. package/docs/docs/plugins/index.html +6 -173
  156. package/docs/docs/plugins/lakebase/index.html +62 -0
  157. package/docs/docs/plugins/lakebase.md +179 -0
  158. package/docs/docs/plugins/plugin-management/index.html +44 -0
  159. package/docs/docs/plugins/plugin-management.md +88 -0
  160. package/docs/docs/plugins/server/index.html +45 -0
  161. package/docs/docs/plugins/server.md +78 -0
  162. package/docs/docs/plugins.md +0 -481
  163. package/llms.txt +7 -0
  164. package/package.json +1 -1
package/CLAUDE.md CHANGED
@@ -148,3 +148,10 @@ The CLI will display the documentation content directly in the terminal.
148
148
  - [Remote Bridge](./docs/docs/development/remote-bridge.md): Remote bridge allows you to develop against a deployed backend while keeping your UI and queries local. This is useful for testing against production data or debugging deployed backend code without redeploying your app.
149
149
  - [Type generation](./docs/docs/development/type-generation.md): AppKit can automatically generate TypeScript types for your SQL queries, providing end-to-end type safety from database to UI.
150
150
  - [Plugins](./docs/docs/plugins.md): Plugins are modular extensions that add capabilities to your AppKit application. They follow a defined lifecycle and have access to shared services like caching, telemetry, and streaming.
151
+ - [Analytics plugin](./docs/docs/plugins/analytics.md): Enables SQL query execution against Databricks SQL Warehouses.
152
+ - [Caching](./docs/docs/plugins/caching.md): AppKit provides both global and plugin-level caching capabilities.
153
+ - [Creating custom plugins](./docs/docs/plugins/custom-plugins.md): If you need custom API routes or background logic, implement an AppKit plugin. The fastest way is to use the CLI:
154
+ - [Execution context](./docs/docs/plugins/execution-context.md): AppKit manages Databricks authentication via two contexts:
155
+ - [Lakebase plugin](./docs/docs/plugins/lakebase.md): Currently, the Lakebase plugin currently requires a one-time manual setup to connect your Databricks App with your Lakebase database. An automated setup process is planned for an upcoming future release.
156
+ - [Plugin management](./docs/docs/plugins/plugin-management.md): AppKit includes a CLI for managing plugins. All commands are available under npx @databricks/appkit plugin.
157
+ - [Server plugin](./docs/docs/plugins/server.md): Provides HTTP server capabilities with development and production modes.
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@databricks/appkit";
3
- var version = "0.10.1";
3
+ var version = "0.11.0";
4
4
 
5
5
  //#endregion
6
6
  export { name, version };
@@ -188,7 +188,8 @@ function discoverLocalPlugins(relativeImports, serverFileDir, cwd) {
188
188
  displayName: manifest.displayName,
189
189
  description: manifest.description,
190
190
  package: `./${relativePath}`,
191
- resources: manifest.resources
191
+ resources: manifest.resources,
192
+ ...manifest.onSetupMessage && { onSetupMessage: manifest.onSetupMessage }
192
193
  };
193
194
  } catch (error) {
194
195
  console.warn(`Warning: Failed to parse manifest at ${manifestPath}:`, error instanceof Error ? error.message : error);
@@ -238,7 +239,8 @@ function scanForPlugins(cwd, packages) {
238
239
  displayName: manifest.displayName,
239
240
  description: manifest.description,
240
241
  package: packageName,
241
- resources: manifest.resources
242
+ resources: manifest.resources,
243
+ ...manifest.onSetupMessage && { onSetupMessage: manifest.onSetupMessage }
242
244
  };
243
245
  }
244
246
  return plugins;
@@ -268,7 +270,8 @@ function scanPluginsDir(dir, packageName) {
268
270
  displayName: manifest.displayName,
269
271
  description: manifest.description,
270
272
  package: packageName,
271
- resources: manifest.resources
273
+ resources: manifest.resources,
274
+ ...manifest.onSetupMessage && { onSetupMessage: manifest.onSetupMessage }
272
275
  };
273
276
  } catch (error) {
274
277
  console.warn(`Warning: Failed to parse manifest at ${manifestPath}:`, error instanceof Error ? error.message : error);
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","names":[],"sources":["../../../../../src/cli/commands/plugin/sync/sync.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Lang, parse, type SgNode } from \"@ast-grep/napi\";\nimport { Command } from \"commander\";\nimport type {\n PluginManifest,\n TemplatePlugin,\n TemplatePluginsManifest,\n} from \"../manifest-types\";\nimport {\n formatValidationErrors,\n validateManifest,\n} from \"../validate/validate-manifest\";\n\n/**\n * Checks whether a resolved file path is within a given directory boundary.\n * Uses path.resolve + startsWith to prevent directory traversal.\n *\n * @param filePath - The path to check (will be resolved to absolute)\n * @param boundary - The directory that must contain filePath\n * @returns true if filePath is inside boundary (or equal to it)\n */\nfunction isWithinDirectory(filePath: string, boundary: string): boolean {\n const resolvedPath = path.resolve(filePath);\n const resolvedBoundary = path.resolve(boundary);\n // Append separator to avoid prefix false-positives (e.g. /foo-bar matching /foo)\n return (\n resolvedPath === resolvedBoundary ||\n resolvedPath.startsWith(`${resolvedBoundary}${path.sep}`)\n );\n}\n\n/**\n * Validates a parsed JSON object against the plugin-manifest JSON schema.\n * Returns the manifest if valid, or null and logs schema errors.\n */\nfunction validateManifestWithSchema(\n obj: unknown,\n sourcePath: string,\n): PluginManifest | null {\n const result = validateManifest(obj);\n if (result.valid && result.manifest) return result.manifest;\n if (result.errors?.length) {\n console.warn(\n `Warning: Manifest at ${sourcePath} failed schema validation:\\n${formatValidationErrors(result.errors, obj)}`,\n );\n }\n return null;\n}\n\n/**\n * Known packages that may contain AppKit plugins.\n * Always scanned for manifests, even if not imported in the server file.\n */\nconst KNOWN_PLUGIN_PACKAGES = [\"@databricks/appkit\"];\n\n/**\n * Candidate paths for the server entry file, relative to cwd.\n * Checked in order; the first that exists is used.\n */\nconst SERVER_FILE_CANDIDATES = [\"server/server.ts\", \"server/index.ts\"];\n\n/**\n * Find the server entry file by checking candidate paths in order.\n *\n * @param cwd - Current working directory\n * @returns Absolute path to the server file, or null if none found\n */\nfunction findServerFile(cwd: string): string | null {\n for (const candidate of SERVER_FILE_CANDIDATES) {\n const fullPath = path.join(cwd, candidate);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * Represents a single named import extracted from the server file.\n */\ninterface ParsedImport {\n /** The imported name (or local alias if renamed) */\n name: string;\n /** The original exported name (differs from name when using `import { foo as bar }`) */\n originalName: string;\n /** The module specifier (package name or relative path) */\n source: string;\n}\n\n/**\n * Extract all named imports from the AST root using structural node traversal.\n * Handles single/double quotes, multiline imports, and aliased imports.\n *\n * @param root - AST root node\n * @returns Array of parsed imports with name, original name, and source\n */\nfunction parseImports(root: SgNode): ParsedImport[] {\n const imports: ParsedImport[] = [];\n\n // Find all import_statement nodes in the AST\n const importStatements = root.findAll({\n rule: { kind: \"import_statement\" },\n });\n\n for (const stmt of importStatements) {\n // Extract the module specifier (the string node, e.g. '@databricks/appkit')\n const sourceNode = stmt.find({ rule: { kind: \"string\" } });\n if (!sourceNode) continue;\n\n // Strip surrounding quotes from the string node text\n const source = sourceNode.text().replace(/^['\"]|['\"]$/g, \"\");\n\n // Find named_imports block: { createApp, analytics, server }\n const namedImports = stmt.find({ rule: { kind: \"named_imports\" } });\n if (!namedImports) continue;\n\n // Extract each import_specifier\n const specifiers = namedImports.findAll({\n rule: { kind: \"import_specifier\" },\n });\n\n for (const specifier of specifiers) {\n const children = specifier.children();\n if (children.length >= 3) {\n // Aliased import: `foo as bar` — children are [name, \"as\", alias]\n const originalName = children[0].text();\n const localName = children[children.length - 1].text();\n imports.push({ name: localName, originalName, source });\n } else {\n // Simple import: `foo`\n const name = specifier.text();\n imports.push({ name, originalName: name, source });\n }\n }\n }\n\n return imports;\n}\n\n/**\n * Extract local names of plugins actually used in the `plugins: [...]` array\n * passed to `createApp()`. Uses structural AST traversal to find `pair` nodes\n * with key \"plugins\" and array values containing call expressions.\n *\n * @param root - AST root node\n * @returns Set of local variable names used as plugin calls in the plugins array\n */\nfunction parsePluginUsages(root: SgNode): Set<string> {\n const usedNames = new Set<string>();\n\n // Find all property pairs in the AST\n const pairs = root.findAll({ rule: { kind: \"pair\" } });\n\n for (const pair of pairs) {\n // Check if the property key is \"plugins\"\n const key = pair.find({ rule: { kind: \"property_identifier\" } });\n if (!key || key.text() !== \"plugins\") continue;\n\n // Find the array value\n const arrayNode = pair.find({ rule: { kind: \"array\" } });\n if (!arrayNode) continue;\n\n // Iterate direct children of the array to find call expressions\n for (const child of arrayNode.children()) {\n if (child.kind() === \"call_expression\") {\n // The callee is the first child (the identifier being called)\n const callee = child.children()[0];\n if (callee?.kind() === \"identifier\") {\n usedNames.add(callee.text());\n }\n }\n }\n }\n\n return usedNames;\n}\n\n/**\n * File extensions to try when resolving a relative import to a file path.\n */\nconst RESOLVE_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\"];\n\n/**\n * Resolve a relative import source to the plugin directory containing a manifest.json.\n * Follows the convention that plugins live in their own directory with a manifest.json.\n *\n * Resolution strategy:\n * 1. If the import path is a directory, look for manifest.json directly in it\n * 2. If the import path + extension is a file, look for manifest.json in its parent directory\n * 3. If the import path is a directory with an index file, look for manifest.json in that directory\n *\n * @param importSource - The relative import specifier (e.g. \"./plugins/my-plugin\")\n * @param serverFileDir - Absolute path to the directory containing the server file\n * @returns Absolute path to manifest.json, or null if not found\n */\nfunction resolveLocalManifest(\n importSource: string,\n serverFileDir: string,\n projectRoot?: string,\n): string | null {\n const resolved = path.resolve(serverFileDir, importSource);\n\n // Security: Reject paths that escape the project root\n const boundary = projectRoot || serverFileDir;\n if (!isWithinDirectory(resolved, boundary)) {\n console.warn(\n `Warning: Skipping import \"${importSource}\" — resolves outside the project directory`,\n );\n return null;\n }\n\n // Case 1: Import path is a directory with manifest.json\n // e.g. ./plugins/my-plugin → ./plugins/my-plugin/manifest.json\n if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n const manifestPath = path.join(resolved, \"manifest.json\");\n if (fs.existsSync(manifestPath)) return manifestPath;\n }\n\n // Case 2: Import path + extension resolves to a file\n // e.g. ./plugins/my-plugin → ./plugins/my-plugin.ts\n // Look for manifest.json in the same directory\n for (const ext of RESOLVE_EXTENSIONS) {\n const filePath = `${resolved}${ext}`;\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n const dir = path.dirname(filePath);\n const manifestPath = path.join(dir, \"manifest.json\");\n if (fs.existsSync(manifestPath)) return manifestPath;\n break;\n }\n }\n\n // Case 3: Import path is a directory with an index file\n // e.g. ./plugins/my-plugin → ./plugins/my-plugin/index.ts\n for (const ext of RESOLVE_EXTENSIONS) {\n const indexPath = path.join(resolved, `index${ext}`);\n if (fs.existsSync(indexPath)) {\n const manifestPath = path.join(resolved, \"manifest.json\");\n if (fs.existsSync(manifestPath)) return manifestPath;\n break;\n }\n }\n\n return null;\n}\n\n/**\n * Discover plugin manifests from local (relative) imports in the server file.\n * Resolves each relative import to a directory and looks for manifest.json.\n *\n * @param relativeImports - Parsed imports with relative sources (starting with . or /)\n * @param serverFileDir - Absolute path to the directory containing the server file\n * @param cwd - Current working directory (for computing relative paths in output)\n * @returns Map of plugin name to template plugin entry for local plugins\n */\nfunction discoverLocalPlugins(\n relativeImports: ParsedImport[],\n serverFileDir: string,\n cwd: string,\n): TemplatePluginsManifest[\"plugins\"] {\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n for (const imp of relativeImports) {\n const manifestPath = resolveLocalManifest(imp.source, serverFileDir, cwd);\n if (!manifestPath) continue;\n\n try {\n const content = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(content);\n const manifest = validateManifestWithSchema(parsed, manifestPath);\n if (!manifest) continue;\n\n const relativePath = path.relative(cwd, path.dirname(manifestPath));\n\n plugins[manifest.name] = {\n name: manifest.name,\n displayName: manifest.displayName,\n description: manifest.description,\n package: `./${relativePath}`,\n resources: manifest.resources,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to parse manifest at ${manifestPath}:`,\n error instanceof Error ? error.message : error,\n );\n }\n }\n\n return plugins;\n}\n\n/**\n * Discover plugin manifests from a package's dist folder.\n * Looks for manifest.json files in dist/plugins/{plugin-name}/ directories.\n *\n * @param packagePath - Path to the package in node_modules\n * @returns Array of plugin manifests found in the package\n */\nfunction discoverPluginManifests(packagePath: string): PluginManifest[] {\n const pluginsDir = path.join(packagePath, \"dist\", \"plugins\");\n const manifests: PluginManifest[] = [];\n\n if (!fs.existsSync(pluginsDir)) {\n return manifests;\n }\n\n const entries = fs.readdirSync(pluginsDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const manifestPath = path.join(pluginsDir, entry.name, \"manifest.json\");\n if (fs.existsSync(manifestPath)) {\n try {\n const content = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(content);\n const manifest = validateManifestWithSchema(parsed, manifestPath);\n if (manifest) {\n manifests.push(manifest);\n }\n } catch (error) {\n console.warn(\n `Warning: Failed to parse manifest at ${manifestPath}:`,\n error instanceof Error ? error.message : error,\n );\n }\n }\n }\n }\n\n return manifests;\n}\n\n/**\n * Scan node_modules for packages with plugin manifests.\n *\n * @param cwd - Current working directory to search from\n * @param packages - Set of npm package names to scan for plugin manifests\n * @returns Map of plugin name to template plugin entry\n */\nfunction scanForPlugins(\n cwd: string,\n packages: Iterable<string>,\n): TemplatePluginsManifest[\"plugins\"] {\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n for (const packageName of packages) {\n const packagePath = path.join(cwd, \"node_modules\", packageName);\n if (!fs.existsSync(packagePath)) {\n continue;\n }\n\n const manifests = discoverPluginManifests(packagePath);\n for (const manifest of manifests) {\n // Convert to template plugin format (exclude config schema)\n plugins[manifest.name] = {\n name: manifest.name,\n displayName: manifest.displayName,\n description: manifest.description,\n package: packageName,\n resources: manifest.resources,\n };\n }\n }\n\n return plugins;\n}\n\n/**\n * Scan a directory for plugin manifests in direct subdirectories.\n * Each subdirectory is expected to contain a manifest.json file.\n * Used with --plugins-dir to discover plugins from source instead of node_modules.\n *\n * @param dir - Absolute path to the directory containing plugin subdirectories\n * @param packageName - Package name to assign to discovered plugins\n * @returns Map of plugin name to template plugin entry\n */\nfunction scanPluginsDir(\n dir: string,\n packageName: string,\n): TemplatePluginsManifest[\"plugins\"] {\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n if (!fs.existsSync(dir)) return plugins;\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n const manifestPath = path.join(dir, entry.name, \"manifest.json\");\n if (!fs.existsSync(manifestPath)) continue;\n\n try {\n const content = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(content);\n const manifest = validateManifestWithSchema(parsed, manifestPath);\n if (manifest) {\n plugins[manifest.name] = {\n name: manifest.name,\n displayName: manifest.displayName,\n description: manifest.description,\n package: packageName,\n resources: manifest.resources,\n };\n }\n } catch (error) {\n console.warn(\n `Warning: Failed to parse manifest at ${manifestPath}:`,\n error instanceof Error ? error.message : error,\n );\n }\n }\n\n return plugins;\n}\n\n/**\n * Write (or preview) the template plugins manifest to disk.\n */\nfunction writeManifest(\n outputPath: string,\n { plugins }: { plugins: TemplatePluginsManifest[\"plugins\"] },\n options: { write?: boolean; silent?: boolean },\n) {\n const templateManifest: TemplatePluginsManifest = {\n $schema:\n \"https://databricks.github.io/appkit/schemas/template-plugins.schema.json\",\n version: \"1.0\",\n plugins,\n };\n\n if (options.write) {\n fs.writeFileSync(\n outputPath,\n `${JSON.stringify(templateManifest, null, 2)}\\n`,\n );\n if (!options.silent) {\n console.log(`\\n✓ Wrote ${outputPath}`);\n }\n } else if (!options.silent) {\n console.log(\"\\nTo write the manifest, run:\");\n console.log(\" npx appkit plugin sync --write\\n\");\n console.log(\"Preview:\");\n console.log(\"─\".repeat(60));\n console.log(JSON.stringify(templateManifest, null, 2));\n console.log(\"─\".repeat(60));\n }\n}\n\n/**\n * Run the plugin sync command.\n * Parses the server entry file to discover which packages to scan for plugin\n * manifests, then marks plugins that are actually used in the `plugins: [...]`\n * array as requiredByTemplate.\n */\nfunction runPluginsSync(options: {\n write?: boolean;\n output?: string;\n silent?: boolean;\n requirePlugins?: string;\n pluginsDir?: string;\n packageName?: string;\n}) {\n const cwd = process.cwd();\n const outputPath = path.resolve(cwd, options.output || \"appkit.plugins.json\");\n\n // Security: Reject output paths that escape the project root\n if (!isWithinDirectory(outputPath, cwd)) {\n console.error(\n `Error: Output path \"${options.output}\" resolves outside the project directory.`,\n );\n process.exit(1);\n }\n\n if (!options.silent) {\n console.log(\"Scanning for AppKit plugins...\\n\");\n }\n\n // Step 1: Parse server file to discover imports and plugin usages\n const serverFile = findServerFile(cwd);\n let serverImports: ParsedImport[] = [];\n let pluginUsages = new Set<string>();\n\n if (serverFile) {\n if (!options.silent) {\n const relativePath = path.relative(cwd, serverFile);\n console.log(`Server entry file: ${relativePath}`);\n }\n\n const content = fs.readFileSync(serverFile, \"utf-8\");\n const lang = serverFile.endsWith(\".tsx\") ? Lang.Tsx : Lang.TypeScript;\n const ast = parse(lang, content);\n const root = ast.root();\n\n serverImports = parseImports(root);\n pluginUsages = parsePluginUsages(root);\n } else if (!options.silent) {\n console.log(\n \"No server entry file found. Checked:\",\n SERVER_FILE_CANDIDATES.join(\", \"),\n );\n }\n\n // Step 2: Split imports into npm packages and local (relative) imports\n const npmImports = serverImports.filter(\n (i) => !i.source.startsWith(\".\") && !i.source.startsWith(\"/\"),\n );\n const localImports = serverImports.filter(\n (i) => i.source.startsWith(\".\") || i.source.startsWith(\"/\"),\n );\n\n // Step 3: Scan for plugin manifests (--plugins-dir or node_modules)\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n if (options.pluginsDir) {\n const resolvedDir = path.resolve(cwd, options.pluginsDir);\n const pkgName = options.packageName ?? \"@databricks/appkit\";\n if (!options.silent) {\n console.log(`Scanning plugins directory: ${options.pluginsDir}`);\n }\n Object.assign(plugins, scanPluginsDir(resolvedDir, pkgName));\n } else {\n const npmPackages = new Set([\n ...KNOWN_PLUGIN_PACKAGES,\n ...npmImports.map((i) => i.source),\n ]);\n Object.assign(plugins, scanForPlugins(cwd, npmPackages));\n }\n\n // Step 4: Discover local plugin manifests from relative imports\n if (serverFile && localImports.length > 0) {\n const serverFileDir = path.dirname(serverFile);\n const localPlugins = discoverLocalPlugins(localImports, serverFileDir, cwd);\n Object.assign(plugins, localPlugins);\n }\n\n const pluginCount = Object.keys(plugins).length;\n\n if (pluginCount === 0) {\n if (options.silent) {\n writeManifest(outputPath, { plugins: {} }, options);\n return;\n }\n console.log(\"No plugins found.\");\n if (options.pluginsDir) {\n console.log(`\\nNo manifest.json files found in: ${options.pluginsDir}`);\n } else {\n console.log(\"\\nMake sure you have plugin packages installed.\");\n }\n process.exit(1);\n }\n\n // Step 5: Mark plugins that are imported AND used in the plugins array as mandatory.\n // For npm imports, match by package name + plugin name.\n // For local imports, resolve both paths to absolute and compare.\n const serverFileDir = serverFile ? path.dirname(serverFile) : cwd;\n\n for (const imp of serverImports) {\n if (!pluginUsages.has(imp.name)) continue;\n\n const isLocal = imp.source.startsWith(\".\") || imp.source.startsWith(\"/\");\n let plugin: TemplatePlugin | undefined;\n\n if (isLocal) {\n // Resolve the import source to an absolute path from the server file directory\n const resolvedImportDir = path.resolve(serverFileDir, imp.source);\n plugin = Object.values(plugins).find((p) => {\n if (!p.package.startsWith(\".\")) return false;\n const resolvedPluginDir = path.resolve(cwd, p.package);\n return (\n resolvedPluginDir === resolvedImportDir && p.name === imp.originalName\n );\n });\n } else {\n // npm import: direct string comparison\n plugin = Object.values(plugins).find(\n (p) => p.package === imp.source && p.name === imp.originalName,\n );\n }\n\n if (plugin) {\n plugin.requiredByTemplate = true;\n }\n }\n\n // Step 6: Apply explicit --require-plugins overrides\n if (options.requirePlugins) {\n const explicitNames = options.requirePlugins\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n for (const name of explicitNames) {\n if (plugins[name]) {\n plugins[name].requiredByTemplate = true;\n } else if (!options.silent) {\n console.warn(\n `Warning: --require-plugins referenced \"${name}\" but no such plugin was discovered`,\n );\n }\n }\n }\n\n if (!options.silent) {\n console.log(`\\nFound ${pluginCount} plugin(s):`);\n for (const [name, manifest] of Object.entries(plugins)) {\n const resourceCount =\n manifest.resources.required.length + manifest.resources.optional.length;\n const resourceInfo =\n resourceCount > 0 ? ` [${resourceCount} resource(s)]` : \"\";\n const mandatoryTag = manifest.requiredByTemplate ? \" (mandatory)\" : \"\";\n console.log(\n ` ${manifest.requiredByTemplate ? \"●\" : \"○\"} ${manifest.displayName} (${name}) from ${manifest.package}${resourceInfo}${mandatoryTag}`,\n );\n }\n }\n\n writeManifest(outputPath, { plugins }, options);\n}\n\n/** Exported for testing: path boundary check, AST parsing. */\nexport { isWithinDirectory, parseImports, parsePluginUsages };\n\nexport const pluginsSyncCommand = new Command(\"sync\")\n .description(\n \"Sync plugin manifests from installed packages into appkit.plugins.json\",\n )\n .option(\"-w, --write\", \"Write the manifest file\")\n .option(\n \"-o, --output <path>\",\n \"Output file path (default: ./appkit.plugins.json)\",\n )\n .option(\n \"-s, --silent\",\n \"Suppress output and never exit with error (for use in predev/prebuild hooks)\",\n )\n .option(\n \"--require-plugins <names>\",\n \"Comma-separated plugin names to mark as requiredByTemplate (e.g. server,analytics)\",\n )\n .option(\n \"--plugins-dir <path>\",\n \"Scan this directory for plugin subdirectories with manifest.json (instead of node_modules)\",\n )\n .option(\n \"--package-name <name>\",\n \"Package name to assign to plugins found via --plugins-dir (default: @databricks/appkit)\",\n )\n .action(runPluginsSync);\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAS,kBAAkB,UAAkB,UAA2B;CACtE,MAAM,eAAe,KAAK,QAAQ,SAAS;CAC3C,MAAM,mBAAmB,KAAK,QAAQ,SAAS;AAE/C,QACE,iBAAiB,oBACjB,aAAa,WAAW,GAAG,mBAAmB,KAAK,MAAM;;;;;;AAQ7D,SAAS,2BACP,KACA,YACuB;CACvB,MAAM,SAAS,iBAAiB,IAAI;AACpC,KAAI,OAAO,SAAS,OAAO,SAAU,QAAO,OAAO;AACnD,KAAI,OAAO,QAAQ,OACjB,SAAQ,KACN,wB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O,CAClD,YACC,yEACD,CACA,OAAO,eAAe,0BAA0B,CAChD,OACC,uBACA,oDACD,CACA,OACC,gBACA,+EACD,CACA,OACC,6BACA,qFACD,CACA,OACC,wBACA,6FACD,CACA,OACC,yBACA,0FACD,CACA,OAAO,eAAe"}
1
+ {"version":3,"file":"sync.js","names":[],"sources":["../../../../../src/cli/commands/plugin/sync/sync.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Lang, parse, type SgNode } from \"@ast-grep/napi\";\nimport { Command } from \"commander\";\nimport type {\n PluginManifest,\n TemplatePlugin,\n TemplatePluginsManifest,\n} from \"../manifest-types\";\nimport {\n formatValidationErrors,\n validateManifest,\n} from \"../validate/validate-manifest\";\n\n/**\n * Checks whether a resolved file path is within a given directory boundary.\n * Uses path.resolve + startsWith to prevent directory traversal.\n *\n * @param filePath - The path to check (will be resolved to absolute)\n * @param boundary - The directory that must contain filePath\n * @returns true if filePath is inside boundary (or equal to it)\n */\nfunction isWithinDirectory(filePath: string, boundary: string): boolean {\n const resolvedPath = path.resolve(filePath);\n const resolvedBoundary = path.resolve(boundary);\n // Append separator to avoid prefix false-positives (e.g. /foo-bar matching /foo)\n return (\n resolvedPath === resolvedBoundary ||\n resolvedPath.startsWith(`${resolvedBoundary}${path.sep}`)\n );\n}\n\n/**\n * Validates a parsed JSON object against the plugin-manifest JSON schema.\n * Returns the manifest if valid, or null and logs schema errors.\n */\nfunction validateManifestWithSchema(\n obj: unknown,\n sourcePath: string,\n): PluginManifest | null {\n const result = validateManifest(obj);\n if (result.valid && result.manifest) return result.manifest;\n if (result.errors?.length) {\n console.warn(\n `Warning: Manifest at ${sourcePath} failed schema validation:\\n${formatValidationErrors(result.errors, obj)}`,\n );\n }\n return null;\n}\n\n/**\n * Known packages that may contain AppKit plugins.\n * Always scanned for manifests, even if not imported in the server file.\n */\nconst KNOWN_PLUGIN_PACKAGES = [\"@databricks/appkit\"];\n\n/**\n * Candidate paths for the server entry file, relative to cwd.\n * Checked in order; the first that exists is used.\n */\nconst SERVER_FILE_CANDIDATES = [\"server/server.ts\", \"server/index.ts\"];\n\n/**\n * Find the server entry file by checking candidate paths in order.\n *\n * @param cwd - Current working directory\n * @returns Absolute path to the server file, or null if none found\n */\nfunction findServerFile(cwd: string): string | null {\n for (const candidate of SERVER_FILE_CANDIDATES) {\n const fullPath = path.join(cwd, candidate);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * Represents a single named import extracted from the server file.\n */\ninterface ParsedImport {\n /** The imported name (or local alias if renamed) */\n name: string;\n /** The original exported name (differs from name when using `import { foo as bar }`) */\n originalName: string;\n /** The module specifier (package name or relative path) */\n source: string;\n}\n\n/**\n * Extract all named imports from the AST root using structural node traversal.\n * Handles single/double quotes, multiline imports, and aliased imports.\n *\n * @param root - AST root node\n * @returns Array of parsed imports with name, original name, and source\n */\nfunction parseImports(root: SgNode): ParsedImport[] {\n const imports: ParsedImport[] = [];\n\n // Find all import_statement nodes in the AST\n const importStatements = root.findAll({\n rule: { kind: \"import_statement\" },\n });\n\n for (const stmt of importStatements) {\n // Extract the module specifier (the string node, e.g. '@databricks/appkit')\n const sourceNode = stmt.find({ rule: { kind: \"string\" } });\n if (!sourceNode) continue;\n\n // Strip surrounding quotes from the string node text\n const source = sourceNode.text().replace(/^['\"]|['\"]$/g, \"\");\n\n // Find named_imports block: { createApp, analytics, server }\n const namedImports = stmt.find({ rule: { kind: \"named_imports\" } });\n if (!namedImports) continue;\n\n // Extract each import_specifier\n const specifiers = namedImports.findAll({\n rule: { kind: \"import_specifier\" },\n });\n\n for (const specifier of specifiers) {\n const children = specifier.children();\n if (children.length >= 3) {\n // Aliased import: `foo as bar` — children are [name, \"as\", alias]\n const originalName = children[0].text();\n const localName = children[children.length - 1].text();\n imports.push({ name: localName, originalName, source });\n } else {\n // Simple import: `foo`\n const name = specifier.text();\n imports.push({ name, originalName: name, source });\n }\n }\n }\n\n return imports;\n}\n\n/**\n * Extract local names of plugins actually used in the `plugins: [...]` array\n * passed to `createApp()`. Uses structural AST traversal to find `pair` nodes\n * with key \"plugins\" and array values containing call expressions.\n *\n * @param root - AST root node\n * @returns Set of local variable names used as plugin calls in the plugins array\n */\nfunction parsePluginUsages(root: SgNode): Set<string> {\n const usedNames = new Set<string>();\n\n // Find all property pairs in the AST\n const pairs = root.findAll({ rule: { kind: \"pair\" } });\n\n for (const pair of pairs) {\n // Check if the property key is \"plugins\"\n const key = pair.find({ rule: { kind: \"property_identifier\" } });\n if (!key || key.text() !== \"plugins\") continue;\n\n // Find the array value\n const arrayNode = pair.find({ rule: { kind: \"array\" } });\n if (!arrayNode) continue;\n\n // Iterate direct children of the array to find call expressions\n for (const child of arrayNode.children()) {\n if (child.kind() === \"call_expression\") {\n // The callee is the first child (the identifier being called)\n const callee = child.children()[0];\n if (callee?.kind() === \"identifier\") {\n usedNames.add(callee.text());\n }\n }\n }\n }\n\n return usedNames;\n}\n\n/**\n * File extensions to try when resolving a relative import to a file path.\n */\nconst RESOLVE_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\"];\n\n/**\n * Resolve a relative import source to the plugin directory containing a manifest.json.\n * Follows the convention that plugins live in their own directory with a manifest.json.\n *\n * Resolution strategy:\n * 1. If the import path is a directory, look for manifest.json directly in it\n * 2. If the import path + extension is a file, look for manifest.json in its parent directory\n * 3. If the import path is a directory with an index file, look for manifest.json in that directory\n *\n * @param importSource - The relative import specifier (e.g. \"./plugins/my-plugin\")\n * @param serverFileDir - Absolute path to the directory containing the server file\n * @returns Absolute path to manifest.json, or null if not found\n */\nfunction resolveLocalManifest(\n importSource: string,\n serverFileDir: string,\n projectRoot?: string,\n): string | null {\n const resolved = path.resolve(serverFileDir, importSource);\n\n // Security: Reject paths that escape the project root\n const boundary = projectRoot || serverFileDir;\n if (!isWithinDirectory(resolved, boundary)) {\n console.warn(\n `Warning: Skipping import \"${importSource}\" — resolves outside the project directory`,\n );\n return null;\n }\n\n // Case 1: Import path is a directory with manifest.json\n // e.g. ./plugins/my-plugin → ./plugins/my-plugin/manifest.json\n if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n const manifestPath = path.join(resolved, \"manifest.json\");\n if (fs.existsSync(manifestPath)) return manifestPath;\n }\n\n // Case 2: Import path + extension resolves to a file\n // e.g. ./plugins/my-plugin → ./plugins/my-plugin.ts\n // Look for manifest.json in the same directory\n for (const ext of RESOLVE_EXTENSIONS) {\n const filePath = `${resolved}${ext}`;\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n const dir = path.dirname(filePath);\n const manifestPath = path.join(dir, \"manifest.json\");\n if (fs.existsSync(manifestPath)) return manifestPath;\n break;\n }\n }\n\n // Case 3: Import path is a directory with an index file\n // e.g. ./plugins/my-plugin → ./plugins/my-plugin/index.ts\n for (const ext of RESOLVE_EXTENSIONS) {\n const indexPath = path.join(resolved, `index${ext}`);\n if (fs.existsSync(indexPath)) {\n const manifestPath = path.join(resolved, \"manifest.json\");\n if (fs.existsSync(manifestPath)) return manifestPath;\n break;\n }\n }\n\n return null;\n}\n\n/**\n * Discover plugin manifests from local (relative) imports in the server file.\n * Resolves each relative import to a directory and looks for manifest.json.\n *\n * @param relativeImports - Parsed imports with relative sources (starting with . or /)\n * @param serverFileDir - Absolute path to the directory containing the server file\n * @param cwd - Current working directory (for computing relative paths in output)\n * @returns Map of plugin name to template plugin entry for local plugins\n */\nfunction discoverLocalPlugins(\n relativeImports: ParsedImport[],\n serverFileDir: string,\n cwd: string,\n): TemplatePluginsManifest[\"plugins\"] {\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n for (const imp of relativeImports) {\n const manifestPath = resolveLocalManifest(imp.source, serverFileDir, cwd);\n if (!manifestPath) continue;\n\n try {\n const content = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(content);\n const manifest = validateManifestWithSchema(parsed, manifestPath);\n if (!manifest) continue;\n\n const relativePath = path.relative(cwd, path.dirname(manifestPath));\n\n plugins[manifest.name] = {\n name: manifest.name,\n displayName: manifest.displayName,\n description: manifest.description,\n package: `./${relativePath}`,\n resources: manifest.resources,\n ...(manifest.onSetupMessage && {\n onSetupMessage: manifest.onSetupMessage,\n }),\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to parse manifest at ${manifestPath}:`,\n error instanceof Error ? error.message : error,\n );\n }\n }\n\n return plugins;\n}\n\n/**\n * Discover plugin manifests from a package's dist folder.\n * Looks for manifest.json files in dist/plugins/{plugin-name}/ directories.\n *\n * @param packagePath - Path to the package in node_modules\n * @returns Array of plugin manifests found in the package\n */\nfunction discoverPluginManifests(packagePath: string): PluginManifest[] {\n const pluginsDir = path.join(packagePath, \"dist\", \"plugins\");\n const manifests: PluginManifest[] = [];\n\n if (!fs.existsSync(pluginsDir)) {\n return manifests;\n }\n\n const entries = fs.readdirSync(pluginsDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const manifestPath = path.join(pluginsDir, entry.name, \"manifest.json\");\n if (fs.existsSync(manifestPath)) {\n try {\n const content = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(content);\n const manifest = validateManifestWithSchema(parsed, manifestPath);\n if (manifest) {\n manifests.push(manifest);\n }\n } catch (error) {\n console.warn(\n `Warning: Failed to parse manifest at ${manifestPath}:`,\n error instanceof Error ? error.message : error,\n );\n }\n }\n }\n }\n\n return manifests;\n}\n\n/**\n * Scan node_modules for packages with plugin manifests.\n *\n * @param cwd - Current working directory to search from\n * @param packages - Set of npm package names to scan for plugin manifests\n * @returns Map of plugin name to template plugin entry\n */\nfunction scanForPlugins(\n cwd: string,\n packages: Iterable<string>,\n): TemplatePluginsManifest[\"plugins\"] {\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n for (const packageName of packages) {\n const packagePath = path.join(cwd, \"node_modules\", packageName);\n if (!fs.existsSync(packagePath)) {\n continue;\n }\n\n const manifests = discoverPluginManifests(packagePath);\n for (const manifest of manifests) {\n // Convert to template plugin format (exclude config schema)\n plugins[manifest.name] = {\n name: manifest.name,\n displayName: manifest.displayName,\n description: manifest.description,\n package: packageName,\n resources: manifest.resources,\n ...(manifest.onSetupMessage && {\n onSetupMessage: manifest.onSetupMessage,\n }),\n };\n }\n }\n\n return plugins;\n}\n\n/**\n * Scan a directory for plugin manifests in direct subdirectories.\n * Each subdirectory is expected to contain a manifest.json file.\n * Used with --plugins-dir to discover plugins from source instead of node_modules.\n *\n * @param dir - Absolute path to the directory containing plugin subdirectories\n * @param packageName - Package name to assign to discovered plugins\n * @returns Map of plugin name to template plugin entry\n */\nfunction scanPluginsDir(\n dir: string,\n packageName: string,\n): TemplatePluginsManifest[\"plugins\"] {\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n if (!fs.existsSync(dir)) return plugins;\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n const manifestPath = path.join(dir, entry.name, \"manifest.json\");\n if (!fs.existsSync(manifestPath)) continue;\n\n try {\n const content = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(content);\n const manifest = validateManifestWithSchema(parsed, manifestPath);\n if (manifest) {\n plugins[manifest.name] = {\n name: manifest.name,\n displayName: manifest.displayName,\n description: manifest.description,\n package: packageName,\n resources: manifest.resources,\n ...(manifest.onSetupMessage && {\n onSetupMessage: manifest.onSetupMessage,\n }),\n };\n }\n } catch (error) {\n console.warn(\n `Warning: Failed to parse manifest at ${manifestPath}:`,\n error instanceof Error ? error.message : error,\n );\n }\n }\n\n return plugins;\n}\n\n/**\n * Write (or preview) the template plugins manifest to disk.\n */\nfunction writeManifest(\n outputPath: string,\n { plugins }: { plugins: TemplatePluginsManifest[\"plugins\"] },\n options: { write?: boolean; silent?: boolean },\n) {\n const templateManifest: TemplatePluginsManifest = {\n $schema:\n \"https://databricks.github.io/appkit/schemas/template-plugins.schema.json\",\n version: \"1.0\",\n plugins,\n };\n\n if (options.write) {\n fs.writeFileSync(\n outputPath,\n `${JSON.stringify(templateManifest, null, 2)}\\n`,\n );\n if (!options.silent) {\n console.log(`\\n✓ Wrote ${outputPath}`);\n }\n } else if (!options.silent) {\n console.log(\"\\nTo write the manifest, run:\");\n console.log(\" npx appkit plugin sync --write\\n\");\n console.log(\"Preview:\");\n console.log(\"─\".repeat(60));\n console.log(JSON.stringify(templateManifest, null, 2));\n console.log(\"─\".repeat(60));\n }\n}\n\n/**\n * Run the plugin sync command.\n * Parses the server entry file to discover which packages to scan for plugin\n * manifests, then marks plugins that are actually used in the `plugins: [...]`\n * array as requiredByTemplate.\n */\nfunction runPluginsSync(options: {\n write?: boolean;\n output?: string;\n silent?: boolean;\n requirePlugins?: string;\n pluginsDir?: string;\n packageName?: string;\n}) {\n const cwd = process.cwd();\n const outputPath = path.resolve(cwd, options.output || \"appkit.plugins.json\");\n\n // Security: Reject output paths that escape the project root\n if (!isWithinDirectory(outputPath, cwd)) {\n console.error(\n `Error: Output path \"${options.output}\" resolves outside the project directory.`,\n );\n process.exit(1);\n }\n\n if (!options.silent) {\n console.log(\"Scanning for AppKit plugins...\\n\");\n }\n\n // Step 1: Parse server file to discover imports and plugin usages\n const serverFile = findServerFile(cwd);\n let serverImports: ParsedImport[] = [];\n let pluginUsages = new Set<string>();\n\n if (serverFile) {\n if (!options.silent) {\n const relativePath = path.relative(cwd, serverFile);\n console.log(`Server entry file: ${relativePath}`);\n }\n\n const content = fs.readFileSync(serverFile, \"utf-8\");\n const lang = serverFile.endsWith(\".tsx\") ? Lang.Tsx : Lang.TypeScript;\n const ast = parse(lang, content);\n const root = ast.root();\n\n serverImports = parseImports(root);\n pluginUsages = parsePluginUsages(root);\n } else if (!options.silent) {\n console.log(\n \"No server entry file found. Checked:\",\n SERVER_FILE_CANDIDATES.join(\", \"),\n );\n }\n\n // Step 2: Split imports into npm packages and local (relative) imports\n const npmImports = serverImports.filter(\n (i) => !i.source.startsWith(\".\") && !i.source.startsWith(\"/\"),\n );\n const localImports = serverImports.filter(\n (i) => i.source.startsWith(\".\") || i.source.startsWith(\"/\"),\n );\n\n // Step 3: Scan for plugin manifests (--plugins-dir or node_modules)\n const plugins: TemplatePluginsManifest[\"plugins\"] = {};\n\n if (options.pluginsDir) {\n const resolvedDir = path.resolve(cwd, options.pluginsDir);\n const pkgName = options.packageName ?? \"@databricks/appkit\";\n if (!options.silent) {\n console.log(`Scanning plugins directory: ${options.pluginsDir}`);\n }\n Object.assign(plugins, scanPluginsDir(resolvedDir, pkgName));\n } else {\n const npmPackages = new Set([\n ...KNOWN_PLUGIN_PACKAGES,\n ...npmImports.map((i) => i.source),\n ]);\n Object.assign(plugins, scanForPlugins(cwd, npmPackages));\n }\n\n // Step 4: Discover local plugin manifests from relative imports\n if (serverFile && localImports.length > 0) {\n const serverFileDir = path.dirname(serverFile);\n const localPlugins = discoverLocalPlugins(localImports, serverFileDir, cwd);\n Object.assign(plugins, localPlugins);\n }\n\n const pluginCount = Object.keys(plugins).length;\n\n if (pluginCount === 0) {\n if (options.silent) {\n writeManifest(outputPath, { plugins: {} }, options);\n return;\n }\n console.log(\"No plugins found.\");\n if (options.pluginsDir) {\n console.log(`\\nNo manifest.json files found in: ${options.pluginsDir}`);\n } else {\n console.log(\"\\nMake sure you have plugin packages installed.\");\n }\n process.exit(1);\n }\n\n // Step 5: Mark plugins that are imported AND used in the plugins array as mandatory.\n // For npm imports, match by package name + plugin name.\n // For local imports, resolve both paths to absolute and compare.\n const serverFileDir = serverFile ? path.dirname(serverFile) : cwd;\n\n for (const imp of serverImports) {\n if (!pluginUsages.has(imp.name)) continue;\n\n const isLocal = imp.source.startsWith(\".\") || imp.source.startsWith(\"/\");\n let plugin: TemplatePlugin | undefined;\n\n if (isLocal) {\n // Resolve the import source to an absolute path from the server file directory\n const resolvedImportDir = path.resolve(serverFileDir, imp.source);\n plugin = Object.values(plugins).find((p) => {\n if (!p.package.startsWith(\".\")) return false;\n const resolvedPluginDir = path.resolve(cwd, p.package);\n return (\n resolvedPluginDir === resolvedImportDir && p.name === imp.originalName\n );\n });\n } else {\n // npm import: direct string comparison\n plugin = Object.values(plugins).find(\n (p) => p.package === imp.source && p.name === imp.originalName,\n );\n }\n\n if (plugin) {\n plugin.requiredByTemplate = true;\n }\n }\n\n // Step 6: Apply explicit --require-plugins overrides\n if (options.requirePlugins) {\n const explicitNames = options.requirePlugins\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n for (const name of explicitNames) {\n if (plugins[name]) {\n plugins[name].requiredByTemplate = true;\n } else if (!options.silent) {\n console.warn(\n `Warning: --require-plugins referenced \"${name}\" but no such plugin was discovered`,\n );\n }\n }\n }\n\n if (!options.silent) {\n console.log(`\\nFound ${pluginCount} plugin(s):`);\n for (const [name, manifest] of Object.entries(plugins)) {\n const resourceCount =\n manifest.resources.required.length + manifest.resources.optional.length;\n const resourceInfo =\n resourceCount > 0 ? ` [${resourceCount} resource(s)]` : \"\";\n const mandatoryTag = manifest.requiredByTemplate ? \" (mandatory)\" : \"\";\n console.log(\n ` ${manifest.requiredByTemplate ? \"●\" : \"○\"} ${manifest.displayName} (${name}) from ${manifest.package}${resourceInfo}${mandatoryTag}`,\n );\n }\n }\n\n writeManifest(outputPath, { plugins }, options);\n}\n\n/** Exported for testing: path boundary check, AST parsing. */\nexport { isWithinDirectory, parseImports, parsePluginUsages };\n\nexport const pluginsSyncCommand = new Command(\"sync\")\n .description(\n \"Sync plugin manifests from installed packages into appkit.plugins.json\",\n )\n .option(\"-w, --write\", \"Write the manifest file\")\n .option(\n \"-o, --output <path>\",\n \"Output file path (default: ./appkit.plugins.json)\",\n )\n .option(\n \"-s, --silent\",\n \"Suppress output and never exit with error (for use in predev/prebuild hooks)\",\n )\n .option(\n \"--require-plugins <names>\",\n \"Comma-separated plugin names to mark as requiredByTemplate (e.g. server,analytics)\",\n )\n .option(\n \"--plugins-dir <path>\",\n \"Scan this directory for plugin subdirectories with manifest.json (instead of node_modules)\",\n )\n .option(\n \"--package-name <name>\",\n \"Package name to assign to plugins found via --plugins-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Q,MACV,SAAQ,MAAM,qBAAqB;WAC1B,CAAC,QAAQ,OAClB,SAAQ,KACN,0CAA0C,KAAK,qCAChD;;AAKP,KAAI,CAAC,QAAQ,QAAQ;AACnB,UAAQ,IAAI,WAAW,YAAY,aAAa;AAChD,OAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,QAAQ,EAAE;GACtD,MAAM,gBACJ,SAAS,UAAU,SAAS,SAAS,SAAS,UAAU,SAAS;GACnE,MAAM,eACJ,gBAAgB,IAAI,KAAK,cAAc,iBAAiB;GAC1D,MAAM,eAAe,SAAS,qBAAqB,iBAAiB;AACpE,WAAQ,IACN,KAAK,SAAS,qBAAqB,MAAM,IAAI,GAAG,SAAS,YAAY,IAAI,KAAK,SAAS,SAAS,UAAU,eAAe,eAC1H;;;AAIL,eAAc,YAAY,EAAE,SAAS,EAAE,QAAQ;;AAMjD,MAAa,qBAAqB,IAAI,QAAQ,OAAO,CAClD,YACC,yEACD,CACA,OAAO,eAAe,0BAA0B,CAChD,OACC,uBACA,oDACD,CACA,OACC,gBACA,+EACD,CACA,OACC,6BACA,qFACD,CACA,OACC,wBACA,6FACD,CACA,OACC,yBACA,0FACD,CACA,OAAO,eAAe"}
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ import { ResourcePermission, ResourceType } from "./registry/types.generated.js"
24
24
  import { ConfigSchema, PluginManifest, ResourceEntry, ResourceFieldEntry, ResourceRequirement, ValidationResult } from "./registry/types.js";
25
25
  import { getPluginManifest, getResourceRequirements } from "./registry/manifest-loader.js";
26
26
  import { ResourceRegistry } from "./registry/resource-registry.js";
27
+ import { lakebase } from "./plugins/lakebase/lakebase.js";
27
28
  import { server } from "./plugins/server/index.js";
28
29
  import { appKitTypesPlugin } from "./type-generator/vite-plugin.js";
29
- export { AppKitError, AuthenticationError, type BasePluginConfig, type CacheConfig, CacheManager, type ConfigSchema, ConfigurationError, ConnectionError, type Counter, type DatabaseCredential, ExecutionError, type GenerateDatabaseCredentialRequest, type Histogram, type IAppRouter, type ITelemetry, InitializationError, type LakebasePoolConfig, Plugin, type PluginManifest, type RequestedClaims, RequestedClaimsPermissionSet, type RequestedResource, type ResourceEntry, type ResourceFieldEntry, type ResourcePermission, ResourceRegistry, type ResourceRequirement, ResourceType, ServerError, SeverityNumber, type Span, SpanStatusCode, type StreamExecutionSettings, type TelemetryConfig, type ToPlugin, TunnelError, ValidationError, type ValidationResult, analytics, appKitTypesPlugin, createApp, createLakebasePool, generateDatabaseCredential, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, server, sql, toPlugin };
30
+ export { AppKitError, AuthenticationError, type BasePluginConfig, type CacheConfig, CacheManager, type ConfigSchema, ConfigurationError, ConnectionError, type Counter, type DatabaseCredential, ExecutionError, type GenerateDatabaseCredentialRequest, type Histogram, type IAppRouter, type ITelemetry, InitializationError, type LakebasePoolConfig, Plugin, type PluginManifest, type RequestedClaims, RequestedClaimsPermissionSet, type RequestedResource, type ResourceEntry, type ResourceFieldEntry, type ResourcePermission, ResourceRegistry, type ResourceRequirement, ResourceType, ServerError, SeverityNumber, type Span, SpanStatusCode, type StreamExecutionSettings, type TelemetryConfig, type ToPlugin, TunnelError, ValidationError, type ValidationResult, analytics, appKitTypesPlugin, createApp, createLakebasePool, generateDatabaseCredential, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, lakebase, server, sql, toPlugin };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ import { Plugin } from "./plugin/plugin.js";
24
24
  import { toPlugin } from "./plugin/to-plugin.js";
25
25
  import "./plugin/index.js";
26
26
  import { analytics } from "./plugins/analytics/analytics.js";
27
+ import { lakebase } from "./plugins/lakebase/lakebase.js";
27
28
  import { appKitTypesPlugin } from "./type-generator/vite-plugin.js";
28
29
  import { server } from "./plugins/server/index.js";
29
30
  import "./plugins/index.js";
@@ -33,5 +34,5 @@ init_context();
33
34
  init_errors();
34
35
 
35
36
  //#endregion
36
- export { AppKitError, AuthenticationError, CacheManager, ConfigurationError, ConnectionError, ExecutionError, InitializationError, Plugin, RequestedClaimsPermissionSet, ResourceRegistry, ResourceType, ServerError, SeverityNumber, SpanStatusCode, TunnelError, ValidationError, analytics, appKitTypesPlugin, createApp, createLakebasePool, generateDatabaseCredential, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, server, sql, toPlugin };
37
+ export { AppKitError, AuthenticationError, CacheManager, ConfigurationError, ConnectionError, ExecutionError, InitializationError, Plugin, RequestedClaimsPermissionSet, ResourceRegistry, ResourceType, ServerError, SeverityNumber, SpanStatusCode, TunnelError, ValidationError, analytics, appKitTypesPlugin, createApp, createLakebasePool, generateDatabaseCredential, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, lakebase, server, sql, toPlugin };
37
38
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * Core library for building Databricks applications with type-safe SQL queries,\n * plugin architecture, and React integration.\n */\n\n// Types from shared\nexport type {\n BasePluginConfig,\n CacheConfig,\n IAppRouter,\n StreamExecutionSettings,\n} from \"shared\";\nexport { isSQLTypeMarker, sql } from \"shared\";\nexport { CacheManager } from \"./cache\";\nexport type {\n DatabaseCredential,\n GenerateDatabaseCredentialRequest,\n LakebasePoolConfig,\n RequestedClaims,\n RequestedResource,\n} from \"./connectors/lakebase\";\n// Lakebase Autoscaling connector\nexport {\n createLakebasePool,\n generateDatabaseCredential,\n getLakebaseOrmConfig,\n getLakebasePgConfig,\n getUsernameWithApiLookup,\n getWorkspaceClient,\n RequestedClaimsPermissionSet,\n} from \"./connectors/lakebase\";\nexport { getExecutionContext } from \"./context\";\nexport { createApp } from \"./core\";\n// Errors\nexport {\n AppKitError,\n AuthenticationError,\n ConfigurationError,\n ConnectionError,\n ExecutionError,\n InitializationError,\n ServerError,\n TunnelError,\n ValidationError,\n} from \"./errors\";\n// Plugin authoring\nexport { Plugin, type ToPlugin, toPlugin } from \"./plugin\";\nexport { analytics, server } from \"./plugins\";\n// Registry types and utilities for plugin manifests\nexport type {\n ConfigSchema,\n PluginManifest,\n ResourceEntry,\n ResourceFieldEntry,\n ResourcePermission,\n ResourceRequirement,\n ValidationResult,\n} from \"./registry\";\nexport {\n getPluginManifest,\n getResourceRequirements,\n ResourceRegistry,\n ResourceType,\n} from \"./registry\";\n// Telemetry (for advanced custom telemetry)\nexport {\n type Counter,\n type Histogram,\n type ITelemetry,\n SeverityNumber,\n type Span,\n SpanStatusCode,\n type TelemetryConfig,\n} from \"./telemetry\";\n// Vite plugin and type generation\nexport { appKitTypesPlugin } from \"./type-generator/vite-plugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCgD;aAa9B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * Core library for building Databricks applications with type-safe SQL queries,\n * plugin architecture, and React integration.\n */\n\n// Types from shared\nexport type {\n BasePluginConfig,\n CacheConfig,\n IAppRouter,\n StreamExecutionSettings,\n} from \"shared\";\nexport { isSQLTypeMarker, sql } from \"shared\";\nexport { CacheManager } from \"./cache\";\nexport type {\n DatabaseCredential,\n GenerateDatabaseCredentialRequest,\n LakebasePoolConfig,\n RequestedClaims,\n RequestedResource,\n} from \"./connectors/lakebase\";\n// Lakebase Autoscaling connector\nexport {\n createLakebasePool,\n generateDatabaseCredential,\n getLakebaseOrmConfig,\n getLakebasePgConfig,\n getUsernameWithApiLookup,\n getWorkspaceClient,\n RequestedClaimsPermissionSet,\n} from \"./connectors/lakebase\";\nexport { getExecutionContext } from \"./context\";\nexport { createApp } from \"./core\";\n// Errors\nexport {\n AppKitError,\n AuthenticationError,\n ConfigurationError,\n ConnectionError,\n ExecutionError,\n InitializationError,\n ServerError,\n TunnelError,\n ValidationError,\n} from \"./errors\";\n// Plugin authoring\nexport { Plugin, type ToPlugin, toPlugin } from \"./plugin\";\nexport { analytics, lakebase, server } from \"./plugins\";\n// Registry types and utilities for plugin manifests\nexport type {\n ConfigSchema,\n PluginManifest,\n ResourceEntry,\n ResourceFieldEntry,\n ResourcePermission,\n ResourceRequirement,\n ValidationResult,\n} from \"./registry\";\nexport {\n getPluginManifest,\n getResourceRequirements,\n ResourceRegistry,\n ResourceType,\n} from \"./registry\";\n// Telemetry (for advanced custom telemetry)\nexport {\n type Counter,\n type Histogram,\n type ITelemetry,\n SeverityNumber,\n type Span,\n SpanStatusCode,\n type TelemetryConfig,\n} from \"./telemetry\";\n// Vite plugin and type generation\nexport { appKitTypesPlugin } from \"./type-generator/vite-plugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCgD;aAa9B"}
@@ -1,6 +1,9 @@
1
1
  import { analyticsManifest } from "./analytics/manifest.js";
2
2
  import { AnalyticsPlugin, analytics } from "./analytics/analytics.js";
3
3
  import "./analytics/index.js";
4
+ import { lakebaseManifest } from "./lakebase/manifest.js";
5
+ import { LakebasePlugin, lakebase } from "./lakebase/lakebase.js";
6
+ import "./lakebase/index.js";
4
7
  import { serverManifest } from "./server/manifest.js";
5
8
  import { ServerPlugin, server } from "./server/index.js";
6
9
 
@@ -0,0 +1,4 @@
1
+ import { lakebaseManifest } from "./manifest.js";
2
+ import { LakebasePlugin, lakebase } from "./lakebase.js";
3
+
4
+ export { };
@@ -0,0 +1,117 @@
1
+ import { ToPlugin } from "../../shared/src/plugin.js";
2
+ import { Plugin } from "../../plugin/plugin.js";
3
+ import { PluginManifest } from "../../registry/types.js";
4
+ import { ILakebaseConfig } from "./types.js";
5
+ import * as pg0 from "pg";
6
+ import pg from "pg";
7
+ import * as stream0 from "stream";
8
+
9
+ //#region src/plugins/lakebase/lakebase.d.ts
10
+
11
+ /**
12
+ * AppKit plugin for Databricks Lakebase Autoscaling.
13
+ *
14
+ * Wraps `@databricks/lakebase` to provide a standard `pg.Pool` with automatic
15
+ * OAuth token refresh, integrated with AppKit's logger and OpenTelemetry setup.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { createApp, lakebase, server } from "@databricks/appkit";
20
+ *
21
+ * const AppKit = await createApp({
22
+ * plugins: [server(), lakebase()],
23
+ * });
24
+ *
25
+ * const result = await AppKit.lakebase.query("SELECT * FROM users WHERE id = $1", [userId]);
26
+ * ```
27
+ */
28
+ declare class LakebasePlugin extends Plugin {
29
+ name: string;
30
+ /** Plugin manifest declaring metadata and resource requirements */
31
+ static manifest: PluginManifest;
32
+ protected config: ILakebaseConfig;
33
+ private pool;
34
+ constructor(config: ILakebaseConfig);
35
+ /**
36
+ * Initializes the Lakebase connection pool.
37
+ * Called automatically by AppKit during the plugin setup phase.
38
+ *
39
+ * Resolves the PostgreSQL username via {@link getUsernameWithApiLookup},
40
+ * which tries config, env vars, and finally the Databricks workspace API.
41
+ */
42
+ setup(): Promise<void>;
43
+ /**
44
+ * Executes a parameterized SQL query against the Lakebase pool.
45
+ *
46
+ * @param text - SQL query string, using `$1`, `$2`, ... placeholders
47
+ * @param values - Parameter values corresponding to placeholders
48
+ * @returns Query result with typed rows
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const result = await AppKit.lakebase.query<{ id: number; name: string }>(
53
+ * "SELECT id, name FROM users WHERE active = $1",
54
+ * [true],
55
+ * );
56
+ * ```
57
+ */
58
+ query<T extends pg.QueryResultRow = any>(text: string, values?: unknown[]): Promise<pg.QueryResult<T>>;
59
+ /**
60
+ * Gracefully drains and closes the connection pool.
61
+ * Called automatically by AppKit during shutdown.
62
+ */
63
+ abortActiveOperations(): void;
64
+ /**
65
+ * Returns the plugin's public API, accessible via `AppKit.lakebase`.
66
+ *
67
+ * - `pool` — The raw `pg.Pool` instance, for use with ORMs or advanced scenarios
68
+ * - `query` — Convenience method for executing parameterized SQL queries
69
+ * - `getOrmConfig()` — Returns a config object compatible with Drizzle, TypeORM, Sequelize, etc.
70
+ * - `getPgConfig()` — Returns a `pg.PoolConfig` object for manual pool construction
71
+ */
72
+ exports(): {
73
+ pool: pg0.Pool;
74
+ query: <T extends pg.QueryResultRow = any>(text: string, values?: unknown[]) => Promise<pg.QueryResult<T>>;
75
+ getOrmConfig: () => {
76
+ username: string | undefined;
77
+ password: string | (() => string) | (() => Promise<string>) | undefined;
78
+ ssl: boolean | {
79
+ rejectUnauthorized: boolean | undefined;
80
+ };
81
+ max?: number | undefined;
82
+ min?: number | undefined;
83
+ idleTimeoutMillis?: number | undefined | null;
84
+ log?: ((...messages: any[]) => void) | undefined;
85
+ Promise?: PromiseConstructorLike | undefined;
86
+ allowExitOnIdle?: boolean | undefined;
87
+ maxUses?: number | undefined;
88
+ maxLifetimeSeconds?: number | undefined;
89
+ Client?: (new () => pg0.ClientBase) | undefined;
90
+ database?: string | undefined;
91
+ port?: number | undefined;
92
+ host?: string | undefined;
93
+ connectionString?: string | undefined;
94
+ keepAlive?: boolean | undefined;
95
+ stream?: () => stream0.Duplex | undefined;
96
+ statement_timeout?: false | number | undefined;
97
+ query_timeout?: number | undefined;
98
+ lock_timeout?: number | undefined;
99
+ keepAliveInitialDelayMillis?: number | undefined;
100
+ idle_in_transaction_session_timeout?: number | undefined;
101
+ application_name?: string | undefined;
102
+ fallback_application_name?: string | undefined;
103
+ connectionTimeoutMillis?: number | undefined;
104
+ types?: pg0.CustomTypesConfig | undefined;
105
+ options?: string | undefined;
106
+ client_encoding?: string | undefined;
107
+ };
108
+ getPgConfig: () => pg0.PoolConfig;
109
+ };
110
+ }
111
+ /**
112
+ * @internal
113
+ */
114
+ declare const lakebase: ToPlugin<typeof LakebasePlugin, ILakebaseConfig, "lakebase">;
115
+ //#endregion
116
+ export { lakebase };
117
+ //# sourceMappingURL=lakebase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lakebase.d.ts","names":[],"sources":["../../../src/plugins/lakebase/lakebase.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;AA+BA;;;;;;;;;;;AA2CwB,cA3CX,cAAA,SAAuB,MAAA,CA2CT;MAGC,EAAA,MAAA;;SAAvB,QAAA,EA9CuB,cA8CvB;oBAxCuB;;sBAGN;;;;;;AA+EtB;;OAAqB,CAAA,CAAA,EAnER,OAmEQ,CAAA,IAAA,CAAA;;;;;;;;;;;;;;;;kBA7CG,EAAA,CAAG,yDAGtB,QAAQ,EAAA,CAAG,YAAY;;;;;;;;;;;;;;;UAAhB,GAAA,CAAA;sBAHY,EAAA,CAAG,2DAGtB,QAAQ,EAAA,CAAG,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Cf,UAAQ,gBAAA,gBAAA"}
@@ -0,0 +1,108 @@
1
+ import { createLogger } from "../../logging/logger.js";
2
+ import { createLakebasePool, getLakebaseOrmConfig, getLakebasePgConfig, getUsernameWithApiLookup } from "../../connectors/lakebase/index.js";
3
+ import { Plugin } from "../../plugin/plugin.js";
4
+ import { toPlugin } from "../../plugin/to-plugin.js";
5
+ import "../../plugin/index.js";
6
+ import { lakebaseManifest } from "./manifest.js";
7
+
8
+ //#region src/plugins/lakebase/lakebase.ts
9
+ const logger = createLogger("lakebase");
10
+ /**
11
+ * AppKit plugin for Databricks Lakebase Autoscaling.
12
+ *
13
+ * Wraps `@databricks/lakebase` to provide a standard `pg.Pool` with automatic
14
+ * OAuth token refresh, integrated with AppKit's logger and OpenTelemetry setup.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { createApp, lakebase, server } from "@databricks/appkit";
19
+ *
20
+ * const AppKit = await createApp({
21
+ * plugins: [server(), lakebase()],
22
+ * });
23
+ *
24
+ * const result = await AppKit.lakebase.query("SELECT * FROM users WHERE id = $1", [userId]);
25
+ * ```
26
+ */
27
+ var LakebasePlugin = class extends Plugin {
28
+ name = "lakebase";
29
+ /** Plugin manifest declaring metadata and resource requirements */
30
+ static manifest = lakebaseManifest;
31
+ pool = null;
32
+ constructor(config) {
33
+ super(config);
34
+ this.config = config;
35
+ }
36
+ /**
37
+ * Initializes the Lakebase connection pool.
38
+ * Called automatically by AppKit during the plugin setup phase.
39
+ *
40
+ * Resolves the PostgreSQL username via {@link getUsernameWithApiLookup},
41
+ * which tries config, env vars, and finally the Databricks workspace API.
42
+ */
43
+ async setup() {
44
+ const poolConfig = this.config.pool;
45
+ const user = await getUsernameWithApiLookup(poolConfig);
46
+ this.pool = createLakebasePool({
47
+ ...poolConfig,
48
+ user
49
+ });
50
+ logger.info("Lakebase pool initialized");
51
+ }
52
+ /**
53
+ * Executes a parameterized SQL query against the Lakebase pool.
54
+ *
55
+ * @param text - SQL query string, using `$1`, `$2`, ... placeholders
56
+ * @param values - Parameter values corresponding to placeholders
57
+ * @returns Query result with typed rows
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const result = await AppKit.lakebase.query<{ id: number; name: string }>(
62
+ * "SELECT id, name FROM users WHERE active = $1",
63
+ * [true],
64
+ * );
65
+ * ```
66
+ */
67
+ async query(text, values) {
68
+ return this.pool.query(text, values);
69
+ }
70
+ /**
71
+ * Gracefully drains and closes the connection pool.
72
+ * Called automatically by AppKit during shutdown.
73
+ */
74
+ abortActiveOperations() {
75
+ super.abortActiveOperations();
76
+ if (this.pool) {
77
+ logger.info("Closing Lakebase pool");
78
+ this.pool.end().catch((err) => {
79
+ logger.error("Error closing Lakebase pool: %O", err);
80
+ });
81
+ this.pool = null;
82
+ }
83
+ }
84
+ /**
85
+ * Returns the plugin's public API, accessible via `AppKit.lakebase`.
86
+ *
87
+ * - `pool` — The raw `pg.Pool` instance, for use with ORMs or advanced scenarios
88
+ * - `query` — Convenience method for executing parameterized SQL queries
89
+ * - `getOrmConfig()` — Returns a config object compatible with Drizzle, TypeORM, Sequelize, etc.
90
+ * - `getPgConfig()` — Returns a `pg.PoolConfig` object for manual pool construction
91
+ */
92
+ exports() {
93
+ return {
94
+ pool: this.pool,
95
+ query: this.query.bind(this),
96
+ getOrmConfig: () => getLakebaseOrmConfig(this.config.pool),
97
+ getPgConfig: () => getLakebasePgConfig(this.config.pool)
98
+ };
99
+ }
100
+ };
101
+ /**
102
+ * @internal
103
+ */
104
+ const lakebase = toPlugin(LakebasePlugin, "lakebase");
105
+
106
+ //#endregion
107
+ export { LakebasePlugin, lakebase };
108
+ //# sourceMappingURL=lakebase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lakebase.js","names":[],"sources":["../../../src/plugins/lakebase/lakebase.ts"],"sourcesContent":["import type pg from \"pg\";\nimport {\n createLakebasePool,\n getLakebaseOrmConfig,\n getLakebasePgConfig,\n getUsernameWithApiLookup,\n} from \"../../connectors/lakebase\";\nimport { createLogger } from \"../../logging/logger\";\nimport { Plugin, toPlugin } from \"../../plugin\";\nimport { lakebaseManifest } from \"./manifest\";\nimport type { ILakebaseConfig } from \"./types\";\n\nconst logger = createLogger(\"lakebase\");\n\n/**\n * AppKit plugin for Databricks Lakebase Autoscaling.\n *\n * Wraps `@databricks/lakebase` to provide a standard `pg.Pool` with automatic\n * OAuth token refresh, integrated with AppKit's logger and OpenTelemetry setup.\n *\n * @example\n * ```ts\n * import { createApp, lakebase, server } from \"@databricks/appkit\";\n *\n * const AppKit = await createApp({\n * plugins: [server(), lakebase()],\n * });\n *\n * const result = await AppKit.lakebase.query(\"SELECT * FROM users WHERE id = $1\", [userId]);\n * ```\n */\nexport class LakebasePlugin extends Plugin {\n name = \"lakebase\";\n\n /** Plugin manifest declaring metadata and resource requirements */\n static manifest = lakebaseManifest;\n\n protected declare config: ILakebaseConfig;\n private pool: pg.Pool | null = null;\n\n constructor(config: ILakebaseConfig) {\n super(config);\n this.config = config;\n }\n\n /**\n * Initializes the Lakebase connection pool.\n * Called automatically by AppKit during the plugin setup phase.\n *\n * Resolves the PostgreSQL username via {@link getUsernameWithApiLookup},\n * which tries config, env vars, and finally the Databricks workspace API.\n */\n async setup() {\n const poolConfig = this.config.pool;\n const user = await getUsernameWithApiLookup(poolConfig);\n this.pool = createLakebasePool({ ...poolConfig, user });\n logger.info(\"Lakebase pool initialized\");\n }\n\n /**\n * Executes a parameterized SQL query against the Lakebase pool.\n *\n * @param text - SQL query string, using `$1`, `$2`, ... placeholders\n * @param values - Parameter values corresponding to placeholders\n * @returns Query result with typed rows\n *\n * @example\n * ```ts\n * const result = await AppKit.lakebase.query<{ id: number; name: string }>(\n * \"SELECT id, name FROM users WHERE active = $1\",\n * [true],\n * );\n * ```\n */\n async query<T extends pg.QueryResultRow = any>(\n text: string,\n values?: unknown[],\n ): Promise<pg.QueryResult<T>> {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup(), which AppKit always awaits before exposing the plugin API\n return this.pool!.query<T>(text, values);\n }\n\n /**\n * Gracefully drains and closes the connection pool.\n * Called automatically by AppKit during shutdown.\n */\n abortActiveOperations(): void {\n super.abortActiveOperations();\n if (this.pool) {\n logger.info(\"Closing Lakebase pool\");\n this.pool.end().catch((err) => {\n logger.error(\"Error closing Lakebase pool: %O\", err);\n });\n this.pool = null;\n }\n }\n\n /**\n * Returns the plugin's public API, accessible via `AppKit.lakebase`.\n *\n * - `pool` — The raw `pg.Pool` instance, for use with ORMs or advanced scenarios\n * - `query` — Convenience method for executing parameterized SQL queries\n * - `getOrmConfig()` — Returns a config object compatible with Drizzle, TypeORM, Sequelize, etc.\n * - `getPgConfig()` — Returns a `pg.PoolConfig` object for manual pool construction\n */\n exports() {\n return {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup(), which AppKit always awaits before exposing the plugin API\n pool: this.pool!,\n query: this.query.bind(this),\n getOrmConfig: () => getLakebaseOrmConfig(this.config.pool),\n getPgConfig: () => getLakebasePgConfig(this.config.pool),\n };\n }\n}\n\n/**\n * @internal\n */\nexport const lakebase = toPlugin<\n typeof LakebasePlugin,\n ILakebaseConfig,\n \"lakebase\"\n>(LakebasePlugin, \"lakebase\");\n"],"mappings":";;;;;;;;AAYA,MAAM,SAAS,aAAa,WAAW;;;;;;;;;;;;;;;;;;AAmBvC,IAAa,iBAAb,cAAoC,OAAO;CACzC,OAAO;;CAGP,OAAO,WAAW;CAGlB,AAAQ,OAAuB;CAE/B,YAAY,QAAyB;AACnC,QAAM,OAAO;AACb,OAAK,SAAS;;;;;;;;;CAUhB,MAAM,QAAQ;EACZ,MAAM,aAAa,KAAK,OAAO;EAC/B,MAAM,OAAO,MAAM,yBAAyB,WAAW;AACvD,OAAK,OAAO,mBAAmB;GAAE,GAAG;GAAY;GAAM,CAAC;AACvD,SAAO,KAAK,4BAA4B;;;;;;;;;;;;;;;;;CAkB1C,MAAM,MACJ,MACA,QAC4B;AAE5B,SAAO,KAAK,KAAM,MAAS,MAAM,OAAO;;;;;;CAO1C,wBAA8B;AAC5B,QAAM,uBAAuB;AAC7B,MAAI,KAAK,MAAM;AACb,UAAO,KAAK,wBAAwB;AACpC,QAAK,KAAK,KAAK,CAAC,OAAO,QAAQ;AAC7B,WAAO,MAAM,mCAAmC,IAAI;KACpD;AACF,QAAK,OAAO;;;;;;;;;;;CAYhB,UAAU;AACR,SAAO;GAEL,MAAM,KAAK;GACX,OAAO,KAAK,MAAM,KAAK,KAAK;GAC5B,oBAAoB,qBAAqB,KAAK,OAAO,KAAK;GAC1D,mBAAmB,oBAAoB,KAAK,OAAO,KAAK;GACzD;;;;;;AAOL,MAAa,WAAW,SAItB,gBAAgB,WAAW"}
@@ -0,0 +1,11 @@
1
+ import { dirname, join } from "node:path";
2
+ import { readFileSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ //#region src/plugins/lakebase/manifest.ts
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const lakebaseManifest = JSON.parse(readFileSync(join(__dirname, "manifest.json"), "utf-8"));
8
+
9
+ //#endregion
10
+ export { lakebaseManifest };
11
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","names":[],"sources":["../../../src/plugins/lakebase/manifest.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { PluginManifest } from \"../../registry\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const lakebaseManifest: PluginManifest = JSON.parse(\n readFileSync(join(__dirname, \"manifest.json\"), \"utf-8\"),\n) as PluginManifest;\n"],"mappings":";;;;;AAKA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAa,mBAAmC,KAAK,MACnD,aAAa,KAAK,WAAW,gBAAgB,EAAE,QAAQ,CACxD"}
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://databricks.github.io/appkit/schemas/plugin-manifest.schema.json",
3
+ "name": "lakebase",
4
+ "displayName": "Lakebase",
5
+ "description": "SQL query execution against Databricks Lakebase Autoscaling",
6
+ "onSetupMessage": "Configure environment variables before running or deploying the app.\nSee: https://databricks.github.io/appkit/docs/plugins/lakebase",
7
+ "resources": {
8
+ "required": [],
9
+ "optional": []
10
+ }
11
+ }
@@ -0,0 +1,25 @@
1
+ import { BasePluginConfig } from "../../shared/src/plugin.js";
2
+ import { LakebasePoolConfig } from "../../connectors/lakebase/index.js";
3
+
4
+ //#region src/plugins/lakebase/types.d.ts
5
+
6
+ /**
7
+ * Configuration for the Lakebase plugin.
8
+ *
9
+ * The minimum required setup is via environment variables — no `pool` config
10
+ * is needed if `PGHOST`, `PGDATABASE`, and `LAKEBASE_ENDPOINT` are set.
11
+ *
12
+ * @see {@link https://github.com/databricks/appkit/blob/main/packages/lakebase/README.md} for the full configuration reference.
13
+ */
14
+ interface ILakebaseConfig extends BasePluginConfig {
15
+ /**
16
+ * Optional overrides for the underlying `pg.Pool` configuration.
17
+ * All fields are optional and fall back to environment variables or defaults.
18
+ *
19
+ * Common overrides: `max` (pool size), `connectionTimeoutMillis`, `idleTimeoutMillis`.
20
+ */
21
+ pool?: Partial<LakebasePoolConfig>;
22
+ }
23
+ //#endregion
24
+ export { ILakebaseConfig };
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/plugins/lakebase/types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;;;;;;UAAiB,eAAA,SAAwB;;;;;;;SAOhC,QAAQ"}
@@ -86,6 +86,10 @@
86
86
  "type": "string",
87
87
  "description": "SPDX license identifier",
88
88
  "examples": ["Apache-2.0", "MIT"]
89
+ },
90
+ "onSetupMessage": {
91
+ "type": "string",
92
+ "description": "Message displayed to the user after project initialization. Use this to inform about manual setup steps (e.g. environment variables, resource provisioning)."
89
93
  }
90
94
  },
91
95
  "additionalProperties": false,
@@ -65,6 +65,10 @@
65
65
  "default": false,
66
66
  "description": "When true, this plugin is required by the template and cannot be deselected during CLI init. The user will only be prompted to configure its resources. When absent or false, the plugin is optional and the user can choose whether to include it."
67
67
  },
68
+ "onSetupMessage": {
69
+ "type": "string",
70
+ "description": "Message displayed to the user after project initialization. Use this to inform about manual setup steps (e.g. environment variables, resource provisioning)."
71
+ },
68
72
  "resources": {
69
73
  "type": "object",
70
74
  "required": ["required", "optional"],
@@ -57,6 +57,7 @@ interface PluginManifest {
57
57
  config?: {
58
58
  schema: JSONSchema7;
59
59
  };
60
+ onSetupMessage?: string;
60
61
  author?: string;
61
62
  version?: string;
62
63
  repository?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../../shared/src/plugin.ts"],"sourcesContent":[],"mappings":";;;;;UAIiB,UAAA;EAAA,IAAA,EAAA,MAAA;EAAU,qBAAA,GAAA,EAAA,IAAA;OAKhB,EAAA,EAAA,OAAA,CAAA,IAAA,CAAA;cAEoB,CAAA,MAAA,EAAR,OA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