Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Express Importing using import JSON #355

Open
arumsey opened this issue May 16, 2024 · 3 comments
Open

Express Importing using import JSON #355

arumsey opened this issue May 16, 2024 · 3 comments

Comments

@arumsey
Copy link
Collaborator

arumsey commented May 16, 2024

Introduce a higher-level Importer API that provides a declarative approach to transformations

  • offer a clear API for developers to access that follows a consistent pattern
  • define a no-code configuration for most common transformation phases
  • allow for block-level transformation extensions
  • provide default metadata handling to avoid code duplication
  • open the door for easier transformation automation
  • separate block transformations into their own modules

Transformer Class

export default class Transformer {
  static transform(rules, source) {
    const {
      root,
      cleanup: {
        start: removeStart = [],
        end: removeEnd = [],
      },
      blocks = [],
    } = rules;

    // phase 1: get main element
    // phase 2: DOM removal - start
    // phase 3: block creation
    // phase 4: DOM removal - end

    return main;
  }

  /**
   * Build a name/value pair block configuration from a selector object.
   *
   * Selector Object:
   * {
   *   name: value_selector | [condition_selector, value_selector]
   * }
   *
   *
   * @param element Root element to query from
   * @param params Object of selector conditions
   */
  static buildBlockConfig(element, params) {}

  /**
   * Build a two-dimensional array of block cells from a selector object.
   * @param element
   * @param cells
   */
  static buildBlockCells(element, cells) {}

}

Importer Factory

const createImporter = (rules) => ({
  transform: (source) => {
    const element = WebImporter.Transformer.transform(rules, source);
    return [{
      element,
      path: generateDocumentPath(source),
    }];
  },
});
@kptdobe
Copy link
Contributor

kptdobe commented May 21, 2024

Who is using / requesting this ? What is the context ?

@arumsey
Copy link
Collaborator Author

arumsey commented May 21, 2024

Who is using / requesting this ? What is the context ?

The Import as a Service team/project is requesting this feature.

Adding a declarative API on top of the existing import.js feature will enable less technical users to participate in the import of a site. In addition, the proposed JSON configuration structure will also be used by the import service that is being devleoped so that custom code will not need to be executed on the server.

The feature being proposed is fully backwards compatible with the existing AEM Importer features. This means all existing import scripts will still work. The new abstraction layer being proposed will be built on top of the transformation file API. The responsibility of the transformation factory is to create a valid transformation object from the JSON configuration. Additionally, a developer creating an import script could even consume the declarative API if they want to simplify the work they need to do when writing a custom import script.

Finally, the introduction of a JSON configuration object will make it easier to be machine generated from a blueprint detection UI as well as AI prompts.

@kptdobe
Copy link
Contributor

kptdobe commented May 22, 2024

Ok, thanks for the details.
Once you have a first draft version, we would need several projects using the declarative approach instead of the current approach.
Also, it would be required to get adoption from the project leads or from non-technical users (as this is the target audience).

@arumsey arumsey changed the title Declarative Transformations Declarative Transformations (import JSON) Jun 13, 2024
@arumsey arumsey changed the title Declarative Transformations (import JSON) Express Importing using import JSON Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants