FluxbaseAdminJobs
Admin Jobs manager for managing background job functions Provides create, update, delete, sync, and monitoring operations
Constructors
Section titled “Constructors”new FluxbaseAdminJobs()
Section titled “new FluxbaseAdminJobs()”new FluxbaseAdminJobs(
fetch):FluxbaseAdminJobs
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | FluxbaseFetch |
Returns
Section titled “Returns”Methods
Section titled “Methods”cancel()
Section titled “cancel()”cancel(
jobId):Promise<object>
Cancel a running or pending job
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | Job ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple
| Name | Type |
|---|---|
data | null |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.cancel('550e8400-e29b-41d4-a716-446655440000')create()
Section titled “create()”create(
request):Promise<object>
Create a new job function
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
request | CreateJobFunctionRequest | Job function configuration and code |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with created job function metadata
| Name | Type |
|---|---|
data | null | JobFunction |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.create({ name: 'process-data', code: 'export async function handler(req) { return { success: true } }', enabled: true, timeout_seconds: 300})delete()
Section titled “delete()”delete(
namespace,name):Promise<object>
Delete a job function
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
namespace | string | Namespace |
name | string | Job function name |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple
| Name | Type |
|---|---|
data | null |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.delete('default', 'process-data')get(
namespace,name):Promise<object>
Get details of a specific job function
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
namespace | string | Namespace |
name | string | Job function name |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with job function metadata
| Name | Type |
|---|---|
data | null | JobFunction |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.get('default', 'process-data')if (data) { console.log('Job function version:', data.version)}getJob()
Section titled “getJob()”getJob(
jobId):Promise<object>
Get details of a specific job (execution)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | Job ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with job details
| Name | Type |
|---|---|
data | null | Job |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.getJob('550e8400-e29b-41d4-a716-446655440000')if (data) { console.log(`Job ${data.job_name}: ${data.status}`)}getStats()
Section titled “getStats()”getStats(
namespace?):Promise<object>
Get job statistics
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
namespace? | string | Optional namespace filter |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with job stats
| Name | Type |
|---|---|
data | null | JobStats |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.getStats('default')if (data) { console.log(`Pending: ${data.pending}, Running: ${data.running}`)}list()
Section titled “list()”list(
namespace?):Promise<object>
List all job functions (admin view)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
namespace? | string | Optional namespace filter |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with array of job functions
| Name | Type |
|---|---|
data | null | JobFunction[] |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.list('default')if (data) { console.log('Job functions:', data.map(f => f.name))}listJobs()
Section titled “listJobs()”listJobs(
filters?):Promise<object>
List all jobs (executions) across all namespaces (admin view)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filters? | object | Optional filters (status, namespace, limit, offset) |
filters.includeResult? | boolean | - |
filters.limit? | number | - |
filters.namespace? | string | - |
filters.offset? | number | - |
filters.status? | string | - |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with array of jobs
| Name | Type |
|---|---|
data | null | Job[] |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.listJobs({ status: 'running', namespace: 'default', limit: 50})if (data) { data.forEach(job => { console.log(`${job.job_name}: ${job.status}`) })}listNamespaces()
Section titled “listNamespaces()”listNamespaces():
Promise<object>
List all namespaces that have job functions
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with array of namespace strings
| Name | Type |
|---|---|
data | null | string[] |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.listNamespaces()if (data) { console.log('Available namespaces:', data)}listWorkers()
Section titled “listWorkers()”listWorkers():
Promise<object>
List active workers
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with array of workers
| Name | Type |
|---|---|
data | null | JobWorker[] |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.listWorkers()if (data) { data.forEach(worker => { console.log(`Worker ${worker.id}: ${worker.current_jobs} jobs`) })}retry()
Section titled “retry()”retry(
jobId):Promise<object>
Retry a failed job
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | Job ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with new job
| Name | Type |
|---|---|
data | null | Job |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.retry('550e8400-e29b-41d4-a716-446655440000')sync()
Section titled “sync()”sync(
options):Promise<object>
Sync multiple job functions to a namespace
Can sync from:
- Filesystem (if no jobs provided) - loads from configured jobs directory
- API payload (if jobs array provided) - syncs provided job specifications
Requires service_role or admin authentication.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | string | SyncJobsOptions | Sync options including namespace and optional jobs array |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with sync results
| Name | Type |
|---|---|
data | null | SyncJobsResult |
error | null | Error |
Example
Section titled “Example”// Sync from filesystemconst { data, error } = await client.admin.jobs.sync({ namespace: 'default' })
// Sync with pre-bundled code (client-side bundling)const bundled = await FluxbaseAdminJobs.bundleCode({ code: myJobCode })const { data, error } = await client.admin.jobs.sync({ namespace: 'default', functions: [{ name: 'my-job', code: bundled.code, is_pre_bundled: true, original_code: myJobCode, }], options: { delete_missing: true, // Remove jobs not in this sync dry_run: false, // Preview changes without applying }})
if (data) { console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)}syncWithBundling()
Section titled “syncWithBundling()”syncWithBundling(
options,bundleOptions?):Promise<object>
Sync job functions with automatic client-side bundling
This is a convenience method that bundles all job code using esbuild before sending to the server. Requires esbuild as a peer dependency.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | SyncJobsOptions | Sync options including namespace and jobs array |
bundleOptions? | Partial<BundleOptions> | Optional bundling configuration |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with sync results
| Name | Type |
|---|---|
data | null | SyncJobsResult |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.syncWithBundling({ namespace: 'default', functions: [ { name: 'process-data', code: processDataCode }, { name: 'send-email', code: sendEmailCode }, ], options: { delete_missing: true }})terminate()
Section titled “terminate()”terminate(
jobId):Promise<object>
Terminate a running job immediately
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | Job ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple
| Name | Type |
|---|---|
data | null |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.terminate('550e8400-e29b-41d4-a716-446655440000')update()
Section titled “update()”update(
namespace,name,updates):Promise<object>
Update an existing job function
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
namespace | string | Namespace |
name | string | Job function name |
updates | UpdateJobFunctionRequest | Fields to update |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with updated job function metadata
| Name | Type |
|---|---|
data | null | JobFunction |
error | null | Error |
Example
Section titled “Example”const { data, error } = await client.admin.jobs.update('default', 'process-data', { enabled: false, timeout_seconds: 600})bundleCode()
Section titled “bundleCode()”
staticbundleCode(options):Promise<BundleResult>
Bundle job code using esbuild (client-side)
Transforms and bundles TypeScript/JavaScript code into a single file that can be executed by the Fluxbase jobs runtime.
Requires esbuild as a peer dependency.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | BundleOptions | Bundle options including source code |
Returns
Section titled “Returns”Promise<BundleResult>
Promise resolving to bundled code
Throws
Section titled “Throws”Error if esbuild is not available
Example
Section titled “Example”const bundled = await FluxbaseAdminJobs.bundleCode({ code: ` import { helper } from './utils' export async function handler(req) { return helper(req.payload) } `, minify: true,})
// Use bundled code in syncawait client.admin.jobs.sync({ namespace: 'default', functions: [{ name: 'my-job', code: bundled.code, is_pre_bundled: true, }]})