@nexterajs/app-kit
v0.1.0
Published
Metadata-driven application framework for Angular: module and page metadata, action constants, and the helpers built on them. Companion to @nexterajs/ui.
Maintainers
Readme
@nexterajs/app-kit
The metadata-driven application framework that sits beside @nexterajs/ui.
A module describes its pages as data (which list columns and filters, which form fields and layout, which actions a
user may take, which tabs a detail page has) and the application renders those pages from it. This package holds that
shape and the pure helpers built on it: module and page metadata interfaces, action and page-mode constants, a form
builder, a condition evaluator, and small replacements for the third-party utilities the applications used to import.
It is separate from @nexterajs/ui on purpose: this half is coupled to a specific backend contract (action codes,
list-of-values tables, pageNo/pageSize paging), and an application that only wants components should not have to
take it. It does not import @nexterajs/ui.
Install
npm install @nexterajs/app-kit @angular/forms @angular/cdk rxjsAngular 22 (@angular/core, @angular/common) is a peer dependency. createFormGroup uses @angular/forms, the
[nxeMenu] directive uses @angular/cdk/overlay, and NxeModalService returns an RxJS Observable, so install those
three alongside it.
What is in it
| Area | Exports |
|---|---|
| Module metadata | ModuleMetadata, ListPageMetadata, UpsertPageMetadata, ActionItem, Condition, ConditionEvaluator, ConditionType, ConditionOperator, ValueOperator, BooleanOperator |
| Field and layout metadata | NxeGridItem, NxeLayoutItem, LayoutType, DataType, LovDependency, ValueChangeEvent, Paging |
| Actions | ActionCode (LST, VIE, CRT, MOD, DEL, …), ACTION_MAPPER, getActionView() and the other getAction*() button descriptors, RequestAction, ActionConfig |
| Page mode | PageMode (View, Modify, New), ModeSignalHelper (isView, isModify, isAdd as computed signals) |
| Forms | extractGridItems (flatten a layout to its fields), createFormGroup (a FormGroup from field metadata and list-of-values) |
| List of values | Lov, MappedLov, mapLov, mapOriginalLov |
| Helpers | buildTree (flat list to tree, array-to-tree semantics), cloneDeep (lodash semantics), uuidV4, decodeJwt (decode only, never verify), trackChanges, sortSequence, HTTP query helpers (filterQueryParams, constructUrlWithQueryParams, downloadFile, previewPDF) |
| Pipes | actionCode (an action code to its label), null (empty values to -) |
| Directives | [nxeBadge], [nxeMenu] (opens a template in a CDK overlay) |
| Services | NxeModalService (opens a component over a click-to-dismiss backdrop) |
Minimal usage
import { Component, input } from '@angular/core';
import {
ActionCode,
ConditionEvaluator,
ConditionType,
ModeSignalHelper,
ModuleMetadata,
NullPipe,
ValueOperator,
createFormGroup,
extractGridItems,
} from '@nexterajs/app-kit';
export const PURCHASE_ORDER: ModuleMetadata = {
section: 'Purchasing',
icon: 'cart',
entityType: 'PO',
accessRight: 'PURCHASE_ORDER',
webBaseUrl: '/purchase-orders',
apiBaseUrl: '/api/purchase-orders',
uploadUrl: '/api/purchase-orders/upload',
id: 'poId',
lov: 'PO_STATUS',
listPage: {
create: true,
filters: [{ id: 'status', label: 'Status', dataType: 'LOV', lov: 'PO_STATUS' }],
gridItems: [
{ id: 'poNumber', label: 'PO number' },
{ id: 'total', label: 'Total', dataType: 'NUM' },
],
},
upsertPage: {
subheaders: [],
forms: [{ gridItem: { id: 'supplier', label: 'Supplier', required: true } }],
},
};
@Component({
selector: 'app-po-detail',
imports: [NullPipe],
template: `{{ form.value.supplier | null }}`,
})
export class PoDetailComponent {
readonly mode = input('View');
readonly modes = new ModeSignalHelper(this.mode); // modes.isView(), modes.isModify(), modes.isAdd()
readonly form = createFormGroup(
extractGridItems(PURCHASE_ORDER.upsertPage!.forms),
PURCHASE_ORDER,
{},
);
canDelete(row: Record<string, unknown>): boolean {
return ConditionEvaluator.evaluate(row, {
type: ConditionType.SINGLE,
key: 'status',
valueOperator: ValueOperator.INCLUDE,
value: ['DRAFT', 'REJECTED'],
});
}
readonly deleteCode = ActionCode.DELETE; // 'DEL'
}License
Apache-2.0. See LICENSE and NOTICE in this package.
