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

aem-import-builder

v0.3.0

Published

Powerful AI capabilities to simplify AEM import script development.

Downloads

146

Readme

AEM Import Builder

Powerful AI capabilities to simplify AEM import script development.

Usage

Accessing the AEM Import Builder is achieved by using the ImportBuilderFactory to create an ImportBuilder instance.

Visit the aem-import-helper for a full example of how to use the AEM Import Builder.

Import Builder Factory

The ImportBuilderFactory is responsible for managing authentication and emitting events during builder operations.

Options

  • baseUrl: URL containing a /tools/importer path.
  • apiKey: Import API key.
  • environment: Assistant service environment (stage or prod).

The create method of the factory returns an ImportBuilder instance that can be used to build an AEM import script. An ImportBuilder must be given a sample HTML document and screenshot to operate against. A set of existing import rules can also be provided when building on top of an existing project.

import {ImportBuilderFactory} from 'aem-import-builder';
import {FactoryOptions} from './importBuilderFactory';

const options: FactoryOptions = {
  baseUrl: 'https://localhost:3001',
  apiKey: 'import-api-key',
  environment: 'prod',
};

const factory = ImportBuilderFactory(options);
factory.on('start', (msg) => {
  // start message
});
factory.on('progress', (msg) => {
  // progress message
});
factory.on('complete', () => {
  // complete message
});

// rules is in import rules JSON object
// page is array containing an HTML document string and a Base64 encoded screenshot string
const builder = factory.create({mode: 'script', rules, page});

Templates

The ImportBuilderFactory uses templates to generate import scripts and AI prompts. The templates folder must be copied to a /tools/importer path that is accessible by the baseUrl provided to the factory.

Import Builder

An ImportBuilder consists of several asynchronous builder functions that all return a manifest of builder file items. The BuilderManifest is a list of files that can be used to create an AEM import script.

export type BuilderFileItem = {
  name: string;
  type?: 'parser' | 'transformer';
  contents: string;
}

Build Project

Build a new import project that includes an initial import script and a set of import rules.

const manifest = await builder.buildProject();

Cleanup

Add cleanup rules to the import rules that will remove unnecessary elements from the document being imported.

const manifest = await builder.addCleanup('breadcrumbs');

Blocks

Add block rules to the import rules that will identify and extract blocks of content from the document being imported.

const manifest = await builder.addBlock('block-name', 'block description');

Block Cells

Add a block cell parser script to the import project that will add content to a block.

const manifest = await builder.addCellParser('block-name', 'description of cell content');

Page Transformation

Add a page transformation script to the import project that will transform the document content.

const manifest = await builder.addPageTransformer('transformer-name', 'description of page transformation');

Developer Guide

Ensure you understand the architecture.

Install

Install all the dependencies.

npm i

Build

This is a Typescript project so a build step is required to generate the final Javascript.

npm run build

Lint

Run eslint to ensure code quality and consistency.

npm run lint

Test

Run all the units tests using Mocha.

npm run test

Environment

Since this project makes Open AI requests you must be authenticated.

The following environment variables must be defined before making requests to Azure Open AI.

IMS_CLIENT_SECRET
IMS_AUTH_CODE

Templates

Handlebars templates are used extensively by the import builder to generate scripts and AI prompts. Script templates are stored as publicly accessible GitHib gists.

  • https://gist.github.com/arumsey/a66e25a5292afcc0f34be48a84c8c548