npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ez-aem/policies

v1.0.3

Published

Easily Manage AEM Policies and Style System with EZ-AEM Policies.

Downloads

2

Readme

EZ-AEM Policies

Easily Manage AEM Policies and Style System with EZ-AEM Policies.

The AEM Policies and Style System provide a flexible and powerful way to manage access and styling of components. But, authoring the policies - either in the AEM GUI or manually writing XML can be tedious and limiting.

EZ-AEM Policies is a toolset to make authoring and managing your Policies and Styles easier. The included tools are:

  1. Component Policies
  2. Style Groups and Items
  3. Policy Generator

Component Policies

Component Policies are used to define the settings to be applied to a component within AEM. Component Policy definitions include "metadata" such as the component type, description, policy name, styles, and title. Component Policies may have an attributes object with has settings that are to be applied for the component. Additionally, Component Policies may have a configurations object that defines related settings such as default components, authoring, plugins, etc.

Usage

// Example usage of Component Policies
const { ComponentPolicy } = require("@ez-aem/policies");
const components = require("../components");
const styles = require("../../../theme/src/styles");

const cqAuthoring = {
  assetToComponentMapping: {
    mapping_image: {
      attributes: {
        assetGroup: "media",
        assetMimetype: "image/*",
        droptarget: "image",
        resourceType: "core/wcm/components/image/v3/image"
      }
    },
  },
}; 

module.exports = [
  new ComponentPolicy({
    component: "core/wcm/components/container/v1/container",
    description: "Default Policy for Container Component",
    policy: "policy_default",
    styles: styles.container.default,
    title: "Default Container Policy",

    attributes: {
      components: components.all,
      layout: "responsiveGrid",
      layoutDisabled: false,
    },
    configurations: {
      "cq:authoring": cqAuthoring,
    }
  })
}

Options

|Options|Required|Description| |-------|--------|-----------| |component|true|The resource Type of the component. For the Core Container component, the value would be "core/wcm/components/container/v1/container"| |description|false|A description of the purpose of the Component Policy, that will be displayed in the in the Policy editor GUI in AEM.| |policy|true|The name of the Component Policy. This will be used as a reference within page template definitions to assign a Policy to a component type.| |styles|false|A Style Groups object with the definitions for the Style System| |title|true|The title of the Component Policy, that will display in the AEM Policy editor GUI.| |attributes|false|An object with attributes that will be applied to the component in AEM. Consult the component source code for options. Whatever is included here will be output as part of the main policy node in xml so it's up to you to ensure it's functional| |configurations|false|Additional component configurations that are separate from Attributes and metadata. For example, the cq:authoring values or plugins. These configurations will be output as children of the main node in the xml. Again, it's up to you to ensure that it's functional.|


Style Groups and Items

EZ-AEM Policies provides tools to manage the AEM Style System: CQStyleGroups, CQStyleGroup, and CQStyle.

CQStyle

The CQStyle is the individual definition of a Style System option and is composed of a few attributes: label, id, classes. CQStyle objects are combined in an array to form the CQStyleGroup.

Usage

  new CQStyle({
    label: "Library Preset",
    id: "library-preset",
    classes: "library-preset accordion--preset:library-preset",
  }),

Options

|Attribute|Required|Default Value|Description| |---------|--------|-------------|-----------| |label|true|null|The label that will be visible to authors to choose the Style and apply it to a component.| |id|true|null|The id corresponds with the cq:styleId and is used to match applied styles to a component. This id is stored on a component when selected by an author for matching. It can be referenced in code to apply a Style to a component. This must be unique. AEM generates this id for you, but the EZ-AEM Policies toolset does not, as the ID must remain the same after it has been used by an author for later referencing. Cannot have spaces or special characters. | |classes|false|The id value will be used as the default|The value classes attribute will be output on the component wrapping element upon a match with the id value. By default, the value of the id will be used, and as such, the classes attribute isn't necessary. But if you would like a different value than the id or perhaps multiple classes to be output, you can include those in the string.|


CQStyleGroup

The CQStyleGroup includes an array of CQStyle's along with some other metadata. Multiple CQStyleGroup's can be combined to form a CQStyleGroups object that is used in a policy.

Usage

const { CQStyle, CQStyleGroup } = require("@ez-aem/policies");

module.exports = new CQStyleGroup({
  label: "Presets",
  styles: [
    new CQStyle({
      label: "Library Preset",
      id: "library-preset",
      classes: "library-preset accordion--preset:library-preset",
    }),
  ],
});

Options

|Attribute|Required|Default Value|Description| |---------|--------|-------------|-----------| |label|true|null|The label visible to authors in the Policy Editor GUI and also in the authoring editor Style System dropdown.| |allowMultiple|false|false|Determines if multiple CQStyle settings can be applied simultaneously.| |styles|true|CQStyle[]|An array of CQStyle objects.|

CQStyleGroups

Multiple CQStyleGroup's can be combined to form a CQStyleGroups array that is used in a policy. Accepts an CQStyleGroup[] as it's parameter.

Usage

const { CQStyleGroups } = require("@ez-aem/policies");

module.exports = new CQStyleGroups([
  require("./preset"),
  require("../_common/justify-self"),
  require("../_common/align-self"),
]);

Policy Generator

Generating the policies/.content.xml is the one of the biggest benefits of the EZ-AEM Policies toolset, and allows you to use a scripting language to simplify and supercharge your Policy management. Create a file which will be called by an npm run generate command. In that file require all of your Component Policies and Style Groups. Call the generatePolicies method, passing the policies array and the path where you want the policies/.content.xml to be generated. Optionally you can provide a tabWidth parameter to control the indentation of the generated xml.

Usage

// package.json
{
  "scripts": {
    "generatePolicies": "node ./generatePolicies.js"
  }
}
// ./generatePolicies.js
const { generatePolicies } = require("@ez-aem/policies");

const policies = [
  require("./components/accordion"),
  require("./components/breadcrumb"),
  require("./components/button"),
  require("./components/carousel"),
  ...require("./components/container"),
  require("./components/download"),
  require("./components/embed"),
  ...require("./components/experiencefragment"),
  require("./components/form-button"),
  require("./components/form-container"),
  require("./components/image"),
  require("./components/languagenavigation"),
  require("./components/list"),
  require("./components/navigation"),
  require("./components/page"),
  require("./components/progressbar"),
  require("./components/search"),
  require("./components/separator"),
  require("./components/tabs"),
  require("./components/teaser"),
  require("./components/text"),
  require("./components/title"),
];

generatePolicies(policies, "/src/main/content/jcr_root/conf/mysite/settings/wcm/policies");

Options

|Parameter|Required|Default Value|Description| |---------|--------|-------------|-----------| |policies|true|null|Type CQStyleGroups[]. An array of Policy objects.| |outputPath|true|null|The path to where you want the policies/.content.xml file output. This value will be combined with __dirname from the directory in which the npm script was ran.| |tabWidth|false|2|The number of spaces to indent the XML output.|