Vault API Helpers
When communicating with the M-Files vault through the gRPC API, you work with structured message objects such as ObjID, PropertyValue, TypedValue, and SearchConditionArray. Constructing these objects by hand as raw JSON is verbose and error-prone.
The @m-filescorporation/uix-vault-messages NPM package provides type-safe constructors, helper properties, and convenience methods that simplify working with these messages.
Installation
npm install @m-filescorporation/uix-vault-messages
Since UIX modules run as plain JavaScript in the M-Files shell, you need a bundler (such as Vite or webpack) to bundle the NPM package into a single file. See the Vault Messages Package sample for a complete project setup with Vite.
Why use this package?
Compare creating a text property value with raw JSON versus the package helpers:
Raw JSON (manual construction):
const nameProperty = {
property_def: 0,
value: {
type: 1, // Datatype.DATATYPE_TEXT
is_null_value: false,
data: {
text: 'My Document',
},
},
};
With the package:
import { MFGrpc } from '@m-filescorporation/uix-vault-messages';
const nameProperty = MFGrpc.PropertyValue.Text(0, 'My Document');
The package eliminates manual union field mapping, magic numbers, and deeply nested structures.
Importing the package
import { MFGrpc } from '@m-filescorporation/uix-vault-messages';
All message constructors and helpers are accessed through the MFGrpc namespace. No global variables are created.
Available Helpers
The following message types have helper constructors, properties, and methods:
MFGrpc.TypedValueMFGrpc.PropertyValueMFGrpc.PropertyValueArrayMFGrpc.SearchConditionMFGrpc.SearchConditionArrayMFGrpc.ExpressionMFGrpc.ObjIDMFGrpc.ObjVerMFGrpc.FileVerMFGrpc.LookupMFGrpc.MultiSelectLookupMFGrpc.ObjectVersionEx