@imtf/dms-core
v8.0.0
Published
Typings for dms-core plugin system
Downloads
759
Readme
@imtf/dms-core
TypeScript typings for dms-core (the ICOS front end) - for typing your own code against its domain model, and for the IMTFPlugins plugin system it exposes at runtime.
Prerequisites
- TypeScript 5+.
IMTFPluginsis a global provided at runtime by dms-core itself, inside a plugin bundle it loads - this package only supplies its types. ReferencingIMTFPluginsoutside that runtime (e.g. an isolated unit test) will beundefinedunless you mock it.
Installation
npm install --save-dev @imtf/dms-coreThis is a types-only package - it ships no runtime code, only .d.ts declarations.
Using the domain types
Import any of the exported domain types directly to type your own functions, components, or utilities - this works regardless of whether the code is a registered plugin. The package exports the domain types used across dms-core's plugin surface (Case, Task, Inode, Entity, and others); rely on your editor's autocomplete on @imtf/dms-core for the full, current list rather than a list here that can drift out of date.
import type { Case, Task } from "@imtf/dms-core";
function getCaseLabel(currentCase: Case): string {
return currentCase.label;
}
function isOpenTask(task: Task): boolean {
return task.status === "open";
}Using the IMTFPlugins global
When dms-core starts, it registers a global IMTFPlugins object - the entry point for building custom plugins that extend Core without modifying it. This package types that global so you get autocomplete and type-checking while authoring plugins.
Registering a plugin (available plugin types are exposed at runtime via IMTFPlugins.TYPES - use autocomplete there too):
import MyPluginComponent from "./MyPlugin";
IMTFPlugins.register(
IMTFPlugins.TYPES.QUESTIONNAIRE_PART,
"myPlugin",
MyPluginComponent,
);Reading data via the hooks API (namespaced under IMTFPlugins.hooks, grouped by domain - app, case, task, mdm, inode):
export default function MyComponent({ item }: { item: Case }) {
const { data: currentCase } = IMTFPlugins.hooks.case.useCase(item);
// ...
}Calling an action:
const { getAction, TYPES } = IMTFPlugins.actions;
const action = getAction(TYPES.APP.OPEN_IN_NEW_WINDOW, [item]);
if (action) {
action();
}Versioning
This package follows semantic versioning, always aligned with the dms-core product release version (e.g. 7.4.X) — so the version you install tells you exactly which dms-core release its types were generated from.
- Stable releases (
x.y.z, no suffix) are published under thelatestnpm dist-tag.npm install @imtf/dms-corewithout pinning a version resolves to one of these. - Prereleases and variant lines (e.g.
x.y.z-beta.n,x.y.z-natwest.n) publish under their own identifier as the npm dist-tag (beta,natwest, ...) rather thanlatest, so they're never picked up unless explicitly requested - either by pinning the exact version (e.g."@imtf/dms-core": "1.1.0-beta.6") or installing via that tag (e.g.npm install @imtf/dms-core@beta).
