options
number of contracts per combination (from)
number of contracts per combination (to)
contract type
combinations
Note that the client is responsible for evaluating that the combination of contracts is valid with regards to requirements, conflicts, etc. This function simply returns all the possible combinations without any further checks.
The combinations output by this function is a plain list of contracts from which you can create a contract, or any other application specific data structure.
const contract = new Contract({ ... })
contract.addChildren([
new Contract({
name: 'Debian Wheezy',
version: 'wheezy',
slug: 'debian',
type: 'sw.os'
}),
new Contract({
name: 'Debian Jessie',
version: 'jessie',
slug: 'debian',
type: 'sw.os'
}),
new Contract({
name: 'Fedora 25',
version: '25',
slug: 'fedora',
type: 'sw.os'
})
])
const combinations = contract.getChildrenCombinations({
type: 'sw.os',
from: 2,
to: 2
})
console.log(combinations)
> [
> [
> new Contract({
> name: 'Debian Wheezy',
> version: 'wheezy',
> slug: 'debian',
> type: 'sw.os'
> }),
> new Contract({
> name: 'Debian Jessie',
> version: 'jessie',
> slug: 'debian',
> type: 'sw.os'
> })
> ],
> [
> new Contract({
> name: 'Debian Wheezy',
> version: 'wheezy',
> slug: 'debian',
> type: 'sw.os'
> }),
> new Contract({
> name: 'Fedora 25',
> version: '25',
> slug: 'fedora',
> type: 'sw.os'
> })
> ],
> [
> new Contract({
> name: 'Debian Jessie',
> version: 'jessie',
> slug: 'debian',
> type: 'sw.os'
> }),
> new Contract({
> name: 'Fedora 25',
> version: '25',
> slug: 'fedora',
> type: 'sw.os'
> })
> ]
> ]
children cross referenced contracts
const contract = new Contract({ ... })
contract.addChildren([
new Contract({
type: 'arch.sw',
slug: 'armv7hf',
name: 'armv7hf'
}),
new Contract({
type: 'sw.os',
slug: 'raspbian',
requires: [
{
or: [
{
type: 'arch.sw',
slug: 'armv7hf'
},
{
type: 'arch.sw',
slug: 'rpi'
}
]
}
]
}),
new Contract({
type: 'sw.stack',
slug: 'nodejs',
requires: [
{
type: 'arch.sw',
slug: 'armv7hf'
}
]
})
])
const references = contract.getChildrenCrossReferencedContracts({
from: contract,
types: new Set([ 'arch.sw' ])
})
console.log(references)
> [
> Contract {
> type: 'arch.sw',
> slug: 'armv7hf',
> name: 'armv7hf'
> }
> ]
child contract
Optional
options: { types?: Set<string> } = {}options
Optional
types?: Set<string>the types to consider (all by default)
list of unsatisfied requirements
const contract = new Contract({ ... })
contract.addChildren([
new Contract({
type: 'sw.os',
name: 'Debian Wheezy',
version: 'wheezy',
slug: 'debian'
}),
new Contract({
type: 'sw.os',
name: 'Fedora 25',
version: '25',
slug: 'fedora'
})
])
const child = new Contract({
type: 'sw.stack',
name: 'Node.js',
version: '4.8.0',
slug: 'nodejs',
requires: [
{
or: [
{
type: 'sw.os',
slug: 'debian'
},
{
type: 'sw.os',
slug: 'fedora'
}
]
}
]
})
if (contract.satisfiesChildContract(child)) {
console.log('The child contract is satisfied!')
}
Protected
hashProtected
interpolateProtected
rebuildchild contract
Optional
options: { types?: Set<string> } = {}options
Optional
types?: Set<string>the types to consider (all by default)
whether the contract is satisfied
const contract = new Contract({ ... })
contract.addChildren([
new Contract({
type: 'sw.os',
name: 'Debian Wheezy',
version: 'wheezy',
slug: 'debian'
}),
new Contract({
type: 'sw.os',
name: 'Fedora 25',
version: '25',
slug: 'fedora'
})
])
const child = new Contract({
type: 'sw.stack',
name: 'Node.js',
version: '4.8.0',
slug: 'nodejs',
requires: [
{
or: [
{
type: 'sw.os',
slug: 'debian'
},
{
type: 'sw.os',
slug: 'fedora'
}
]
}
]
})
if (contract.satisfiesChildContract(child)) {
console.log('The child contract is satisfied!')
}
Static
buildProtected
Static
createStatic
is
the contract plain object