This document describes the platform.common library. This package provides shared functionality across the application. It includes state management (actions, reducers, selectors, facades), reusable UI components, utility functions, and common models used by other projects.
The platform.common package is a central repository for shared code and assets. It abstracts common concerns such as:
The package is built using Angular along with Nx tooling, ensuring scalable integration and consistent development practices.
A high-level breakdown of the package structure is as follows:
.eslintrc.json – Linter configuration.jest.config.ts – Jest testing configuration.ng-package.json – Package build configuration with ng-packagr.package.json – Package dependencies, scripts, and metadata.project.json – Nx project configuration (build, test, lint targets).tsconfig*.json – TypeScript configuration for different environments.README.md – Brief library description (expandable with detailed docs).extensions/array/
Extends native array functionality. The included README.md explains usage and integration.
actions/, effects/, facades/, reducers/, selectors/identifiers.ts generates namespaced action keys.model/media/file-extension.ts maps file extensions to HTTP media type information._providePersistenceFeature and _providePersistenceRoot set up meta-reducers to integrate with Ngrx.GlobalAPILocation and ModuleAPIState for API configuration.index.ts for simplified import.The module system is a core part of platform.common:
createNamespacedFeatureKey (for namespacing state slices) and persists state when enabled.forRoot and forFeature methods to register persistent state.persistenceMetaReducerFactory) to integrate persistent storage into Ngrx._setupPersistentState function registers persistent features with the ZWPPersistenceService.forRoot / forFeature) to integrate history tracking.State management is organized under the +state directory with the following responsibilities:
identifiers.ts).zwp.ngrx.module.ts manage router and theming effects.The model folder declares and exports types related to:
model/media/file-extension.ts).extensions/array folder provides enhancements to built-in array functionalities.The utils folder encompasses helper functions that aid in reducing boilerplate and handling common tasks:
Accept and Content-Type based on provided options.GlobalAPILocation and ModuleAPIState support API configuration.index.ts) for simplified access throughout our projects..eslintrc.json and .prettierrc to ensure code quality and consistency.jest.config.ts and tsconfig.spec.json.test-setup.ts file initializes any required test configurations and global mocks.project.json file defines targets for building, testing, and linting.nx build platform.commonnx test platform.commonnx lint platform.commonTo build and use the package:
nx build platform.common
nx test platform.common
src/index.ts, so you can consume modules like:
import { ExampleModule } from '@zwp/platform.common';
The platform.common package is a core library designed to centralize and standardize shared functionalities across our projects. Key features include:
This enriched documentation should serve as a detailed guide for developers to understand, extend, and maintain the functionalities provided by platform.common.