Skip to content

Commit 3e2badc

Browse files
committed
chore: fixup
1 parent 14b339e commit 3e2badc

File tree

5 files changed

+106
-6
lines changed

5 files changed

+106
-6
lines changed

docs/docs/api/appkit/Class.Plugin.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
Base abstract class for creating AppKit plugins.
44

5-
Plugins can optionally declare their resource requirements through:
6-
1. A static `manifest` property - recommended for all plugins
7-
2. A static `getResourceRequirements()` method - for dynamic requirements
5+
All plugins must declare a static `manifest` property with their metadata
6+
and resource requirements. Plugins can also implement a static
7+
`getResourceRequirements()` method for dynamic requirements based on config.
88

99
## Example
1010

1111
```typescript
1212
import { Plugin, toPlugin, PluginManifest, ResourceType } from '@databricks/appkit';
1313

14-
// Define manifest
14+
// Define manifest (required)
1515
const myManifest: PluginManifest = {
1616
name: 'myPlugin',
1717
displayName: 'My Plugin',
@@ -31,9 +31,21 @@ const myManifest: PluginManifest = {
3131
};
3232

3333
class MyPlugin extends Plugin<MyConfig> {
34-
static manifest = myManifest;
35-
// ... implementation
34+
static manifest = myManifest; // Required!
35+
36+
name = 'myPlugin';
37+
protected envVars: string[] = [];
38+
39+
async setup() {
40+
// Initialize your plugin
41+
}
42+
43+
injectRoutes(router: Router) {
44+
// Register HTTP endpoints
45+
}
3646
}
47+
48+
export const myPlugin = toPlugin(MyPlugin, 'myPlugin');
3749
```
3850

3951
## Type Parameters
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Function: getPluginManifest()
2+
3+
```ts
4+
function getPluginManifest(plugin: PluginConstructor): PluginManifest;
5+
```
6+
7+
Loads and validates the manifest from a plugin constructor.
8+
9+
All plugins must have a static `manifest` property that declares their
10+
metadata and resource requirements.
11+
12+
## Parameters
13+
14+
| Parameter | Type | Description |
15+
| ------ | ------ | ------ |
16+
| `plugin` | `PluginConstructor` | The plugin constructor class |
17+
18+
## Returns
19+
20+
[`PluginManifest`](Interface.PluginManifest.md)
21+
22+
The validated plugin manifest
23+
24+
## Throws
25+
26+
If the manifest is missing or invalid
27+
28+
## Example
29+
30+
```typescript
31+
import { AnalyticsPlugin } from '@databricks/appkit';
32+
import { getPluginManifest } from './manifest-loader';
33+
34+
const manifest = getPluginManifest(AnalyticsPlugin);
35+
console.log('Required resources:', manifest.resources.required);
36+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Function: getResourceRequirements()
2+
3+
```ts
4+
function getResourceRequirements(plugin: PluginConstructor): {
5+
alias: string;
6+
description: string;
7+
env?: string;
8+
permission: ResourcePermission;
9+
required: boolean;
10+
type: ResourceType;
11+
}[];
12+
```
13+
14+
Gets the resource requirements from a plugin's manifest.
15+
16+
Combines required and optional resources into a single array with the
17+
`required` flag set appropriately.
18+
19+
## Parameters
20+
21+
| Parameter | Type | Description |
22+
| ------ | ------ | ------ |
23+
| `plugin` | `PluginConstructor` | The plugin constructor class |
24+
25+
## Returns
26+
27+
Combined array of required and optional resources
28+
29+
## Throws
30+
31+
If the plugin manifest is missing or invalid
32+
33+
## Example
34+
35+
```typescript
36+
const resources = getResourceRequirements(AnalyticsPlugin);
37+
for (const resource of resources) {
38+
console.log(`${resource.type}: ${resource.description} (required: ${resource.required})`);
39+
}
40+
```

docs/docs/api/appkit/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ plugin architecture, and React integration.
6060
| [appKitTypesPlugin](Function.appKitTypesPlugin.md) | Vite plugin to generate types for AppKit queries. Calls generateFromEntryPoint under the hood. |
6161
| [createApp](Function.createApp.md) | Bootstraps AppKit with the provided configuration. |
6262
| [getExecutionContext](Function.getExecutionContext.md) | Get the current execution context. |
63+
| [getPluginManifest](Function.getPluginManifest.md) | Loads and validates the manifest from a plugin constructor. |
64+
| [getResourceRequirements](Function.getResourceRequirements.md) | Gets the resource requirements from a plugin's manifest. |
6365
| [isSQLTypeMarker](Function.isSQLTypeMarker.md) | Type guard to check if a value is a SQL type marker |

docs/docs/api/appkit/typedoc-sidebar.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ const typedocSidebar: SidebarsConfig = {
175175
id: "api/appkit/Function.getExecutionContext",
176176
label: "getExecutionContext"
177177
},
178+
{
179+
type: "doc",
180+
id: "api/appkit/Function.getPluginManifest",
181+
label: "getPluginManifest"
182+
},
183+
{
184+
type: "doc",
185+
id: "api/appkit/Function.getResourceRequirements",
186+
label: "getResourceRequirements"
187+
},
178188
{
179189
type: "doc",
180190
id: "api/appkit/Function.isSQLTypeMarker",

0 commit comments

Comments
 (0)