These are chat archives for meteor-shuttler/graphs

4th
Mar 2016
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 00:02
Hi
In the classic sense of the inheritance is the "class" as a set of properties.
Here every tree option-independent property. Inheritance enables you to impose a property-graph to documents on another graph.
Now is active the demo: http://5.200.53.164:3008/
Collections on server:
documents = new Mongo.Collection('documents');

used = new Mongo.Collection('used');
used.attachGraph();

right = new Mongo.Collection('right');
right.attachGraph();
right.attachSelect();

if (Meteor.isServer) {
    right.select({
        graph: 'used',
        field: 'source',
        from: 'target',
        to: 'source'
    });
    right.select({
        graph: 'used',
        field: 'source',
        from: 'target',
        to: 'link'
    });
}
AttachSelect andselect - methods are not yet published package. It does works as used.inheritTree(right) in https://github.com/ivansglazunov/meteor-trees.
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 00:15
I recommend to execute the following commands in the console of browser for understanding:
// Remove all right links
right.find().forEach(function(r) { right.remove(r._id); });
// If target of right link is reference to subject, and source is reference to object of this rule
// then give to "user" document №3 this "right" to structure from document 2.
right.link.insert(documents.findOne('2'), documents.findOne('1'));
// RETURNEDID
// You can also update any links.
// For example to transfer this right from the user 1 to user 3.
right.update(RETURNEDID, { $set: { '_target.id': '3'} });
This makes it possible without searching in tree easily to know which properties have the document.
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 00:30

For example like this:
https://github.com/ivansglazunov/meteor-shuttle-rights#shuttlerighttree-mongocollection-object-document-user-user--cursor

// In future versions it will be something like this:
Shuttler.can((graph: Mongo.Collection)|(restrict: String), object?: Document, user? (id: String)|Document) => Boolean

This same method can be used to check for the "literal" right to a certain action.
With package https://github.com/ivansglazunov/meteor-restrict

Collection.attachRestriction('someMyAction');
Collection.deny({
    someMyAction: function(userId, document) {
         if (userId && Shuttler.can(Shuttler.FetchAllow, document, userId)) return false;
         else throw new Meteor.Error('You can not this...');
    }
});
Shuttler.can('someMyAction, Collection.findOne(), Meteor.userId()); // Boolean
Shuttler.can.why('someMyAction, Collection.findOne(), Meteor.userId());
// thrown "You can not this..." if has error
// return true if send restrict
// return link in graph if graph sended

In demo
Red links - examples of some right
Blue links - example of some tree structure (as directories, comments, categories...)
Black documents - as posts, users and other atomic independent entities

You can delete , insert and update anything. Just please do not make eternal cycles ))

Ivan S Glazunov
@ivansglazunov
Mar 04 2016 00:43
I am currently working on a mutually exclusive trees. To be able to create a tree own.allow, but on top imposeown.deny stopping the spread of own.allow.
Simple example:
User A is owner if himself. In own.allow has link A->A. It inherits to all his documents.
User A insert document 1. Auto inherit 1->A in own.allow
User B is owner if himself. In own.allow has link B->B. It inherits to all his documents.
User B insert document 2. Auto inherit 2->A in own.allow
Users A and B is a parts of group C
User B insert to graph own.deny link 2->C. It prohibits members of the group C to own something in the comments tree of the document 2.
Link 2->A automatically removed, because is prohibits.
Now, members of the group C can not own, which means edit their comments on this tree.

Nesting on the demo page, is understood as follows:

<2><4><5></5></4></2>

Ivan S Glazunov
@ivansglazunov
Mar 04 2016 00:54

Nice to represent what will be if you make trees of different trees rights as:

  • own.allow own.deny
  • fetch.allow fetch.deny
  • update.allow update.deny
  • remove.allow remove.deny
  • delete.allow delete.deny (not remove, just mark as deleted...)
  • comment.allow comment.deny
  • buy.allow buy.deny
  • task.allow task.deny (can change status of "task")
    ....

and different semantic trees as:

  • comments comment-drafts
  • tasks.done (link from the task -> user who closed the task)
  • template-nesting (Nesting in a 2 dimensional space element width and height. For visual editors.) { _source, _target, x, y, width, height, template: String, options: Object }
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 03:28
Published package for selection-inheritance. https://github.com/meteor-shuttler/selector
Work on it continues.
echo66
@echo66
Mar 04 2016 14:47
When you talk about actions, what do you mean?
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 16:35
The meteor has 3 standard actions that you can check and limit using the allow or deny. insert, update and remove. With the package https://github.com/ivansglazunov/meteor-restrict you an create your own actions.
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 16:44
actions == operations
http://shuttler.meteor.com Soon there will be demos with detailed examples.
echo66
@echo66
Mar 04 2016 19:20
can you upload that demo to github?
aaaand it's gone
Ivan S Glazunov
@ivansglazunov
Mar 04 2016 20:16
This message was deleted
This message was deleted