@requisite/sieve-plugin-api
v0.4.0
Published
TypeScript types for Sieve plugin development
Readme
@requisite/sieve-plugin-api
TypeScript types for Sieve plugin development.
Installation
npm install --save-dev @requisite/sieve-plugin-apiUsage
Import the types in your plugin component:
import type { SieveHostAPI, TimeRange, FieldInfo, SearchResult, StatsResult } from '@requisite/sieve-plugin-api'
const props = defineProps<{ hostApi?: SieveHostAPI }>()
const host = props.hostApiAlways consume the API via the
:host-apiprop. Do not use Vue'sinject()— it may not work correctly across the module federation boundary.
SieveHostAPI
The object injected into every search-panel plugin:
| Member | Type | Description |
|---|---|---|
| timeRange | Ref<TimeRange> | Reactive current time range from the host date picker |
| currentQuery | Ref<string> | Reactive text currently in the main search bar |
| applyQuery(query) | void | Copy query to search bar, run it, and close all panels |
| executeStats(filter, expr, range) | Promise<StatsResult> | Run a stats aggregation |
| executeSearch(filter, range, page?, pageSize?) | Promise<SearchResult> | Search for log entries |
| getFields(range?) | Promise<FieldInfo[]> | List all field names with hit counts |
| getFieldValues(field, range) | Promise<string[]> | Up to 50 distinct values for a field, by frequency |
Example — search panel component
import { onMounted, ref } from 'vue'
import type { SieveHostAPI, FieldInfo } from '@requisite/sieve-plugin-api'
const props = defineProps<{ hostApi?: SieveHostAPI }>()
const host = props.hostApi
const fields = ref<FieldInfo[]>([])
const query = ref('')
onMounted(async () => {
if (!host) return
fields.value = await host.getFields() // all known fields (cached)
query.value = host.currentQuery.value // pre-populate from search bar
})
function apply() {
host?.applyQuery(query.value) // run search and close panel
}Notes
getFields()without arangeis cached by the host for the session — safe to call on every mount.getFieldValues()always requires a range. For suggestion dropdowns, pass an all-time range so values aren't filtered to the current time window:const allTime = { start: '2000-01-01T00:00:00Z', end: new Date().toISOString() } const values = await host.getFieldValues('status_code', allTime)timeRangeandcurrentQueryare VueRefobjects. Access them as plain values (.value) inside a plugin — reactive tracking withwatchmay not propagate across the federation boundary.
License
MIT
