
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@umbraco/json-models-builders
Advanced tools
Umbraco.JsonModels.Builder is a package made for use with Umbraco. This package is meant to contain all the Umbraco backoffice models, and their corresponding builders. If you see any model/builder missing, please create an issue / open a PR for it yourself, we would love your contribution!
Before we even get started, lets talk about what a builder is. We are using the Builder pattern here.
The builder is a class that creates a model, but you yourself can then use that builder to tweak the different properties.
If you take a look at the DocumentTypeBuilder
you will see all these properties:
compositeContentTypes;
isContainer;
allowAsRoot;
allowedTemplates;
allowedContentTypes;
alias;
description;
thumbnail;
name;
id;
icon;
trashed;
key;
parentId;
path;
allowCultureVariant;
isElement;
defaultTemplate;
lockedCompositeContentTypes: any[];
historyCleanupPreventCleanup;
historyCleanupKeepAllVersionsNewerThanDays;
historyCleanupKeepLatestVersionPerDayForDays;
documentTypeGroupBuilders;
documentTypeHistoryCleanupBuilder;
This looks very daunting, what types are these properties, what values do you fill out? You could imagine this being a big process, every time you needed to create a document type. Well the builder handles setting all of this for you! So all you would need to do, when using a builder to create a document type is:
const documentType = new DocumentTypeBuilder()
.build();
The builder will then fill out all the properties with default values!
This project was made with Node V16, so the minimum requirement is node 16.17.1
You can import a builder in the top of your file like so:
import { DocumentTypeBuilder} from "@umbraco/json-models-builders";
You can then use the imported builder to build a model:
const documentType = new DocumentTypeBuilder()
.build();
If you want to configure a property, like giving the document type a specific name, there are different methods for that, for changing the name, you can call the withName()
method like so:
const documentType = new DocumentTypeBuilder()
.withName("My document type")
.build();
There are a few things to consider when contributing
When adding new models/builders, it is important to register the exports in the correct index.ts
files!
Lets say you've added a new builder, remember to export it in the lib/builders/index.ts
file.
npm run build
& npm link
in the root of this directory.npm link @umbraco/json-models-builders
in your directory where you are using this package.FAQs
Builders and models for Umbraco Sites
The npm package @umbraco/json-models-builders receives a total of 102 weekly downloads. As such, @umbraco/json-models-builders popularity was classified as not popular.
We found that @umbraco/json-models-builders demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.