Skip to content

Express Importing using import JSON #355

@arumsey

Description

@arumsey

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),
    }];
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions