Ejemplo n.º 1
0
  return function resolveData(
    settings = {},
    config = {}
  ) {
    /**
     * Clone the config to avoid mutation
     */
    const configCopy = clone(config);

    /**
     * Create an array of resolver specifications
     */
    const resolvers = generateResolvers('app', configCopy.app, ({
      path,
      module: {
        type = '',
        options = {},
      },
    }) => {
      return {
        path: `${path}.options._data`,
        getData: (() => {
          return getModule(type)
            .then(({ getData = () => Promise.resolve() }) => {
              return getData(Object.assign({}, { __settings: settings }, options._dataOptions));
            });
        }),
      };
    });

    /**
     * Return a Promise of the config
     * resolved with data by applying
     * the resolvers created above
     */
    return new Promise((resolve, reject) => {
      asyncEach(resolvers, ({
        path,
        getData = () => Promise.resolve(),
      }, cb) => {
        getData()
          .then((_data) => {
            set(configCopy, path, _data);
            cb();
          })
          .catch(cb);
      }, (err) => {
        return err ? reject(err) : resolve(configCopy);
      });
    });
  };
Ejemplo n.º 2
0
module.exports = function (input) {
  // don't mess with original object
  var har = clone(input)

  // sanity
  validate(har, function (err, valid) {
    if (!valid) {
      throw err
    }
  })

  har.log.entries.forEach(function (entry) {
    entry.request = request(entry.request)
    entry.response = response(entry.response)
  })

  return har
}
Ejemplo n.º 3
0
 beforeEach(function (done) {
   fixtures.blank = clone(fixtures.min)
   done()
 })
Ejemplo n.º 4
0
import clone from 'stringify-clone'
import _content from '../../schemas/2.0.0/content.json'
import _creator from '../../schemas/2.0.0/creator.json'
import _entry from '../../schemas/2.0.0/entry.json'
import _log from '../../schemas/2.0.0/log.json'
import _pairs from '../../schemas/2.0.0/pairs.json'
import _request from '../../schemas/2.0.0/request.json'
import _response from '../../schemas/2.0.0/response.json'
import _service from '../../schemas/2.0.0/service.json'
import _timings from '../../schemas/2.0.0/timings.json'

let content = clone(_content)
let creator = clone(_creator)
let entry = clone(_entry)
let log = clone(_log)
let pairs = clone(_pairs)
let request = clone(_request)
let response = clone(_response)
let service = clone(_service)
let timings = clone(_timings)

/*
 * copy external scheams internally
 * is-my-json-valid does not provide meaningful error messages for external schemas
 */

request.properties.headers.items = pairs
request.properties.queryString.items = pairs
request.properties.content = content

response.properties.headers.items = pairs
Ejemplo n.º 5
0
import clone from 'stringify-clone'
import { har as _har, content as _content } from 'har-validator/lib/schemas'

let har = clone(_har)
let content = clone(_content)

// ALF modification to HAR

// ignore `cache`
har.properties.log.properties.entries.items.required = [
  'startedDateTime',
  'time',
  'request',
  'response',
  'timings'
]

// ignore `cookies
har.properties.log.properties.entries.items.properties.request.required = [
  'method',
  'url',
  'httpVersion',
  'headers',
  'queryString',
  'headersSize',
  'bodySize'
]

// ignore `cookies`, `redirectURL`
har.properties.log.properties.entries.items.properties.response.required = [
  'status',