コード例 #1
0
 updateState = (newState, callback) => {
   let state = this.state;
   let stateModel = ObjectPath(state);
   for (let property in newState) {
     if (newState.hasOwnProperty(property)) {
       stateModel.set(property, newState[property]);
     }
   }
   if (callback) {
     this.setState(state, callback);
   } else {
     this.setState(state);
   }
 };
コード例 #2
0
ファイル: entu.js プロジェクト: argoroots/helpific
            async.each(op.get(body, loop, []), function(e, callback) {
                if(params.fullObject === true) {
                    getEntity({
                        definition: params.definition,
                        id: e.id,
                        auth_id: params.auth_id,
                        auth_token: params.auth_token
                    }, function(error, entity) {
                        if(error) return callback(error)

                        entities.push(entity)
                        callback()
                    })
                } else {
                    entities.push(op(e))
                    callback()
                }
            }, function(error) {
コード例 #3
0
ファイル: config.js プロジェクト: E-LLP/api-umbrella
  get: function(key) {
    // Read from the config file the api-umbrella process creates after reading
    // and merging config files.
    var testFileConfigPath = '/tmp/api-umbrella-test/var/run/runtime_config.yml';

    // If we're trying to read config data before the api-umbrella processes
    // have started, then as a fallback read from the single test file. This
    // assumes these config values read early on are only in this file. So it
    // isn't quite ideal or perfect, but seems to do the trick for now (but
    // should perhaps be revisited).
    if(!fs.existsSync(testFileConfigPath)) {
      testFileConfigPath = path.resolve(__dirname, '../config/test.yml');
    }

    var data = fs.readFileSync(testFileConfigPath);
    var config = objectPath(yaml.safeLoad(data.toString()));
    return config.get(key);
  },
コード例 #4
0
ファイル: entu.js プロジェクト: argoroots/helpific
        request.get({url: preparedUrl, headers: headers, qs: qs, strictSSL: true, json: true, timeout: defaultTimeout}, function(error, response, body) {
            if(error) return callback(error)
            if(response.statusCode !== 200 || !body.result) return callback(new Error(op.get(body, 'error', body)))

            var properties = op.get(body, 'result.properties', {})
            var entity = {
                _id: op.get(body, 'result.id', null),
                _changed: op.get(body, 'result.changed', null) || op.get(body, 'result.created', null),
                _picture: APP_ENTU_URL + '/entity-' + op.get(body, 'result.id', null) + '/picture'
            }
            for(var p in properties) {
                if(op.has(properties, [p, 'values'])) {
                    for(var v in op.get(properties, [p, 'values'])) {
                        if(op.get(properties, [p, 'datatype']) === 'file') {
                            op.push(entity, p, {
                                id: op.get(properties, [p, 'values', v, 'id']),
                                value: sanitize(op.get(properties, [p, 'values', v, 'value'])),
                                file: APP_ENTU_URL + '/file-' + op.get(properties, [p, 'values', v, 'db_value'])
                            })
                        } else if(op.get(properties, [p, 'datatype']) === 'text') {
                            op.push(entity, p, {
                                id: op.get(properties, [p, 'values', v, 'id']),
                                value: sanitize(op.get(properties, [p, 'values', v, 'value'])),
                                md: md(sanitize(op.get(properties, [p, 'values', v, 'db_value'])))
                            })
                        } else if(op.get(properties, [p, 'datatype']) === 'reference') {
                            op.push(entity, p, {
                                id: op.get(properties, [p, 'values', v, 'id']),
                                value: sanitize(op.get(properties, [p, 'values', v, 'value'])),
                                reference: op.get(properties, [p, 'values', v, 'db_value'])
                            })
                        } else {
                            op.push(entity, p, {
                                id: op.get(properties, [p, 'values', v, 'id']),
                                value: sanitize(op.get(properties, [p, 'values', v, 'value'])),
                            })
                        }
                    }
                    if(op.get(properties, [p, 'multiplicity']) === 1) op.set(entity, p, op.get(entity, [p, 0]))
                }
            }
            log.debug('entity = ' + JSON.stringify(entity))
            callback(null, op(entity))
        })
コード例 #5
0
ファイル: apolloUpload.js プロジェクト: boldr/boldr
    form.parse(req, (error, { operations }, files) => {
      if (error) {
        return reject(new Error(error));
      }
      debug('parsing form data');
      // Decode the GraphQL operation(s). This is an array
      // if batching is enabled.
      operations = JSON.parse(operations);
      // Check if files were uploaded
      if (Object.keys(files).length) {
        // File field names contain the original path to
        // the File object in the GraphQL operation input
        // variables. Relevent data for each uploaded file
        // now gets placed back in the variables.
        const operationsPath = objectPath(operations);
        Object.keys(files).forEach(variablesPath => {
          const { name, type, size, path } = files[variablesPath];
          return operationsPath.set(variablesPath, { name, type, size, path });
        });
      }

      // Provide fields for replacement request body
      return resolve(operations);
    });
コード例 #6
0
ファイル: config.js プロジェクト: ccird/api-umbrella
'use strict';

var fs = require('fs'),
    objectPath = require('object-path'),
    path = require('path'),
    yaml = require('js-yaml');

var testFileConfigPath = path.resolve(__dirname, '../config/test.yml');
var data = fs.readFileSync(testFileConfigPath);
var config = yaml.safeLoad(data.toString());
module.exports = objectPath(config);
コード例 #7
0
ファイル: index.js プロジェクト: getlackey/lackey-cms
 /**
  * Gets field from configuration. Accept dot notation as defined in https://www.npmjs.com/package/object-path
  * @param   {string} name
  * @returns {mixed|null}
  */
 get(name) {
     return objectPath(this._map).get(name);
 }
コード例 #8
0
ファイル: cache.js プロジェクト: kgs-ee/saal-js
var async     = require('async')
var op        = require('object-path')
var fs        = require('fs')


var entu      = require('entulib')


CACHE_LOADED_MESSAGE = 'Cache successfully loaded'
CACHE_RELOAD_REQUIRED_MESSAGE = 'Full cache reload required'

var state = 'idle'

SDC = op({
  'root': {},
  'local_entities': {},
  'relationships': {},
  'lastPollTs': new Date().getTime()/1e3
})

var cacheFromEntu = [
  {'parent':'3808', 'definition': 'category',    'class': 'rootCategory'},
  {'parent':'1930', 'definition': 'event',       'class': 'festival'},
  {'parent':'1930', 'definition': 'performance', 'class': 'festival'},
  {'parent':'597',  'definition': 'event',       'class': 'program'},
  {'parent':'4054', 'definition': 'event',       'class': 'program'},
  {'parent':'1931', 'definition': 'event',       'class': 'residency'},
  {'parent':'1929', 'definition': 'event',       'class': 'tour'},
  {'parent':'1953', 'definition': 'news',        'class': 'news'},
  // {'parent':'1933', 'definition': 'coverage',    'class': 'coverage'}, // nu performance 2016
  {'parent':'4054', 'definition': 'coverage',    'class': 'coverage'}, // SB 2017
  {'parent':'4051', 'definition': 'person',      'class': 'team'},