Search for type specific properties ($class...) and return associated builder function

@param {Object} definition Entity definition literal object
@return {Function|undefined} Entity builder or undefined
@since 0.1.6
481316
function _gpfDefineRead$TypedProperties (definition) {
    var ResultEntityBuilder;
    _gpfObjectForEach(_gpfDefineTypedBuilders, function (TypedEntityBuilder, type) {
        if (definition["$" + type]) {
            ResultEntityBuilder = TypedEntityBuilder;
        }
    });
    return ResultEntityBuilder;
}
161532
function literalNode (value) {
  if (value === undefined) {
    return {
      type: 'Identifier',
      name: 'undefined'
    };
  }
  else if (typeof value == 'function') {
    throw Error('Unist property contains a function');
  }
  else if (value === null || typeof value != 'object') {
    return {
      type: 'Literal',
      value: value
    };
  }
  else if (Array.isArray(value)) {
    return {
      type: 'ArrayExpression',
      elements: value.map(literalNode)
    };
  }
  else {
    return {
      type: 'ObjectExpression',
      properties: Object.keys(value).map(function (key) {
        return {
          type: 'Property',
          key: {
            type: 'Identifier',
            name: key
          },
          value: literalNode(value[key])
        };
      })
    };
  }
}
339852
function createAbstractClass(params, constructor) {
        var def,
            savedMembers,
            key,
            value;

        // Handle abstract methods
        if (hasOwn(params, '$abstracts')) {
            savedMembers = params.$abstracts;
            delete params.$abstracts;
        }

        // Create the class definition
        def = Class.$create(params, constructor);
        def[$abstract] = true;

        // Grab binds
        if (savedMembers) {
            for (key in savedMembers) {
                value = savedMembers[key];

                if (value[$bound]) {
                    insert(def[$class].binds, key);
                }
            }
        }

        return def;
    }
4277
function defineProperty(obj, prop, getter) {
  Object.defineProperty(obj, prop, {
    configurable: true,
    enumerable: true,
    get: getter
  });
}
521813
function getColumnName(columnDefinitions, property) {
    Validate.isObject(columnDefinitions);
    Validate.notNull(columnDefinitions);
    Validate.isString(property);
    Validate.notNullOrEmpty(property);

    for (var column in columnDefinitions) {
        if (column.toLowerCase() === property.toLowerCase()) {
            return column;
        }
    }

    return property; // If no definition found for property, simply returns the column name as is
}
647212
function (def, classpath, member) {
        var res;
        if (typeUtils.isFunction(def)) {
            // should already be normalized:
            return __simpleFunctionDefinition;
        } else if (typeUtils.isString(def)) {
            res = {
                $type : def
            };
        } else if (typeUtils.isArray(def)) {
            return __simpleArrayDefinition;
        } else if (typeUtils.isObject(def)) {
            res = def;
        } else {
            return null;
        }
        var memberType = res.$type;
        if (!__acceptedMemberTypes[memberType]) {
            // the error is logged later
            return null;
        }
        if (!(require("./JsonValidator")).normalize({
            json : res,
            beanName : "aria.core.CfgBeans.ItfMember" + memberType + "Cfg"
        })) {
            return null;
        }
        return res;
    }
1130592
function(object, key, def) {
		if (this._isaccessor(def)) {
			return Object.defineProperty(object, key, {
				enumerable: true,
				configurable: true,
				get: def.getter || this._NOGETTER,
				set: def.setter || this._NOSETTER
			});
		} else {
			throw new TypeError("Expected getter and/or setter method");
		}
	}
769883
function compileEntity() {
          var entity = extend({
            buildId: bff.key(payload),
            extension: file.extension,
            filename: file.filename,
            fingerprint: print,
            url: file.url
          }, payload);

          return entity;
        }
941564
function _gpfAttributesGetFromClass (classConstructor, baseAttributeClass) {
    var entityDefinition = _gpfDefineEntitiesFindByConstructor(classConstructor);
    if (entityDefinition) {
        return entityDefinition.getAttributes(baseAttributeClass);
    }
    return {};
}
17223
function boundClass(target) {
    // (Using reflect to get all keys including symbols)
    let keys
    // Use Reflect if exists
    if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
        keys = Reflect.ownKeys(target.prototype)
    } else {
        keys = Object.getOwnPropertyNames(target.prototype)
        // use symbols if support is provided
        if (typeof Object.getOwnPropertySymbols === 'function') {
            keys = keys.concat(Object.getOwnPropertySymbols(target.prototype))
        }
    }

    keys.forEach(key => {
        // Ignore special case target method
        if (key === 'constructor') {
            return
        }

        let descriptor = Object.getOwnPropertyDescriptor(target.prototype, key)

        // Only methods need binding
        if (typeof descriptor.value === 'function') {
            Object.defineProperty(target.prototype, key, boundMethod(target, key, descriptor))
        }
    })
    return target
}
1268406
public function entity(Table $definition, array $data, bool $empty = false)
    {
        $primary = [];
        if (!$empty) {
            foreach ($definition->getPrimaryKey() as $column) {
                $primary[$column] = $data[$column];
            }
            if (isset($this->objects[$definition->getName()][base64_encode(serialize($primary))])) {
                return $this->objects[$definition->getName()][base64_encode(serialize($primary))];
            }
        }
        $entity = new class ($this, $definition, $data) extends \StdClass {
            protected $mapper;
            protected $empty;
            protected $definition;
            protected $initial = [];
            protected $changed = [];
            protected $fetched = [];

            public function __construct($mapper, $definition, array $data = [])
            {
                $this->mapper = $mapper;
                $this->definition = $definition;
                $this->initial = $data;
            }
            public function __lazyProperty(string $property, $resolve)
            {
                $this->fetched[$property] = $resolve;
                return $this;
            }
            public function &__get($property)
            {
                if (isset($this->fetched[$property])) {
                    if (is_callable($this->fetched[$property])) {
                        $this->fetched[$property] = call_user_func($this->fetched[$property]);
                    }
                    return $this->fetched[$property];
                }
                if (isset($this->changed[$property])) {
                    return $this->changed[$property];
                }
                if (isset($this->initial[$property])) {
                    return $this->initial[$property];
                }
                $null = null;
                return $null;
            }
            public function __set($property, $value)
            {
                $this->changed[$property] = $value;
            }
            public function __call($method, $args)
            {
                if (isset($this->definition->getRelations()[$method])) {
                    if (isset($this->fetched[$method])) {
                        return is_callable($this->fetched[$method]) ?
                            $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) :
                            $this->fetched[$method];
                    }
                }
                return null;
            }
            public function definition()
            {
                return $this->definition;
            }
            public function toArray(bool $fetch = false)
            {
                $data = [];
                foreach ($this->definition->getColumns() as $k) {
                    if (isset($this->fetched[$k])) {
                        if ($fetch) {
                            $this->fetched[$k] = call_user_func($this->fetched[$k]);
                        }
                        if (!is_callable($this->fetched[$k])) {
                            $data[$k] = $this->fetched[$k];
                        }
                    }
                    if (isset($this->initial[$k])) {
                        $data[$k] = $this->initial[$k];
                    }
                    if (isset($this->changed[$k])) {
                        $data[$k] = $this->changed[$k];
                    }
                }
                return $data;
            }
            public function fromArray(array $data)
            {
                foreach ($this->definition->getColumns() as $k) {
                    if (isset($data[$k])) {
                        $this->changed[$k] = $data[$k];
                    }
                }
                return $this;
            }
            public function id()
            {
                $primary = [];
                foreach ($this->definition->getPrimaryKey() as $k) {
                    $primary[$k] = $this->initial[$k] ?? null;
                }
                return $primary;
            }
            public function save()
            {
                $this->mapper->save($this);
                return $this->flatten();
            }
            public function delete()
            {
                $this->mapper->delete($this);
            }
            public function refresh()
            {
                $this->mapper->refresh($this);
                return $this->flatten();
            }
            public function flatten()
            {
                $this->initial = $this->toArray();
                $this->changed = [];
                return $this;
            }
        };
        if ($empty) {
            return $entity;
        }
        $this->lazy($entity, $data);
        return $this->objects[$definition->getName()][base64_encode(serialize($primary))] = $entity;
    }
532202
function define(File, utils) {
  return class HTMLFile extends File {
    /**
     * Constructor
     * @param {String} id
     * @param {String} filepath
     * @param {Object} options
     *  - {Function} buildFactory
     *  - {Object} fileCache
     *  - {Object} fileExtensions
     *  - {Function} fileFactory
     *  - {Array} npmModulepaths
     *  - {Object} pluginOptions
     *  - {Object} runtimeOptions
     *  - {String} webroot
     */
    constructor(id, filepath, options) {
      super(id, filepath, 'html', options);

      this.hasMaps = false;
      this.map = null;
      this.workflows.standard = WORKFLOW_STANDARD;
      this.workflows.writeable = WORKFLOW_WRITEABLE;
    }

    /**
     * Parse file contents for dependency references
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    parse(buildOptions, fn) {
      const context = inlineContext.create({ compress: false });

      context.html = this.content;
      context.htmlpath = this.filepath;
      inlineParse(context, err => {
        if (err) return fn(err);

        const dependencies = context.sources.map(source => {
          const { attributes } = source;

          source.id = attributes.src || attributes.href || attributes.data;
          return source;
        });

        super.addDependencies(dependencies, buildOptions);
        fn();
      });
    }

    /**
     * Parse sidecar data file
     * @returns {Object}
     */
    parseSidecarDependency() {
      const filepath = path.resolve(path.dirname(this.filepath), this.name.replace(`.${this.extension}`, '.json'));

      if (exists(filepath)) return { context: '', filepath, match: '' };
    }

    /**
     * Retrieve sidecar data dependency
     * @returns {Object}
     */
    findSidecarDependency() {
      let data = {};

      // Find sidecar data
      for (const dependency of this.dependencies) {
        if (dependency.type == 'json') {
          try {
            data = JSON.parse(dependency.content);
          } catch (err) {
            warn(`malformed json file: ${strong(dependency.filepath)}`, this.options.level);
          }
        }
      }

      return data;
    }

    /**
     * Replace {BUDDY_*} references with values
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    replaceEnvironment(buildOptions, fn) {
      this.setContent(replaceEnvironment(this.content));
      debug(`replace environment vars: ${strong(this.relpath)}`, 4);
      fn();
    }

    /**
     * Inline css/img/js dependency content
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     * @returns {null}
     */
    inline(buildOptions, fn) {
      const inlineableDependencyReferences = [...this.dependencyReferences].filter(
        reference => reference.file.isInline
      );

      if (!inlineableDependencyReferences.length) return fn();

      // Prepare for inline-source
      inlineableDependencyReferences.forEach(reference => {
        // Copy to override inline-source behaviour
        reference.fileContent = reference.file.content;
        reference.compress = buildOptions.compress;
      });

      // Update transformed html content
      const context = inlineableDependencyReferences[0].parentContext;

      context.html = this.content;

      try {
        const content = inlineRun(context, inlineableDependencyReferences, false);

        this.setContent(content);
      } catch (err) {
        return fn(err);
      }

      debug(`inline: ${strong(this.relpath)}`, 4);
      fn();
    }
  };
}
490417
function doc_builder(doc) {
				if(is.array(doc)) {
					return ARRAY(doc).map(_doc_builder).valueOf();
				}
				return _doc_builder(doc);
			}
932987
function(Type) {
		if (Type) {
			if (this._map) {
				var classid = Type.$classid;
				var typeobj = this._map[classid];
				return typeobj ? true : false;
			}
			return false;
		} else {
			throw new Error("Something is undefined");
		}
	}
1311059
function creareSetGet( classProto ) {
			// Storing key:value in separate variable as using original object will
			// create infinit loop.
			var valueStorage = {};
			// Static is not supported.... will not support ie < 9;
			// Adding setter and getter
			classProto.prototype.$add = function( obj, key, val, isConst ) {

				// val has a value for it's original object.
				if (val != undefined) {
					valueStorage[key] = val;
				}

				function setter( newval ) {
					if (isConst) {
						throw this + "." + key + " can not be changed.";
					}
					valueStorage[key] = newval;
				}

				function getter( ) {
					return valueStorage[key];
				}
				/// ie dont include key created by setter getter if not intialized before
				obj[key] = null;
				if (Object.defineProperty && isGetterSetterSupported) {
					Object.defineProperty(obj, key, {
					    get : getter,
					    set : setter
					});
				}
				else if (obj.__defineGetter__) {
					obj.__defineGetter__(key, getter);
					obj.__defineSetter__(key, setter);
				}
				else {
					obj[key] == undefined && (obj[key] = valueStorage[key]);
				}
			};
		}
1125262
public function findById($class, $id) {
        $mapper = MapperBuilder::buildFromMapping($this->mapping, $class);

        $newEntity = NULL;

        $query = "SELECT * FROM `" . $mapper->getTable() . "` WHERE id='$id'";
        $result = $this->conn->executeQuery($query);

        if ($result) {
            $class = $mapper->getClass();
            $newEntity = new $class();
            $this->populateEntity($newEntity, $result[0], $mapper);

            // populate relations
            foreach ($mapper->getRelations() as $relation) {

                $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());
                $queryRel = $this->buildSelectRelation($newEntity, $mapper, $relation, $relMapper);
                $resRel = $this->conn->executeQuery($queryRel);

                $classRel = $relMapper->getClass();
                $method = "set" . $relation->getName();
                if ($resRel) {
                    foreach ($resRel as $row) {
                        $newEntityRel = new $classRel();
                        $this->populateEntity($newEntityRel, $row, $relMapper, $relation->getForeignColumn());
                        $array[] = $newEntityRel;
                    }
                    $newEntity->$method($array);
                }
            }
        }
        return $newEntity;
    }
1087982
function(wrapper, name, options){
    function createLocalId(id){
      if (typeof id == 'string')
        return function(data, item){
          return data[id] == item.data[id];
        };

      if (typeof id == 'function')
        return id;
    }

    if (this instanceof )
    {
      if (!wrapper)
        wrapper = $self;

      if (!name || getTypeByNameIfDefined(name))
      {
        /** @cut */ if (getTypeByNameIfDefined(name)) basis.dev.warn(namespace + ': Duplicate entity set type name `' + this.name + '`, name ignored');
        name = getUntitledName('UntitledEntitySetType');
      }

      var entitySetType = new EntitySetConstructor({
        entitySetClass: {
          /** @cut */ className: namespace + '.EntitySet(' + (typeof wrapper == 'string' ? wrapper : (wrapper.type || wrapper).name || 'UnknownType') + ')',
          /** @cut */ name: 'Set of {' + (typeof wrapper == 'string' ? wrapper : (wrapper.type || wrapper).name || 'UnknownType') + '}',
          wrapper: wrapper,
          localId: createLocalId(options && options.localId)
        }
      });

      var EntitySetClass = entitySetType.entitySetClass;
      var result = function(data, entitySet){
        if (data != null)
        {
          if (entitySet instanceof EntitySet == false)
            entitySet = entitySetType.createEntitySet();

          entitySet.set(data instanceof Dataset ? data.getItems() : arrayFrom(data));

          return entitySet;
        }
        else
          return null;
      };

      // if wrapper is string resolve it by named type map
      if (typeof wrapper == 'string')
        EntitySetClass.prototype.wrapper = getTypeByName(wrapper, EntitySetClass.prototype, 'wrapper');

      // resolve type name
      defineType(name, result);

      // extend result with additional properties
      extend(result, {
        type: entitySetType,
        typeName: name,

        toString: function(){
          return name + '()';
        },

        reader: function(data){
          if (Array.isArray(data))
          {
            var wrapper = EntitySetClass.prototype.wrapper;
            return data.map(wrapper.reader || wrapper);
          }

          return data;
        },

        extendClass: function(source){
          EntitySetClass.extend.call(EntitySetClass, source);
          return result;
        },
        extendReader: function(extReader){
          var reader = result.reader;

          result.reader = function(data){
            if (Array.isArray(data))
              extReader(data);
            return reader(data);
          };

          return result;
        },

        // deprecated in 1.3.0
        entitySetType: entitySetType,
        extend: function(){
          /** @cut */ basis.dev.warn('basis.entity: EntitySetType.extend() is deprecated, use EntitySetType.extendClass() instead.');
          return EntitySetClass.extend.apply(EntitySetClass, arguments);
        }
      });

      // deprecated in 1.3.0
      /** @cut */ basis.dev.warnPropertyAccess(result, 'entitySetType', entitySetType,
      /** @cut */   'basis.entity: EntitySetType.entitySetType is deprecated, use EntitySetType.type instead.'
      /** @cut */ );

      return result;
    }
  }