@databricks/appkit 0.26.1 → 0.27.1
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 +7 -0
- package/NOTICE.md +1 -0
- package/dist/appkit/package.js +1 -1
- package/dist/connectors/index.js +2 -0
- package/dist/connectors/jobs/client.d.ts +2 -0
- package/dist/connectors/jobs/client.js +132 -0
- package/dist/connectors/jobs/client.js.map +1 -0
- package/dist/connectors/jobs/index.d.ts +2 -0
- package/dist/connectors/jobs/index.js +3 -0
- package/dist/connectors/jobs/types.d.ts +10 -0
- package/dist/connectors/jobs/types.d.ts.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/jobs/defaults.js +45 -0
- package/dist/plugins/jobs/defaults.js.map +1 -0
- package/dist/plugins/jobs/index.d.ts +2 -0
- package/dist/plugins/jobs/index.js +3 -0
- package/dist/plugins/jobs/manifest.js +40 -0
- package/dist/plugins/jobs/manifest.js.map +1 -0
- package/dist/plugins/jobs/params.js +35 -0
- package/dist/plugins/jobs/params.js.map +1 -0
- package/dist/plugins/jobs/plugin.d.ts +66 -0
- package/dist/plugins/jobs/plugin.d.ts.map +1 -0
- package/dist/plugins/jobs/plugin.js +531 -0
- package/dist/plugins/jobs/plugin.js.map +1 -0
- package/dist/plugins/jobs/types.d.ts +84 -0
- package/dist/plugins/jobs/types.d.ts.map +1 -0
- package/dist/plugins/serving/serving.js +3 -3
- package/dist/plugins/serving/serving.js.map +1 -1
- package/dist/registry/types.generated.d.ts.map +1 -1
- package/dist/registry/types.generated.js.map +1 -1
- package/dist/schemas/plugin-manifest.generated.d.ts +5 -5
- package/dist/schemas/plugin-manifest.generated.d.ts.map +1 -1
- package/dist/shared/src/schemas/plugin-manifest.generated.d.ts +5 -5
- package/dist/shared/src/schemas/plugin-manifest.generated.d.ts.map +1 -1
- package/dist/stream/sse-writer.js +3 -4
- package/dist/stream/sse-writer.js.map +1 -1
- package/dist/stream/stream-manager.d.ts.map +1 -1
- package/dist/stream/stream-manager.js +2 -0
- package/dist/stream/stream-manager.js.map +1 -1
- package/docs/api/appkit/Interface.BasePluginConfig.md +4 -0
- package/docs/api/appkit/Interface.IJobsConfig.md +86 -0
- package/docs/api/appkit/Interface.JobAPI.md +163 -0
- package/docs/api/appkit/Interface.JobConfig.md +36 -0
- package/docs/api/appkit/Interface.JobsConnectorConfig.md +10 -0
- package/docs/api/appkit/TypeAlias.JobHandle.md +29 -0
- package/docs/api/appkit/TypeAlias.JobsExport.md +34 -0
- package/docs/api/appkit.md +6 -0
- package/docs/plugins/jobs.md +252 -0
- package/docs/plugins.md +2 -1
- package/llms.txt +7 -0
- package/package.json +2 -1
- package/sbom.cdx.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -48,6 +48,7 @@ npx @databricks/appkit docs <query>
|
|
|
48
48
|
- [Execution context](./docs/plugins/execution-context.md): AppKit manages Databricks authentication via two contexts:
|
|
49
49
|
- [Files plugin](./docs/plugins/files.md): File operations against Databricks Unity Catalog Volumes. Supports listing, reading, downloading, uploading, deleting, and previewing files with built-in caching, retry, and timeout handling via the execution interceptor pipeline.
|
|
50
50
|
- [Genie plugin](./docs/plugins/genie.md): Integrates Databricks AI/BI Genie spaces into your AppKit application, enabling natural language data queries via a conversational interface.
|
|
51
|
+
- [Jobs plugin](./docs/plugins/jobs.md): Trigger and monitor Databricks Lakeflow Jobs from your AppKit application.
|
|
51
52
|
- [Lakebase plugin](./docs/plugins/lakebase.md): Provides a PostgreSQL connection pool for Databricks Lakebase Autoscaling with automatic OAuth token refresh.
|
|
52
53
|
- [Model Serving plugin](./docs/plugins/model-serving.md): Provides an authenticated proxy to Databricks Model Serving endpoints, with invoke and streaming support.
|
|
53
54
|
- [Plugin management](./docs/plugins/plugin-management.md): AppKit includes a CLI for managing plugins. All commands are available under npx @databricks/appkit plugin.
|
|
@@ -93,7 +94,11 @@ npx @databricks/appkit docs <query>
|
|
|
93
94
|
- [Interface: FilePolicyUser](./docs/api/appkit/Interface.FilePolicyUser.md): Minimal user identity passed to the policy function.
|
|
94
95
|
- [Interface: FileResource](./docs/api/appkit/Interface.FileResource.md): Describes the file or directory being acted upon.
|
|
95
96
|
- [Interface: GenerateDatabaseCredentialRequest](./docs/api/appkit/Interface.GenerateDatabaseCredentialRequest.md): Request parameters for generating database OAuth credentials
|
|
97
|
+
- [Interface: IJobsConfig](./docs/api/appkit/Interface.IJobsConfig.md): Configuration for the Jobs plugin.
|
|
96
98
|
- [Interface: ITelemetry](./docs/api/appkit/Interface.ITelemetry.md): Plugin-facing interface for OpenTelemetry instrumentation.
|
|
99
|
+
- [Interface: JobAPI](./docs/api/appkit/Interface.JobAPI.md): User-facing API for a single configured job.
|
|
100
|
+
- [Interface: JobConfig](./docs/api/appkit/Interface.JobConfig.md): Per-job configuration options.
|
|
101
|
+
- [Interface: JobsConnectorConfig](./docs/api/appkit/Interface.JobsConnectorConfig.md): Properties
|
|
97
102
|
- [Interface: LakebasePoolConfig](./docs/api/appkit/Interface.LakebasePoolConfig.md): Configuration for creating a Lakebase connection pool
|
|
98
103
|
- [Interface: PluginManifest<TName>](./docs/api/appkit/Interface.PluginManifest.md): Plugin manifest that declares metadata and resource requirements.
|
|
99
104
|
- [Interface: RequestedClaims](./docs/api/appkit/Interface.RequestedClaims.md): Optional claims for fine-grained Unity Catalog table permissions
|
|
@@ -111,6 +116,8 @@ npx @databricks/appkit docs <query>
|
|
|
111
116
|
- [Type Alias: FileAction](./docs/api/appkit/TypeAlias.FileAction.md): Every action the files plugin can perform.
|
|
112
117
|
- [Type Alias: FilePolicy()](./docs/api/appkit/TypeAlias.FilePolicy.md): A policy function that decides whether user may perform action on
|
|
113
118
|
- [Type Alias: IAppRouter](./docs/api/appkit/TypeAlias.IAppRouter.md): Express router type for plugin route registration
|
|
119
|
+
- [Type Alias: JobHandle](./docs/api/appkit/TypeAlias.JobHandle.md): Job handle returned by appkit.jobs("etl").
|
|
120
|
+
- [Type Alias: JobsExport()](./docs/api/appkit/TypeAlias.JobsExport.md): Public API shape of the jobs plugin.
|
|
114
121
|
- [Type Alias: PluginData<T, U, N>](./docs/api/appkit/TypeAlias.PluginData.md): Tuple of plugin class, config, and name. Created by toPlugin() and passed to createApp().
|
|
115
122
|
- [Type Alias: ResourcePermission](./docs/api/appkit/TypeAlias.ResourcePermission.md): Union of all possible permission levels across all resource types.
|
|
116
123
|
- [Type Alias: ServingFactory](./docs/api/appkit/TypeAlias.ServingFactory.md): Factory function returned by AppKit.serving.
|
package/NOTICE.md
CHANGED
|
@@ -79,4 +79,5 @@ This Software contains code from the following open source projects:
|
|
|
79
79
|
| [tailwind-merge](https://www.npmjs.com/package/tailwind-merge) | 3.4.0 | MIT | https://github.com/dcastil/tailwind-merge |
|
|
80
80
|
| [vaul](https://www.npmjs.com/package/vaul) | 1.1.2 | MIT | https://vaul.emilkowal.ski/ |
|
|
81
81
|
| [ws](https://www.npmjs.com/package/ws) | 7.5.10, 8.18.3 | MIT | https://github.com/websockets/ws |
|
|
82
|
+
| [zod](https://www.npmjs.com/package/zod) | 4.3.6 | MIT | https://zod.dev |
|
|
82
83
|
|
package/dist/appkit/package.js
CHANGED
package/dist/connectors/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { FilesConnector } from "./files/client.js";
|
|
|
4
4
|
import "./files/index.js";
|
|
5
5
|
import { GenieConnector } from "./genie/client.js";
|
|
6
6
|
import "./genie/index.js";
|
|
7
|
+
import { JobsConnector } from "./jobs/client.js";
|
|
8
|
+
import "./jobs/index.js";
|
|
7
9
|
import "./lakebase-v1/index.js";
|
|
8
10
|
import { SQLWarehouseConnector } from "./sql-warehouse/client.js";
|
|
9
11
|
import "./sql-warehouse/index.js";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createLogger } from "../../logging/logger.js";
|
|
2
|
+
import { AppKitError } from "../../errors/base.js";
|
|
3
|
+
import { ExecutionError } from "../../errors/execution.js";
|
|
4
|
+
import { init_errors } from "../../errors/index.js";
|
|
5
|
+
import { TelemetryManager } from "../../telemetry/telemetry-manager.js";
|
|
6
|
+
import { SpanKind, SpanStatusCode } from "../../telemetry/index.js";
|
|
7
|
+
import { Context } from "@databricks/sdk-experimental";
|
|
8
|
+
|
|
9
|
+
//#region src/connectors/jobs/client.ts
|
|
10
|
+
init_errors();
|
|
11
|
+
const logger = createLogger("connectors:jobs");
|
|
12
|
+
var JobsConnector = class {
|
|
13
|
+
name = "jobs";
|
|
14
|
+
config;
|
|
15
|
+
telemetry;
|
|
16
|
+
telemetryMetrics;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.telemetry = TelemetryManager.getProvider(this.name, this.config.telemetry);
|
|
20
|
+
this.telemetryMetrics = {
|
|
21
|
+
apiCallCount: this.telemetry.getMeter().createCounter("jobs.api_call.count", {
|
|
22
|
+
description: "Total number of Jobs API calls",
|
|
23
|
+
unit: "1"
|
|
24
|
+
}),
|
|
25
|
+
apiCallDuration: this.telemetry.getMeter().createHistogram("jobs.api_call.duration", {
|
|
26
|
+
description: "Duration of Jobs API calls",
|
|
27
|
+
unit: "ms"
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async submitRun(workspaceClient, request, signal) {
|
|
32
|
+
return this._callApi("submit", async () => {
|
|
33
|
+
return workspaceClient.jobs.submit(request, this._createContext(signal));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async runNow(workspaceClient, request, signal) {
|
|
37
|
+
return this._callApi("runNow", async () => {
|
|
38
|
+
return workspaceClient.jobs.runNow(request, this._createContext(signal));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async getRun(workspaceClient, request, signal) {
|
|
42
|
+
return this._callApi("getRun", async () => {
|
|
43
|
+
return workspaceClient.jobs.getRun(request, this._createContext(signal));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async getRunOutput(workspaceClient, request, signal) {
|
|
47
|
+
return this._callApi("getRunOutput", async () => {
|
|
48
|
+
return workspaceClient.jobs.getRunOutput(request, this._createContext(signal));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async cancelRun(workspaceClient, request, signal) {
|
|
52
|
+
await this._callApi("cancelRun", async () => {
|
|
53
|
+
return workspaceClient.jobs.cancelRun(request, this._createContext(signal));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async listRuns(workspaceClient, request, signal) {
|
|
57
|
+
return this._callApi("listRuns", async () => {
|
|
58
|
+
const runs = [];
|
|
59
|
+
const limit = Math.max(1, Math.min(request.limit ?? 100, 100));
|
|
60
|
+
for await (const run of workspaceClient.jobs.listRuns({
|
|
61
|
+
...request,
|
|
62
|
+
limit
|
|
63
|
+
}, this._createContext(signal))) {
|
|
64
|
+
runs.push(run);
|
|
65
|
+
if (runs.length >= limit) break;
|
|
66
|
+
}
|
|
67
|
+
return runs;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async getJob(workspaceClient, request, signal) {
|
|
71
|
+
return this._callApi("getJob", async () => {
|
|
72
|
+
return workspaceClient.jobs.get(request, this._createContext(signal));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async _callApi(operation, fn) {
|
|
76
|
+
const startTime = Date.now();
|
|
77
|
+
let success = false;
|
|
78
|
+
return this.telemetry.startActiveSpan(`jobs.${operation}`, {
|
|
79
|
+
kind: SpanKind.CLIENT,
|
|
80
|
+
attributes: { "jobs.operation": operation }
|
|
81
|
+
}, async (span) => {
|
|
82
|
+
try {
|
|
83
|
+
const result = await fn();
|
|
84
|
+
success = true;
|
|
85
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
86
|
+
return result;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
span.recordException(error);
|
|
89
|
+
span.setStatus({
|
|
90
|
+
code: SpanStatusCode.ERROR,
|
|
91
|
+
message: error instanceof Error ? error.message : String(error)
|
|
92
|
+
});
|
|
93
|
+
if (error instanceof AppKitError) throw error;
|
|
94
|
+
if (error instanceof Error && "statusCode" in error && typeof error.statusCode === "number") throw error;
|
|
95
|
+
throw new ExecutionError(`Jobs API call failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
96
|
+
} finally {
|
|
97
|
+
const duration = Date.now() - startTime;
|
|
98
|
+
span.end();
|
|
99
|
+
this.telemetryMetrics.apiCallCount.add(1, {
|
|
100
|
+
operation,
|
|
101
|
+
success: success.toString()
|
|
102
|
+
});
|
|
103
|
+
this.telemetryMetrics.apiCallDuration.record(duration, {
|
|
104
|
+
operation,
|
|
105
|
+
success: success.toString()
|
|
106
|
+
});
|
|
107
|
+
logger.event()?.setContext("jobs", {
|
|
108
|
+
operation,
|
|
109
|
+
duration_ms: duration,
|
|
110
|
+
success
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
name: this.name,
|
|
115
|
+
includePrefix: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
_createContext(signal) {
|
|
119
|
+
return new Context({ cancellationToken: {
|
|
120
|
+
get isCancellationRequested() {
|
|
121
|
+
return signal?.aborted ?? false;
|
|
122
|
+
},
|
|
123
|
+
onCancellationRequested: (cb) => {
|
|
124
|
+
signal?.addEventListener("abort", cb, { once: true });
|
|
125
|
+
}
|
|
126
|
+
} });
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { JobsConnector };
|
|
132
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../../src/connectors/jobs/client.ts"],"sourcesContent":["import {\n Context,\n type jobs,\n type WorkspaceClient,\n} from \"@databricks/sdk-experimental\";\nimport { AppKitError, ExecutionError } from \"../../errors\";\nimport { createLogger } from \"../../logging/logger\";\nimport type { TelemetryProvider } from \"../../telemetry\";\nimport {\n type Counter,\n type Histogram,\n type Span,\n SpanKind,\n SpanStatusCode,\n TelemetryManager,\n} from \"../../telemetry\";\nimport type { JobsConnectorConfig } from \"./types\";\n\nconst logger = createLogger(\"connectors:jobs\");\n\nexport class JobsConnector {\n private readonly name = \"jobs\";\n private readonly config: JobsConnectorConfig;\n private readonly telemetry: TelemetryProvider;\n private readonly telemetryMetrics: {\n apiCallCount: Counter;\n apiCallDuration: Histogram;\n };\n\n constructor(config: JobsConnectorConfig) {\n this.config = config;\n this.telemetry = TelemetryManager.getProvider(\n this.name,\n this.config.telemetry,\n );\n this.telemetryMetrics = {\n apiCallCount: this.telemetry\n .getMeter()\n .createCounter(\"jobs.api_call.count\", {\n description: \"Total number of Jobs API calls\",\n unit: \"1\",\n }),\n apiCallDuration: this.telemetry\n .getMeter()\n .createHistogram(\"jobs.api_call.duration\", {\n description: \"Duration of Jobs API calls\",\n unit: \"ms\",\n }),\n };\n }\n\n async submitRun(\n workspaceClient: WorkspaceClient,\n request: jobs.SubmitRun,\n signal?: AbortSignal,\n ): Promise<jobs.SubmitRunResponse> {\n return this._callApi(\"submit\", async () => {\n return workspaceClient.jobs.submit(request, this._createContext(signal));\n });\n }\n\n async runNow(\n workspaceClient: WorkspaceClient,\n request: jobs.RunNow,\n signal?: AbortSignal,\n ): Promise<jobs.RunNowResponse> {\n return this._callApi(\"runNow\", async () => {\n return workspaceClient.jobs.runNow(request, this._createContext(signal));\n });\n }\n\n async getRun(\n workspaceClient: WorkspaceClient,\n request: jobs.GetRunRequest,\n signal?: AbortSignal,\n ): Promise<jobs.Run> {\n return this._callApi(\"getRun\", async () => {\n return workspaceClient.jobs.getRun(request, this._createContext(signal));\n });\n }\n\n async getRunOutput(\n workspaceClient: WorkspaceClient,\n request: jobs.GetRunOutputRequest,\n signal?: AbortSignal,\n ): Promise<jobs.RunOutput> {\n return this._callApi(\"getRunOutput\", async () => {\n return workspaceClient.jobs.getRunOutput(\n request,\n this._createContext(signal),\n );\n });\n }\n\n async cancelRun(\n workspaceClient: WorkspaceClient,\n request: jobs.CancelRun,\n signal?: AbortSignal,\n ): Promise<void> {\n await this._callApi(\"cancelRun\", async () => {\n return workspaceClient.jobs.cancelRun(\n request,\n this._createContext(signal),\n );\n });\n }\n\n async listRuns(\n workspaceClient: WorkspaceClient,\n request: jobs.ListRunsRequest,\n signal?: AbortSignal,\n ): Promise<jobs.BaseRun[]> {\n return this._callApi(\"listRuns\", async () => {\n const runs: jobs.BaseRun[] = [];\n const limit = Math.max(1, Math.min(request.limit ?? 100, 100));\n for await (const run of workspaceClient.jobs.listRuns(\n { ...request, limit },\n this._createContext(signal),\n )) {\n runs.push(run);\n if (runs.length >= limit) break;\n }\n return runs;\n });\n }\n\n async getJob(\n workspaceClient: WorkspaceClient,\n request: jobs.GetJobRequest,\n signal?: AbortSignal,\n ): Promise<jobs.Job> {\n return this._callApi(\"getJob\", async () => {\n return workspaceClient.jobs.get(request, this._createContext(signal));\n });\n }\n\n private async _callApi<T>(\n operation: string,\n fn: () => Promise<T>,\n ): Promise<T> {\n const startTime = Date.now();\n let success = false;\n\n return this.telemetry.startActiveSpan(\n `jobs.${operation}`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n \"jobs.operation\": operation,\n },\n },\n async (span: Span) => {\n try {\n const result = await fn();\n success = true;\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n if (error instanceof AppKitError) {\n throw error;\n }\n // Preserve SDK ApiError (and any error with a numeric statusCode)\n // so Plugin.execute() can map it to the correct HTTP status.\n if (\n error instanceof Error &&\n \"statusCode\" in error &&\n typeof (error as Record<string, unknown>).statusCode === \"number\"\n ) {\n throw error;\n }\n throw new ExecutionError(\n `Jobs API call failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n } finally {\n const duration = Date.now() - startTime;\n span.end();\n this.telemetryMetrics.apiCallCount.add(1, {\n operation,\n success: success.toString(),\n });\n this.telemetryMetrics.apiCallDuration.record(duration, {\n operation,\n success: success.toString(),\n });\n\n logger.event()?.setContext(\"jobs\", {\n operation,\n duration_ms: duration,\n success,\n });\n }\n },\n { name: this.name, includePrefix: true },\n );\n }\n\n private _createContext(signal?: AbortSignal) {\n return new Context({\n cancellationToken: {\n // Getter — evaluated on every read so SDK code paths that poll\n // (rather than subscribe) observe cancellation live.\n get isCancellationRequested() {\n return signal?.aborted ?? false;\n },\n onCancellationRequested: (cb: () => void) => {\n signal?.addEventListener(\"abort\", cb, { once: true });\n },\n },\n });\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TelemetryOptions } from "../../shared/src/plugin.js";
|
|
2
|
+
import "../../shared/src/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/connectors/jobs/types.d.ts
|
|
5
|
+
interface JobsConnectorConfig {
|
|
6
|
+
telemetry?: TelemetryOptions;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { JobsConnectorConfig };
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/connectors/jobs/types.ts"],"mappings":";;;;UAEiB,mBAAA;EACf,SAAA,GAAY,gBAAA;AAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { StreamExecutionSettings } from "./shared/src/execute.js";
|
|
|
5
5
|
import { isSQLTypeMarker, sql } from "./shared/src/sql/helpers.js";
|
|
6
6
|
import "./shared/src/index.js";
|
|
7
7
|
import { CacheManager } from "./cache/index.js";
|
|
8
|
+
import { JobsConnectorConfig } from "./connectors/jobs/types.js";
|
|
9
|
+
import "./connectors/jobs/index.js";
|
|
8
10
|
import { DatabaseCredential, GenerateDatabaseCredentialRequest, LakebasePoolConfig, RequestedClaims, RequestedClaimsPermissionSet, RequestedResource, createLakebasePool, generateDatabaseCredential, getLakebaseOrmConfig, getLakebasePgConfig, getUsernameWithApiLookup, getWorkspaceClient } from "./connectors/lakebase/index.js";
|
|
9
11
|
import { getExecutionContext } from "./context/execution-context.js";
|
|
10
12
|
import "./context/index.js";
|
|
@@ -34,6 +36,9 @@ import { analytics } from "./plugins/analytics/analytics.js";
|
|
|
34
36
|
import { FileAction, FilePolicy, FilePolicyUser, FileResource, PolicyDeniedError, READ_ACTIONS, WRITE_ACTIONS } from "./plugins/files/policy.js";
|
|
35
37
|
import { files } from "./plugins/files/plugin.js";
|
|
36
38
|
import { genie } from "./plugins/genie/genie.js";
|
|
39
|
+
import { IJobsConfig, JobAPI, JobConfig, JobHandle, JobsExport } from "./plugins/jobs/types.js";
|
|
40
|
+
import { jobs } from "./plugins/jobs/plugin.js";
|
|
41
|
+
import "./plugins/jobs/index.js";
|
|
37
42
|
import { lakebase } from "./plugins/lakebase/lakebase.js";
|
|
38
43
|
import { server } from "./plugins/server/index.js";
|
|
39
44
|
import { EndpointConfig, ServingEndpointEntry, ServingEndpointRegistry, ServingFactory } from "./plugins/serving/types.js";
|
|
@@ -42,4 +47,4 @@ import "./plugins/index.js";
|
|
|
42
47
|
import { extractServingEndpoints, findServerFile } from "./type-generator/serving/server-file-extractor.js";
|
|
43
48
|
import { appKitServingTypesPlugin } from "./type-generator/serving/vite-plugin.js";
|
|
44
49
|
import { appKitTypesPlugin } from "./type-generator/vite-plugin.js";
|
|
45
|
-
export { AppKitError, AuthenticationError, type BasePluginConfig, type CacheConfig, CacheManager, type ConfigSchema, ConfigurationError, ConnectionError, type Counter, type DatabaseCredential, type EndpointConfig, ExecutionError, type ExecutionResult, type FileAction, type FilePolicy, type FilePolicyUser, type FileResource, type GenerateDatabaseCredentialRequest, type Histogram, type IAppRouter, type ITelemetry, InitializationError, type LakebasePoolConfig, Plugin, type PluginData, type PluginManifest, PolicyDeniedError, READ_ACTIONS, type RequestedClaims, RequestedClaimsPermissionSet, type RequestedResource, type ResourceEntry, type ResourceFieldEntry, type ResourcePermission, ResourceRegistry, type ResourceRequirement, ResourceType, ServerError, type ServingEndpointEntry, type ServingEndpointRegistry, type ServingFactory, SeverityNumber, type Span, SpanStatusCode, type StreamExecutionSettings, type TelemetryConfig, type ToPlugin, TunnelError, ValidationError, type ValidationResult, WRITE_ACTIONS, analytics, appKitServingTypesPlugin, appKitTypesPlugin, createApp, createLakebasePool, extractServingEndpoints, files, findServerFile, generateDatabaseCredential, genie, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, lakebase, server, serving, sql, toPlugin };
|
|
50
|
+
export { AppKitError, AuthenticationError, type BasePluginConfig, type CacheConfig, CacheManager, type ConfigSchema, ConfigurationError, ConnectionError, type Counter, type DatabaseCredential, type EndpointConfig, ExecutionError, type ExecutionResult, type FileAction, type FilePolicy, type FilePolicyUser, type FileResource, type GenerateDatabaseCredentialRequest, type Histogram, type IAppRouter, type IJobsConfig, type ITelemetry, InitializationError, type JobAPI, type JobConfig, type JobHandle, type JobsConnectorConfig, type JobsExport, type LakebasePoolConfig, Plugin, type PluginData, type PluginManifest, PolicyDeniedError, READ_ACTIONS, type RequestedClaims, RequestedClaimsPermissionSet, type RequestedResource, type ResourceEntry, type ResourceFieldEntry, type ResourcePermission, ResourceRegistry, type ResourceRequirement, ResourceType, ServerError, type ServingEndpointEntry, type ServingEndpointRegistry, type ServingFactory, SeverityNumber, type Span, SpanStatusCode, type StreamExecutionSettings, type TelemetryConfig, type ToPlugin, TunnelError, ValidationError, type ValidationResult, WRITE_ACTIONS, analytics, appKitServingTypesPlugin, appKitTypesPlugin, createApp, createLakebasePool, extractServingEndpoints, files, findServerFile, generateDatabaseCredential, genie, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, jobs, lakebase, server, serving, sql, toPlugin };
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import { analytics } from "./plugins/analytics/analytics.js";
|
|
|
27
27
|
import { PolicyDeniedError, READ_ACTIONS, WRITE_ACTIONS } from "./plugins/files/policy.js";
|
|
28
28
|
import { files } from "./plugins/files/plugin.js";
|
|
29
29
|
import { genie } from "./plugins/genie/genie.js";
|
|
30
|
+
import { jobs } from "./plugins/jobs/plugin.js";
|
|
30
31
|
import { lakebase } from "./plugins/lakebase/lakebase.js";
|
|
31
32
|
import { extractServingEndpoints, findServerFile } from "./type-generator/serving/server-file-extractor.js";
|
|
32
33
|
import { appKitServingTypesPlugin } from "./type-generator/serving/vite-plugin.js";
|
|
@@ -40,5 +41,5 @@ init_context();
|
|
|
40
41
|
init_errors();
|
|
41
42
|
|
|
42
43
|
//#endregion
|
|
43
|
-
export { AppKitError, AuthenticationError, CacheManager, ConfigurationError, ConnectionError, ExecutionError, InitializationError, Plugin, PolicyDeniedError, READ_ACTIONS, RequestedClaimsPermissionSet, ResourceRegistry, ResourceType, ServerError, SeverityNumber, SpanStatusCode, TunnelError, ValidationError, WRITE_ACTIONS, analytics, appKitServingTypesPlugin, appKitTypesPlugin, createApp, createLakebasePool, extractServingEndpoints, files, findServerFile, generateDatabaseCredential, genie, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, lakebase, server, serving, sql, toPlugin };
|
|
44
|
+
export { AppKitError, AuthenticationError, CacheManager, ConfigurationError, ConnectionError, ExecutionError, InitializationError, Plugin, PolicyDeniedError, READ_ACTIONS, RequestedClaimsPermissionSet, ResourceRegistry, ResourceType, ServerError, SeverityNumber, SpanStatusCode, TunnelError, ValidationError, WRITE_ACTIONS, analytics, appKitServingTypesPlugin, appKitTypesPlugin, createApp, createLakebasePool, extractServingEndpoints, files, findServerFile, generateDatabaseCredential, genie, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, jobs, lakebase, server, serving, sql, toPlugin };
|
|
44
45
|
//# 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 PluginData,\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 {\n type ExecutionResult,\n Plugin,\n type ToPlugin,\n toPlugin,\n} from \"./plugin\";\nexport {
|
|
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 PluginData,\n StreamExecutionSettings,\n} from \"shared\";\nexport { isSQLTypeMarker, sql } from \"shared\";\nexport { CacheManager } from \"./cache\";\nexport type { JobsConnectorConfig } from \"./connectors/jobs\";\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 {\n type ExecutionResult,\n Plugin,\n type ToPlugin,\n toPlugin,\n} from \"./plugin\";\nexport {\n analytics,\n files,\n genie,\n jobs,\n lakebase,\n server,\n serving,\n} from \"./plugins\";\n// Files plugin types (for custom policy authoring)\nexport type {\n FileAction,\n FilePolicy,\n FilePolicyUser,\n FileResource,\n} from \"./plugins/files/policy\";\nexport {\n PolicyDeniedError,\n READ_ACTIONS,\n WRITE_ACTIONS,\n} from \"./plugins/files/policy\";\nexport type {\n IJobsConfig,\n JobAPI,\n JobConfig,\n JobHandle,\n JobsExport,\n} from \"./plugins/jobs\";\nexport type {\n EndpointConfig,\n ServingEndpointEntry,\n ServingEndpointRegistry,\n ServingFactory,\n} from \"./plugins/serving/types\";\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\";\nexport {\n extractServingEndpoints,\n findServerFile,\n} from \"./type-generator/serving/server-file-extractor\";\nexport { appKitServingTypesPlugin } from \"./type-generator/serving/vite-plugin\";\n// Vite plugin and type generation\nexport { appKitTypesPlugin } from \"./type-generator/vite-plugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmCgD;aAa9B"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ import { GenieConversationHistoryResponse } from "../connectors/genie/types.js";
|
|
|
9
9
|
import { IGenieConfig } from "./genie/types.js";
|
|
10
10
|
import { GeniePlugin, genie } from "./genie/genie.js";
|
|
11
11
|
import "./genie/index.js";
|
|
12
|
+
import { IJobsConfig, JobAPI, JobConfig, JobHandle, JobsExport } from "./jobs/types.js";
|
|
13
|
+
import { jobs } from "./jobs/plugin.js";
|
|
14
|
+
import "./jobs/index.js";
|
|
12
15
|
import { ILakebaseConfig } from "./lakebase/types.js";
|
|
13
16
|
import { lakebase } from "./lakebase/lakebase.js";
|
|
14
17
|
import "./lakebase/index.js";
|
package/dist/plugins/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import { FilesPlugin, files } from "./files/plugin.js";
|
|
|
5
5
|
import "./files/index.js";
|
|
6
6
|
import { GeniePlugin, genie } from "./genie/genie.js";
|
|
7
7
|
import "./genie/index.js";
|
|
8
|
+
import { jobs } from "./jobs/plugin.js";
|
|
9
|
+
import "./jobs/index.js";
|
|
8
10
|
import { lakebase } from "./lakebase/lakebase.js";
|
|
9
11
|
import "./lakebase/index.js";
|
|
10
12
|
import { ServerPlugin, server } from "./server/index.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/plugins/jobs/defaults.ts
|
|
2
|
+
/**
|
|
3
|
+
* Execution defaults for read-tier operations (getRun, getJob, listRuns, lastRun, getRunOutput).
|
|
4
|
+
* Cache 60s (ttl in seconds)
|
|
5
|
+
* Retry 3x with 1s backoff
|
|
6
|
+
* Timeout 30s
|
|
7
|
+
*/
|
|
8
|
+
const JOBS_READ_DEFAULTS = {
|
|
9
|
+
cache: {
|
|
10
|
+
enabled: true,
|
|
11
|
+
ttl: 60
|
|
12
|
+
},
|
|
13
|
+
retry: {
|
|
14
|
+
enabled: true,
|
|
15
|
+
initialDelay: 1e3,
|
|
16
|
+
attempts: 3
|
|
17
|
+
},
|
|
18
|
+
timeout: 3e4
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Execution defaults for write-tier operations (runNow, cancelRun).
|
|
22
|
+
* No cache
|
|
23
|
+
* No retry
|
|
24
|
+
* Timeout 120s
|
|
25
|
+
*/
|
|
26
|
+
const JOBS_WRITE_DEFAULTS = {
|
|
27
|
+
cache: { enabled: false },
|
|
28
|
+
retry: { enabled: false },
|
|
29
|
+
timeout: 12e4
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Execution defaults for stream-tier operations (runNowAndWait with polling).
|
|
33
|
+
* No cache
|
|
34
|
+
* No retry
|
|
35
|
+
* Timeout 600s
|
|
36
|
+
*/
|
|
37
|
+
const JOBS_STREAM_DEFAULTS = {
|
|
38
|
+
cache: { enabled: false },
|
|
39
|
+
retry: { enabled: false },
|
|
40
|
+
timeout: 6e5
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { JOBS_READ_DEFAULTS, JOBS_STREAM_DEFAULTS, JOBS_WRITE_DEFAULTS };
|
|
45
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":[],"sources":["../../../src/plugins/jobs/defaults.ts"],"sourcesContent":["import type { PluginExecuteConfig } from \"shared\";\n\n/**\n * Execution defaults for read-tier operations (getRun, getJob, listRuns, lastRun, getRunOutput).\n * Cache 60s (ttl in seconds)\n * Retry 3x with 1s backoff\n * Timeout 30s\n */\nexport const JOBS_READ_DEFAULTS: PluginExecuteConfig = {\n cache: { enabled: true, ttl: 60 },\n retry: { enabled: true, initialDelay: 1000, attempts: 3 },\n timeout: 30_000,\n};\n\n/**\n * Execution defaults for write-tier operations (runNow, cancelRun).\n * No cache\n * No retry\n * Timeout 120s\n */\nexport const JOBS_WRITE_DEFAULTS: PluginExecuteConfig = {\n cache: { enabled: false },\n retry: { enabled: false },\n timeout: 120_000,\n};\n\n/**\n * Execution defaults for stream-tier operations (runNowAndWait with polling).\n * No cache\n * No retry\n * Timeout 600s\n */\nexport const JOBS_STREAM_DEFAULTS: PluginExecuteConfig = {\n cache: { enabled: false },\n retry: { enabled: false },\n timeout: 600_000,\n};\n"],"mappings":";;;;;;;AAQA,MAAa,qBAA0C;CACrD,OAAO;EAAE,SAAS;EAAM,KAAK;EAAI;CACjC,OAAO;EAAE,SAAS;EAAM,cAAc;EAAM,UAAU;EAAG;CACzD,SAAS;CACV;;;;;;;AAQD,MAAa,sBAA2C;CACtD,OAAO,EAAE,SAAS,OAAO;CACzB,OAAO,EAAE,SAAS,OAAO;CACzB,SAAS;CACV;;;;;;;AAQD,MAAa,uBAA4C;CACvD,OAAO,EAAE,SAAS,OAAO;CACzB,OAAO,EAAE,SAAS,OAAO;CACzB,SAAS;CACV"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/plugins/jobs/manifest.json
|
|
2
|
+
var manifest_default = {
|
|
3
|
+
$schema: "https://databricks.github.io/appkit/schemas/plugin-manifest.schema.json",
|
|
4
|
+
name: "jobs",
|
|
5
|
+
displayName: "Jobs Plugin",
|
|
6
|
+
description: "Manage Databricks Lakeflow Jobs.",
|
|
7
|
+
resources: {
|
|
8
|
+
"required": [{
|
|
9
|
+
"type": "job",
|
|
10
|
+
"alias": "Job",
|
|
11
|
+
"resourceKey": "job",
|
|
12
|
+
"description": "A Databricks job to trigger and monitor",
|
|
13
|
+
"permission": "CAN_MANAGE_RUN",
|
|
14
|
+
"fields": { "id": {
|
|
15
|
+
"env": "DATABRICKS_JOB_ID",
|
|
16
|
+
"description": "Numeric Databricks job ID. Find it in the Jobs UI or via `databricks jobs list`."
|
|
17
|
+
} }
|
|
18
|
+
}],
|
|
19
|
+
"optional": []
|
|
20
|
+
},
|
|
21
|
+
config: { "schema": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"timeout": {
|
|
25
|
+
"type": "number",
|
|
26
|
+
"default": 6e4,
|
|
27
|
+
"description": "Default timeout for Jobs API calls in milliseconds"
|
|
28
|
+
},
|
|
29
|
+
"pollIntervalMs": {
|
|
30
|
+
"type": "number",
|
|
31
|
+
"default": 5e3,
|
|
32
|
+
"description": "Poll interval for waiting on run completion in milliseconds"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
} }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { manifest_default as default };
|
|
40
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","names":[],"sources":["../../../src/plugins/jobs/manifest.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/plugins/jobs/params.ts
|
|
2
|
+
/** Throw if any value is not a string, number, or boolean. */
|
|
3
|
+
function assertPrimitiveValues(params) {
|
|
4
|
+
for (const [k, v] of Object.entries(params)) if (v !== null && v !== void 0 && typeof v === "object") throw new Error(`Parameter "${k}" must be a primitive value, got ${Array.isArray(v) ? "array" : "object"}`);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Maps validated parameters to SDK request fields based on the task type.
|
|
8
|
+
* This is a pure function — stateless and testable in isolation.
|
|
9
|
+
*/
|
|
10
|
+
function mapParams(taskType, params) {
|
|
11
|
+
switch (taskType) {
|
|
12
|
+
case "notebook":
|
|
13
|
+
assertPrimitiveValues(params);
|
|
14
|
+
return { notebook_params: Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])) };
|
|
15
|
+
case "python_wheel":
|
|
16
|
+
assertPrimitiveValues(params);
|
|
17
|
+
return { python_named_params: Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])) };
|
|
18
|
+
case "python_script": return { python_params: Array.isArray(params.args) ? params.args.map(String) : [] };
|
|
19
|
+
case "spark_jar": return { jar_params: Array.isArray(params.args) ? params.args.map(String) : [] };
|
|
20
|
+
case "sql":
|
|
21
|
+
assertPrimitiveValues(params);
|
|
22
|
+
return { sql_params: Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])) };
|
|
23
|
+
case "dbt":
|
|
24
|
+
if (Object.keys(params).length > 0) throw new Error("dbt tasks do not accept parameters");
|
|
25
|
+
return {};
|
|
26
|
+
default: {
|
|
27
|
+
const _exhaustive = taskType;
|
|
28
|
+
throw new Error(`Unknown task type: ${_exhaustive}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { mapParams };
|
|
35
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","names":[],"sources":["../../../src/plugins/jobs/params.ts"],"sourcesContent":["import type { TaskType } from \"./types\";\n\n/** Throw if any value is not a string, number, or boolean. */\nfunction assertPrimitiveValues(params: Record<string, unknown>): void {\n for (const [k, v] of Object.entries(params)) {\n if (v !== null && v !== undefined && typeof v === \"object\") {\n throw new Error(\n `Parameter \"${k}\" must be a primitive value, got ${Array.isArray(v) ? \"array\" : \"object\"}`,\n );\n }\n }\n}\n\n/**\n * Maps validated parameters to SDK request fields based on the task type.\n * This is a pure function — stateless and testable in isolation.\n */\nexport function mapParams(\n taskType: TaskType,\n params: Record<string, unknown>,\n): Record<string, unknown> {\n switch (taskType) {\n case \"notebook\":\n // notebook_params expects Record<string, string>, values coerced to string\n assertPrimitiveValues(params);\n return {\n notebook_params: Object.fromEntries(\n Object.entries(params).map(([k, v]) => [k, String(v)]),\n ),\n };\n case \"python_wheel\":\n assertPrimitiveValues(params);\n return {\n python_named_params: Object.fromEntries(\n Object.entries(params).map(([k, v]) => [k, String(v)]),\n ),\n };\n case \"python_script\":\n // python_params expects string[] (positional args)\n return {\n python_params: Array.isArray(params.args)\n ? params.args.map(String)\n : [],\n };\n case \"spark_jar\":\n // jar_params expects string[]\n return {\n jar_params: Array.isArray(params.args) ? params.args.map(String) : [],\n };\n case \"sql\":\n assertPrimitiveValues(params);\n return {\n sql_params: Object.fromEntries(\n Object.entries(params).map(([k, v]) => [k, String(v)]),\n ),\n };\n case \"dbt\":\n if (Object.keys(params).length > 0) {\n throw new Error(\"dbt tasks do not accept parameters\");\n }\n return {};\n default: {\n const _exhaustive: never = taskType;\n throw new Error(`Unknown task type: ${_exhaustive}`);\n }\n }\n}\n"],"mappings":";;AAGA,SAAS,sBAAsB,QAAuC;AACpE,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,OAAO,CACzC,KAAI,MAAM,QAAQ,MAAM,UAAa,OAAO,MAAM,SAChD,OAAM,IAAI,MACR,cAAc,EAAE,mCAAmC,MAAM,QAAQ,EAAE,GAAG,UAAU,WACjF;;;;;;AASP,SAAgB,UACd,UACA,QACyB;AACzB,SAAQ,UAAR;EACE,KAAK;AAEH,yBAAsB,OAAO;AAC7B,UAAO,EACL,iBAAiB,OAAO,YACtB,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,CACvD,EACF;EACH,KAAK;AACH,yBAAsB,OAAO;AAC7B,UAAO,EACL,qBAAqB,OAAO,YAC1B,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,CACvD,EACF;EACH,KAAK,gBAEH,QAAO,EACL,eAAe,MAAM,QAAQ,OAAO,KAAK,GACrC,OAAO,KAAK,IAAI,OAAO,GACvB,EAAE,EACP;EACH,KAAK,YAEH,QAAO,EACL,YAAY,MAAM,QAAQ,OAAO,KAAK,GAAG,OAAO,KAAK,IAAI,OAAO,GAAG,EAAE,EACtE;EACH,KAAK;AACH,yBAAsB,OAAO;AAC7B,UAAO,EACL,YAAY,OAAO,YACjB,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,CACvD,EACF;EACH,KAAK;AACH,OAAI,OAAO,KAAK,OAAO,CAAC,SAAS,EAC/B,OAAM,IAAI,MAAM,qCAAqC;AAEvD,UAAO,EAAE;EACX,SAAS;GACP,MAAM,cAAqB;AAC3B,SAAM,IAAI,MAAM,sBAAsB,cAAc"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IAppRouter, ToPlugin } from "../../shared/src/plugin.js";
|
|
2
|
+
import "../../shared/src/index.js";
|
|
3
|
+
import { Plugin } from "../../plugin/plugin.js";
|
|
4
|
+
import "../../plugin/index.js";
|
|
5
|
+
import { PluginManifest, ResourceRequirement } from "../../registry/types.js";
|
|
6
|
+
import "../../registry/index.js";
|
|
7
|
+
import { IJobsConfig, JobAPI, JobConfig, JobsExport } from "./types.js";
|
|
8
|
+
|
|
9
|
+
//#region src/plugins/jobs/plugin.d.ts
|
|
10
|
+
declare class JobsPlugin extends Plugin {
|
|
11
|
+
static manifest: PluginManifest;
|
|
12
|
+
protected config: IJobsConfig;
|
|
13
|
+
private connector;
|
|
14
|
+
private jobIds;
|
|
15
|
+
private jobConfigs;
|
|
16
|
+
private jobKeys;
|
|
17
|
+
/**
|
|
18
|
+
* Scans process.env for DATABRICKS_JOB_* keys and merges with explicit config.
|
|
19
|
+
* Explicit config wins for per-job overrides; auto-discovered jobs get default `{}` config.
|
|
20
|
+
*/
|
|
21
|
+
static discoverJobs(config: IJobsConfig): Record<string, JobConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Generates resource requirements dynamically from discovered + configured jobs.
|
|
24
|
+
* Each job key maps to a `DATABRICKS_JOB_{KEY_UPPERCASE}` env var (or `DATABRICKS_JOB_ID` for "default").
|
|
25
|
+
*/
|
|
26
|
+
static getResourceRequirements(config: IJobsConfig): ResourceRequirement[];
|
|
27
|
+
constructor(config: IJobsConfig);
|
|
28
|
+
setup(): Promise<void>;
|
|
29
|
+
private get client();
|
|
30
|
+
private getJobId;
|
|
31
|
+
private _readSettings;
|
|
32
|
+
private _writeSettings;
|
|
33
|
+
/**
|
|
34
|
+
* Validates params against the job's Zod schema (if any) and maps them
|
|
35
|
+
* to SDK request fields based on the task type. Shared by runNow and runAndWait.
|
|
36
|
+
*/
|
|
37
|
+
private _validateAndMap;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a JobAPI for a specific configured job key.
|
|
40
|
+
* Each method is scoped to the job's configured ID.
|
|
41
|
+
*/
|
|
42
|
+
protected createJobAPI(jobKey: string): JobAPI;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve `:jobKey` from the request. Returns the key and ID,
|
|
45
|
+
* or sends a 404 and returns `{ jobKey: undefined, jobId: undefined }`.
|
|
46
|
+
*/
|
|
47
|
+
private _resolveJob;
|
|
48
|
+
private _sendStatusError;
|
|
49
|
+
/**
|
|
50
|
+
* Validate params from an HTTP request body. Eager validation lets streaming
|
|
51
|
+
* requests get a clean 400 instead of a generic SSE error event. Throws
|
|
52
|
+
* ValidationError so handlers can map to a 400 response via their catch block.
|
|
53
|
+
*/
|
|
54
|
+
private _parseRunParams;
|
|
55
|
+
private _handleRun;
|
|
56
|
+
injectRoutes(router: IAppRouter): void;
|
|
57
|
+
exports(): JobsExport;
|
|
58
|
+
clientConfig(): Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare const jobs: ToPlugin<typeof JobsPlugin, IJobsConfig, string>;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { jobs };
|
|
66
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/plugins/jobs/plugin.ts"],"mappings":";;;;;;;;;cAsFM,UAAA,SAAmB,MAAA;EAAA,OAChB,QAAA,EAAuB,cAAA;EAAA,UAEZ,MAAA,EAAQ,WAAA;EAAA,QAClB,SAAA;EAAA,QACA,MAAA;EAAA,QACA,UAAA;EAAA,QACA,OAAA;;;;;SAMD,YAAA,CAAa,MAAA,EAAQ,WAAA,GAAc,MAAA,SAAe,SAAA;EAAf;;;;EAAA,OAgCnC,uBAAA,CAAwB,MAAA,EAAQ,WAAA,GAAc,mBAAA;cAqBzC,MAAA,EAAQ,WAAA;EA0Bd,KAAA,CAAA,GAAK,OAAA;EAAA,YAMC,MAAA,CAAA;EAAA,QAIJ,QAAA;EAAA,QAcA,aAAA;EAAA,QAYA,cAAA;EAhIqB;;;;EAAA,QA6IrB,eAAA;EA1IkB;;;;EAAA,UAoKhB,YAAA,CAAa,MAAA,WAAiB,MAAA;EA1JjC;;;;EAAA,QAgXC,WAAA;EAAA,QA0BA,gBAAA;EA1W+B;;;;;EAAA,QAsX/B,eAAA;EAAA,QAuCM,UAAA;EA4Cd,YAAA,CAAa,MAAA,EAAQ,UAAA;EA6IrB,OAAA,CAAA,GAAW,UAAA;EAsBX,YAAA,CAAA,GAAgB,MAAA;AAAA;;;;cAiBL,IAAA,EAAI,QAAA,QAAA,UAAA,EAAA,WAAA"}
|