Ga naar hoofdinhoud

Store Plugins

Plugins extend createObjectStore (and, as of the CRUD plugin support update, createCrudStore) with additional state, getters, and actions. Register them by passing their factories into the plugins array:

import {
createObjectStore,
auditTrailsPlugin,
relationsPlugin,
filesPlugin,
lifecyclePlugin,
registerMappingPlugin,
selectionPlugin,
searchPlugin,
} from '@conduction/nextcloud-vue'

const useObjectStore = createObjectStore('myapp', {
plugins: [
auditTrailsPlugin(),
relationsPlugin(),
filesPlugin(),
lifecyclePlugin(),
registerMappingPlugin(),
selectionPlugin(),
searchPlugin(),
],
})

Each plugin ships with its own dedicated reference page:

PluginPurpose
auditTrailsPluginObject-scoped + global audit trails, statistics, and delete
relationsPlugincontracts, uses, used sub-resources
filesPluginFile attachments (upload, publish, delete) + shared tags list
lifecyclePluginObject lifecycle actions: lock, publish, revert, merge
logsPluginPer-item logs collection for CRUD stores (e.g. /sources/logs?source_id=…)
registerMappingPluginFetch registers and schemas for admin selects
selectionPluginCross-type selection state (selectedObjects)
searchPluginDedicated search context: single collection slot, facets, cached schema/register

Building your own plugin

Most sub-resource plugins in this library are thin extensions of createSubResourcePlugin. When you need a paginated child collection hanging off an object URL (e.g. /{register}/{schema}/{id}/<endpoint>), reach for that factory first — it generates state, getters, and actions named after your sub-resource with no boilerplate.

Standalone helpers re-exported by searchPlugin

The search plugin also exports three identifiers at module level that can be used independently of the store:

ExportDescription
SEARCH_TYPEConstant 'search' — import to avoid hard-coding the string
getRegisterApiUrl(registerId)Returns /apps/openregister/api/registers/<id>
getSchemaApiUrl(schemaId)Returns /apps/openregister/api/schemas/<id>

See searchPlugin for details.