Function
contract
Function
contracts
contract
Function
Optionaloptions: { types?: Set<string> } = {}
options
Optionaltypes?: Set<string>the types to consider (all by default)
whether the children are satisfied
Function
Optionaloptions: { types?: Set<string> } = {}
options
Optionaltypes?: Set<string>the types to consider (all by default)
list of unsatisfied requirements
Function
slug - contract canonical slug or slug if canonical slug doesn't exist
Function
Optionaloptions: { types?: Set<string> } = {}
options
Optionaltypes?: Set<string>children types (all by default)
children
Function
options
Optionalfrom?: numbernumber of contracts per combination (from)
Optionalto?: numbernumber 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'
> })
> ]
> ]
Function
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'
> }
> ]
Function
child 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'
}
]
}
]
})
console.log(contract.getNotSatisfiedChildRequirements(child))
Function
whether the contract has aliases
ProtectedhashProtectedinterpolateProtected Function
contract instance
Function
child 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!')
}
StaticbuildFunction
source contract
built contracts
StaticcreateFunction
the match criteria
matcher
A matcher allows to search for child contracts by type, slug, version
range and data. It is a plain object handed straight to the WASM
boundary, where contrato::ContractMatcher validates it — matchers
carrying fields other than type, slug, version and data are
rejected there, at findChildren time.
StaticfromFunction
full path of the directory to load
additional configuration for the search and build process
Protected StaticfromStaticisFunction
whether the contracts are equal
contract