Functioncontracts
Optionaloptions: object = {}options
contract
FunctionOptionaloptions: { types?: Set<string> } = {}options
Optionaltypes?: Set<string>the types to consider (all by default)
whether the children are satisfied
Functionoptions
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'
> })
> ]
> ]
Functionchildren 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'
> }
> ]
Functionchild contract
Optionaloptions: { types?: Set<string> } = {}options
Optionaltypes?: 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!')
}
Functionwhether the contract has aliases
ProtectedhashProtectedinterpolateProtectedrebuildFunctioncontract
Optionaloptions: object = {}options
parent contract
Functionchild contract
Optionaloptions: { types?: Set<string> } = {}options
Optionaltypes?: 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!')
}
StaticbuildFunctionsource contract
built contracts
Protected StaticcreateProtected Functionmatcher data
Optionaloptions: { operation?: string } = {}options
Optionaloperation?: stringthe matcher's operation
matcher contract
StaticfromFunctionfull path of the directory to load
additional configuration for the search and build process
StaticisFunctionwhether the contracts are equal
contract