Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@balena/contrato

Package Overview
Dependencies
Maintainers
0
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balena/contrato - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0-build-capability-support-d2b2177197fbbd5575f76f7bb7da76eb59880172-1

1

build/contract.d.ts

@@ -42,2 +42,3 @@ import type { ContractObject } from './types';

}): Contract[];
private isRequirementSatisfied;
getNotSatisfiedChildRequirements(contract: Contract, options?: {

@@ -44,0 +45,0 @@ types: Set<string>;

76

build/contract.js

@@ -274,4 +274,4 @@ "use strict";

const versionMatch = matcher.raw.data.version;
if (contract.raw.capabilities) {
for (const capability of contract.raw.capabilities) {
if (contract.raw.provides) {
for (const capability of contract.raw.provides) {
if (match(capability)) {

@@ -425,2 +425,32 @@ if (versionMatch) {

}
isRequirementSatisfied(requirement, options = {}) {
const shouldEvaluateType = (type) => options.types ? options.types.has(type) : true;
const hasMatch = (matcher) => {
return (this.findChildren(matcher).length > 0 ||
this.findChildrenWithCapabilities(matcher).length > 0);
};
if (requirement.raw.operation === 'or') {
const disjuncts = (0, filter_1.default)(requirement.raw.data.getAll(), (disjunct) => {
return shouldEvaluateType(disjunct.raw.data.type);
});
if (disjuncts.length === 0 || (0, some_1.default)((0, map_1.default)(disjuncts, hasMatch))) {
return true;
}
return false;
}
else if (requirement.raw.operation === 'not') {
const disjuncts = (0, filter_1.default)(requirement.raw.data.getAll(), (disjunct) => {
return shouldEvaluateType(disjunct.raw.data.type);
});
if (disjuncts.length > 0 && (0, some_1.default)((0, map_1.default)(disjuncts, hasMatch))) {
return false;
}
return true;
}
if (shouldEvaluateType(requirement.raw.data.type) &&
!hasMatch(requirement)) {
return false;
}
return true;
}
getNotSatisfiedChildRequirements(contract, options = { types: new Set() }) {

@@ -433,24 +463,7 @@ const conjuncts = (0, reduce_1.default)(contract.getChildren(), (accumulator, child) => {

}
const shouldEvaluateType = (type) => options.types ? options.types.has(type) : true;
const requirements = [];
const hasMatch = (matcher) => {
return (this.findChildren(matcher).length > 0 ||
this.findChildrenWithCapabilities(matcher).length > 0);
};
for (const conjunct of conjuncts) {
if (conjunct.raw.operation === 'or') {
const disjuncts = (0, filter_1.default)(conjunct.raw.data.getAll(), (disjunct) => {
return shouldEvaluateType(disjunct.raw.data.type);
});
if (disjuncts.length === 0 || (0, some_1.default)((0, map_1.default)(disjuncts, hasMatch))) {
continue;
}
if (!this.isRequirementSatisfied(conjunct, options)) {
requirements.push(conjunct.raw.data);
}
if (shouldEvaluateType(conjunct.raw.data.type) && !hasMatch(conjunct)) {
requirements.push(conjunct.raw.data);
}
else if (!shouldEvaluateType(conjunct.raw.data.type)) {
requirements.push(conjunct.raw.data);
}
}

@@ -466,26 +479,7 @@ return requirements;

}
const shouldEvaluateType = (type) => options.types ? options.types.has(type) : true;
const hasMatch = (matcher) => this.findChildren(matcher).length > 0;
for (const conjunct of conjuncts) {
if (conjunct.raw.operation === 'or') {
const disjuncts = (0, filter_1.default)(conjunct.raw.data.getAll(), (disjunct) => {
return shouldEvaluateType(disjunct.raw.data.type);
});
if (disjuncts.length === 0 || (0, some_1.default)((0, map_1.default)(disjuncts, hasMatch))) {
continue;
}
if (!this.isRequirementSatisfied(conjunct, options)) {
console.log('NOT SATISFIED', JSON.stringify(conjunct));
return false;
}
else if (conjunct.raw.operation === 'not') {
const disjuncts = (0, filter_1.default)(conjunct.raw.data.getAll(), (disjunct) => {
return shouldEvaluateType(disjunct.raw.data.type);
});
if (disjuncts.length > 0 && (0, some_1.default)((0, map_1.default)(disjuncts, hasMatch))) {
return false;
}
continue;
}
if (shouldEvaluateType(conjunct.raw.data.type) && !hasMatch(conjunct)) {
return false;
}
}

@@ -492,0 +486,0 @@ return true;

{
"name": "@balena/contrato",
"version": "0.12.0",
"version": "0.13.0-build-capability-support-d2b2177197fbbd5575f76f7bb7da76eb59880172-1",
"description": "The official contract implementation",

@@ -74,4 +74,4 @@ "homepage": "https://github.com/product-os/contrato",

"versionist": {
"publishedAt": "2025-01-13T18:00:19.879Z"
"publishedAt": "2025-01-15T15:33:46.020Z"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc