🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@seneca/entity-depend

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@seneca/entity-depend

Handle dependency relationships on entity verison

latest
Source
npmnpm
Version
0.6.0
Version published
Maintainers
2
Created
Source

seneca-entity-depend

Handle dependency relationships on entity verison

npm version !Build Coverage Status Maintainability DeepScan grade

NOTE

  • Only works on @seneca/entity-history enabled ents (as per ent option of @seneca/entity-history).

Message Tutorial

These can be run interactively with [seneca-repl](senecajs/seneca-repl. To use in code, call with let out = await seneca.post(msg).

Create some entities

> sys:entity,cmd:save,name:foo,ent:{x:1,y:'Y'} => foo1=out
{ id: <ID>, x: 1, y: 'Y' }
> sys:entity,cmd:save,name:foo,ent:{x:2,y:'YY'} => foo2=out
{ id: <ID>, x: 2, y: 'YY' }

Create a dependency

> sys:entity,rig:depend,name:foo,make:child,parent_id:`$.foo1.id` => foo1c1=out
{ id: <ID>, x: 1, y: 'Y' }

Pull latest updates from parent, child's changes have precedence

Pulls all changes from previous pull point (initially the depend point). Default is to keep child's conflicting changes.

> sys:entity,rig:depend,name:foo,pull:parent,child_id:`$.foo1c1.id` => foo1c1=out

Pull latest updates from parent, parents's changes have precedence

> sys:entity,rig:depend,name:foo,pull:parent,keep:parent,child_id:`$.foo1c1.id` 
    => foo1c1=out

Pull latest updates from child

Pulls all changes since previous pull point (initially the depend point). Default is to keep parent's conflicting changes.

> sys:entity,rig:depend,name:foo,pull:child,parent_id:`$.foo1.id`,child_id:`$.foo1c1.id` 
    => foo1=out

Keep child's conflicting changes:

> sys:entity,rig:depend,name:foo,pull:child,keep:child,parent_id:`$.foo1.id`,child_id:`$.foo1c1.id` 
    => foo1=out

Parent to child relationship is one-to-many. Thus pull:child needs both child_id and parent_id.

Generate a pull request

> sys:entity,rig:depend,name:foo,pull:child,make:request,parent_id:`$.foo1.id`,child_id:`$.foo1c1.id` 
    => pr0=out

Pull request operations

List pull requests against child and parent, as provided

> sys:entity,rig:depend,name:foo,list:request,parent_id?,child_id?

Apply a pull request. Same as applying pull operation above.

> sys:entity,rig:depend,name:foo,apply:request,request_id

Preview pull operation

See which fields are changed in parent and child.

> sys:entity,rig:depend,name:foo,pull-preview:parent,child_id:`$.foo1c1.id` => preview1=out

Pull latest updates from parent, specific version

Pulls all changes from specified version. NOTE: uses entity-history directly

> sys:entity,rig:depend,entity:depend,ent:{name:foo,id:`$.foo1`} => h0=out.items
> sys:entity,rig:depend,name:foo,pull:parent,child_id:`$.foo1c1.id`,
    parent_ver_id:`$.h0[0].id` => foo1c1=out

Implementation

Entities

  • sys/entdep: Dependency relationships established with make:child
  • sys/pullhist: Pull history.
  • sys/pullreq: Pull requests.

TODO:

  • Patterns should support ent param as well as top level base,name,id.
  • Support make:parent

FAQs

Package last updated on 24 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts