How to use the basis.entity.createType function in basis

To help you get started, we’ve selected a few basis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github basisjs / basisjs / tour / src / app / type / slide.js View on Github external
var entity = require('basis.entity');

//
// main part
//

var Slide = entity.createType('Slide', {
  id: entity.StringId,
  num: Number,
  title: String,
  files: entity.createSetType('File'),
  prev: 'Slide',
  next: 'Slide'
});


//
// sync data
//

var slideIndex = basis.resource('./slide/index.json');
slideIndex.ready(function(data){
  var prev = null;
github basisjs / basisjs / docs / src / app / core.js View on Github external
delta.inserted.forEach(function(item){
          resourceLoader.addResource(item.data.url, 'link');
        });
    }
  });

  var JsDocEntity = nsEntity.createType('JsDocEntity', {
    path: nsEntity.StringId,
    file: String,
    line: Number,
    text: String,
    context: String,
    tags: basis.fn.$self
  });

  var JsDocConfigOption = nsEntity.createType('JsDocConfigOption', {
    path: nsEntity.StringId,
    constructorPath: String,
    name: String,
    type: String,
    description: String
  });

  var awaitingUpdateQueue = {};

  function fetchInheritedJsDocs(path, entity){
    var objData = mapDO[path].data;
    if (/class|property|method/.test(objData.kind))
    {
      var postPath = objData.kind == 'class' ? '' : '.prototype.' + objData.title;
      var inheritance = getInheritance(objData.kind == 'class' ? objData.obj : mapDO[objData.path.replace(/.prototype$/, '')].data.obj, objData.kind == 'class' ? null : objData.title);
      for (var i = inheritance.length, inherit; inherit = inheritance[--i];)
github basisjs / basisjs / src / devpanel / type / file.js View on Github external
var STATE = require('basis.data').STATE;
var Value = require('basis.data').Value;
var entity = require('basis.entity');

var File = entity.createType('File', {
  filename: entity.StringId,
  content: function(value){
    return typeof value == 'string' ? value : null;
  }
});

File.permanentChangedCount = new Value({ value: 0 });
File.openFileSupported = new Value({ value: false });
File.open = function(){
  basis.dev.warn('[basis.devpanel] Open file in editor is not supported by server');
};
File.getAppProfile = function(){
  basis.dev.warn('[basis.devpanel] Can\'t fetch app profile since File.getAppProfile() is not inited yet');
};

File.extendClass(function(super_, current_){
github basisjs / basisjs-tools / lib / server / modules / devtool / client / src / type / client.js View on Github external
var entity = require('basis.entity');

function stringOrNull(value){
  return value == null ? null : String(value);
}

var Client = entity.createType('Client', {
  id: entity.StringId,
  sessionId: stringOrNull,
  online: Boolean,
  title: String,
  location: String,
  num: Number,
  uiType: stringOrNull,
  uiContent: stringOrNull,
  features: {
    defValue: [],
    type: Array
  }
});

module.exports = Client;
github basisjs / basisjs / src / devpanel / type / app-file-link.js View on Github external
var AppProfile = require('./app-profile.js');
var entity = require('basis.entity');

var FileLink = entity.createType('AppFileLink', {
  from: entity.StringId,
  to: entity.StringId
});

AppProfile.linkDataset('links', FileLink.all, function(links){
  return links.map(function(link){
    return {
      from: basis.path.resolve('/', link[0]),
      to: basis.path.resolve('/', link[1])
    };
  });
});

module.exports = FileLink;
github smelukov / webpack-runtime-analyzer / src / ui / src / type / source.js View on Github external
var entity = require('basis.entity');
var Profile = require('./profile');

var Source = entity.createType({
    name: 'Source',
    singleton: true,
    fields: {
        status: String,
        progress: Number,
        profile: Profile
    }
});

var source = Source({});

/** @cut */ basis.dev.log('source', source);

rempl.getSubscriber(function(api) {
    api.ns('progress').subscribe(function(data) {
        /** @cut */ basis.dev.log('channel(progress)', data);
github basisjs / basisjs / src / devpanel / type / app-profile.js View on Github external
var STATE = require('basis.data').STATE;
var Value = require('basis.data').Value;
var DatasetWrapper = require('basis.data').DatasetWrapper;
var entity = require('basis.entity');
var api = require('api').ns('app');

var AppProfile = entity.createType({
  name: 'AppProfile',
  singleton: true,
  fields: {
    files: Array,
    links: Array,
    warns: Array,
    l10n: basis.fn.$self
  }
}).extendClass({
  syncAction: function(){
    this.setState(STATE.PROCESSING);
    api.getAppProfile(function(err, profile){
      if (err)
        return this.setState(STATE.ERROR, err);

      this.update(profile);
github smelukov / webpack-runtime-analyzer / src / ui / src / type / profile.js View on Github external
var entity = require('basis.entity');
var Module = require('./module');
var Asset = require('./asset');
var Chunk = require('./chunk');
var Error = require('./error');
var Warning = require('./warning');
var ModuleLink = require('./module-link');
var FileLink = require('./file-link');
var transport = require('app.transport').api;

var Profile = entity.createType({
    name: 'Profile',
    singleton: true,
    fields: {
        status: String,
        progress: Number,
        version: String,
        hash: String,
        context: String
    }
});

var profile = Profile();

/** @cut */ basis.dev.log('profile', profile);

transport.ns('progress').subscribe(function(data) {
github smelukov / webpack-runtime-analyzer / src / ui / src / type / file.js View on Github external
var entity = require('basis.entity');
var utils = require('app.utils');

var File = entity.createType('File', {
    name: entity.StringId,
    short: String,
    size: Number,
    formattedSize: entity.calc('size', utils.formatSize),
    basename: entity.calc('name', basis.path.basename),
    extname: entity.calc('name', basis.path.extname)
});

module.exports = File;
github smelukov / webpack-runtime-analyzer / src / ui / src / type / chunk.js View on Github external
var entity = require('basis.entity');
var Module = require('./module');

var Chunk = entity.createType('Chunk', {
    id: entity.IntId,
    name: String,
    size: Number,
    hash: String,
    files: Array,
    reasons: entity.createSetType('Chunk'),
    dependencies: entity.createSetType(Module),
    rendered: Boolean,
    initial: Boolean,
    entry: Boolean
});

module.exports = Chunk;