How to use type - 10 common examples

To help you get started, we’ve selected a few type 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 IHTSDO / sct-snapshot-rest-api / routes / expressionsv1.js View on Github external
if (condition.cardinality) {
            exitWithError("Unsupported condition: cardinality");
        }
        if (condition.reverseFlag) {
            exitWithError("Unsupported condition: reverseFlag");
        }
        if (condition.typeId != "*") {
            if (condition.attributeOperator) {
                if (condition.attributeOperator == "descendantOrSelfOf") {
                    elemMatch["$or"] = [];
                    elemMatch["$or"].push({"type.conceptId" : condition.conceptId});
                    elemMatch["$or"].push({"typeInferredAncestors" : condition.conceptId});
                } else if (condition.attributeOperator == "descendantOf") {
                    elemMatch["typeInferredAncestors"] = condition.conceptId;
                } else {
                    elemMatch["type.conceptId"] = condition.typeId;
                }
            } else {
                elemMatch["type.conceptId"] = condition.typeId;
            }
        }
        // Process attribute value
        //if (condition.targetNode.content != "*") {
        //    var temp = [];
        //    computer.resolve(condition.targetNode, ast, temp;
        //}
        //queryPart.push({relationships: {"$elemMatch": elemMatch}});
        //TODO: update for nested definitions in attributes
        if (condition.targetNode) {
            if (condition.targetNode.rule == "simpleExpressionConstraint") {
                var targetExp = readSimpleExpressionConstraint(condition.targetNode, ast);
                //console.log(JSON.stringify(targetExp));
github IHTSDO / sct-snapshot-rest-api / routes / expressions.js View on Github external
if (condition.reverseFlag) {
            exitWithError("Unsupported condition: reverseFlag");
        }
        if (condition.typeId != "*") {
            if (condition.attributeOperator) {
                if (condition.attributeOperator == "descendantOrSelfOf") {
                    elemMatch["$or"] = [];
                    elemMatch["$or"].push({"type.conceptId" : condition.conceptId});
                    elemMatch["$or"].push({"typeInferredAncestors" : condition.conceptId});
                } else if (condition.attributeOperator == "descendantOf") {
                    elemMatch["typeInferredAncestors"] = condition.conceptId;
                } else {
                    elemMatch["type.conceptId"] = condition.typeId;
                }
            } else {
                elemMatch["type.conceptId"] = condition.typeId;
            }
        }
        // Process attribute value
        //if (condition.targetNode.content != "*") {
        //    var temp = [];
        //    computer.resolve(condition.targetNode, ast, temp;
        //}
        //queryPart.push({relationships: {"$elemMatch": elemMatch}});
        //TODO: update for nested definitions in attributes
        if (condition.targetNode) {
            if (condition.targetNode.rule == "simpleExpressionConstraint") {
                var targetExp = readSimpleExpressionConstraint(condition.targetNode, ast);
                //console.log(JSON.stringify(targetExp));
                if (targetExp.memberOf) {
                    elemMatch["targetMemberships"] = targetExp.conceptId;
                } else if (targetExp.criteria == "descendantOrSelfOf") {
github raptorjs-legacy / raptorjs / lib / raptor / widgets / widgets_browser.js View on Github external
var _doInitWidget = function() {
                    try
                    {
                        if (widget.initWidget) {
                            widget.initWidget(config);
                        }
                        else {
                            OriginalWidgetClass.call(widget, config);
                        }
                    }
                    catch(e) {
                        var message = 'Unable to initialize widget of type "' + type + '". Exception: ' + e;
                        
                        // NOTE:
                        // For widgets rendered on the server we disable errors from bubbling to allow the page to possibly function
                        // in a partial state even if some of the widgets fail to initialize.
                        // For widgets rendered on the client we enable bubbling to make sure calling code is aware of the error.
                        if (bubbleErrorsDisabled) {
                            logger.error(message, e);
                        }
                        else {
                            throw e;
                        }
                    }
github basisjs / basisjs / src / devpanel / sync-basisjs-tools.js View on Github external
File.all.set(basisjsTools.getFiles());

  // subscribe to files change notifications
  basisjsTools.notifications.attach(function(action, filename, content){
    if (!notificationsQueue.length)
      basis.nextTick(processNotificationQueue);

    notificationsQueue.push({
      action: action,
      filename: filename,
      content: content
    });
  });

  File.open = basisjsTools.openFile;
  File.openFileSupported.set(typeof File.open == 'function'); // TODO: remove when basisjs-tools released with features
  File.getAppProfile = basisjsTools.getAppProfile;

  // sync features
  if (basisjsTools.features)
  {
    link(features, basisjsTools.features);
    features.link(File.openFileSupported, function(list){
      this.set(list.indexOf('file:open') !== -1);
    });
  }

  // invoke onInit callbacks
  initCallbacks.splice(0).forEach(init);
});
github basisjs / basisjs / src / devpanel / sync-basisjs-tools.js View on Github external
notificationsQueue.push({
      action: action,
      filename: filename,
      content: content
    });
  });

  File.open = basisjsTools.openFile;
  File.openFileSupported.set(typeof File.open == 'function'); // TODO: remove when basisjs-tools released with features
  File.getAppProfile = basisjsTools.getAppProfile;

  // sync features
  if (basisjsTools.features)
  {
    link(features, basisjsTools.features);
    features.link(File.openFileSupported, function(list){
      this.set(list.indexOf('file:open') !== -1);
    });
  }

  // invoke onInit callbacks
  initCallbacks.splice(0).forEach(init);
});
github basisjs / basisjs / src / devpanel / sync-basisjs-tools.js View on Github external
return;

    // trace only update and delete
    var ext = basis.path.extname(filename);

    if (inspectBasisResource.extensions[ext] &&
        inspectBasisResource.extensions[ext].permanent &&
        inspectBasisResource.isResolved(filename) &&
        inspectBasisResource(filename).hasChanges())
      basis.array.add(permanentFiles, filename);
    else
      basis.array.remove(permanentFiles, filename);
  });

  // set new count
  File.permanentChangedCount.set(permanentFiles.length);

  Dataset.setAccumulateState(false);
}
github dthree / vantage / lib / server.js View on Github external
if (this.server.connections.length === 0) {
      this.server.connection({ port: options.port, labels: "vantage" });
      this.io = require("socket.io")(this.server.listener);
    } else if (this.server.connections.length > 1) {
      // Select a specific connection if more than one exist.
      this.io = require("socket.io")(this.server.select(options.connectionLabel || "vantage").listener);
      delete options.connectionLabel;
    } else {
      this.io = require("socket.io")(this.server.listener);
    }
  } else {
    var type = (options.ssl) ? "https" : "http";
    if (type === "http") {
      this.server = require(type).createServer(appCallback);
    } else {
      this.server = require(type).createServer(options, appCallback);
    }
    this.io = require("socket.io")(this.server);
    this.server.listen(options.port);
  }

  this._port = options.port;
  this._logActivity = options.logActivity;

  this.io.set("authorization", function(handshakeData, accept){

    var address = handshakeData.connection._peername;
    var valid = self.firewall.valid(address);
    var query = handshakeData._query;
    var id = query.id || void 0;
    var ssnId = query.sessionId || void 0;
github dthree / vantage / lib / server.js View on Github external
// Create a connection if none exist.
    if (this.server.connections.length === 0) {
      this.server.connection({ port: options.port, labels: "vantage" });
      this.io = require("socket.io")(this.server.listener);
    } else if (this.server.connections.length > 1) {
      // Select a specific connection if more than one exist.
      this.io = require("socket.io")(this.server.select(options.connectionLabel || "vantage").listener);
      delete options.connectionLabel;
    } else {
      this.io = require("socket.io")(this.server.listener);
    }
  } else {
    var type = (options.ssl) ? "https" : "http";
    if (type === "http") {
      this.server = require(type).createServer(appCallback);
    } else {
      this.server = require(type).createServer(options, appCallback);
    }
    this.io = require("socket.io")(this.server);
    this.server.listen(options.port);
  }

  this._port = options.port;
  this._logActivity = options.logActivity;

  this.io.set("authorization", function(handshakeData, accept){

    var address = handshakeData.connection._peername;
    var valid = self.firewall.valid(address);
    var query = handshakeData._query;
    var id = query.id || void 0;
github raptorjs-legacy / raptorjs / lib / raptor / widgets / widgets_browser.js View on Github external
widget.registerMessages(['beforeDestroy', 'destroy'], false);
            
            // Check if the user's widget has an additional events defined
            var allowedEvents = proto.events || OriginalWidgetClass.events;

            if (allowedEvents) {
                widget.registerMessages(allowedEvents, false);
            }
            
            // Add required specified properties required by the Widget mixin methods
            if (id) {
                widget._id = id;
                widget.el = widget.getEl();
            }

            if (!OriginalWidgetClass.getName) {
                OriginalWidgetClass.getName = function() {
                    return type;
                };
            }
            
            proto.constructor = OriginalWidgetClass;

            if (Widget.legacy) {
                widget._parentWidget = parent;
            }
            
            if (events) {
                widget._events = _convertEvents(events);
            }
            
            widget.widgets = new Document(); //This widget might have other widgets scoped within it
github raptorjs-legacy / raptorjs / lib / raptor / widgets / widgets_browser.js View on Github external
// Check if the user's widget has an additional events defined
            var allowedEvents = proto.events || OriginalWidgetClass.events;

            if (allowedEvents) {
                widget.registerMessages(allowedEvents, false);
            }
            
            // Add required specified properties required by the Widget mixin methods
            if (id) {
                widget._id = id;
                widget.el = widget.getEl();
            }

            if (!OriginalWidgetClass.getName) {
                OriginalWidgetClass.getName = function() {
                    return type;
                };
            }
            
            proto.constructor = OriginalWidgetClass;

            if (Widget.legacy) {
                widget._parentWidget = parent;
            }
            
            if (events) {
                widget._events = _convertEvents(events);
            }
            
            widget.widgets = new Document(); //This widget might have other widgets scoped within it