Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const AssetDeclaration = require('composer-common').AssetDeclaration;
const EventEmitter = require('events');
const Logger = require('composer-common').Logger;
const ParticipantDeclaration = require('composer-common').ParticipantDeclaration;
const TransactionDeclaration = require('composer-common').TransactionDeclaration;
const Registry = require('./registry');
const LOG = Logger.getLog('RegistryManager');
// Do not add additional types to these constants. All system types are assets.
const TYPE_MAP = {
Asset : 'AssetRegistry',
Participant : 'ParticipantRegistry',
Transaction : 'TransactionRegistry',
Network : 'Network'
};
// This is a list of non-abstract system types that we do not want registries created for.
const VIRTUAL_TYPES = [
'Network'
];
/**
* A class for managing and persisting registries.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const Logger = require('composer-common').Logger;
const LOG = Logger.getLog('TransactionHandler');
/**
* A transaction handler class can bind transaction processor functions which are
* then executed when the bound transaction type is submitted.
* @abstract
* @protected
*/
class TransactionHandler {
/**
* Constructor.
*/
constructor() {
this.handlers = {};
}
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const createHash = require('sha.js');
const Logger = require('composer-common').Logger;
const LOG = Logger.getLog('CompiledQueryBundle');
/**
* A script compiler compiles all scripts in a script manager into a compiled
* script bundle that can easily be called by the runtime.
* @protected
*/
class CompiledQueryBundle {
/**
* Constructor.
* @param {QueryCompiler} queryCompiler The query compiler to use.
* @param {QueryManager} queryManager The query manager to use.
* @param {Object[]} compiledQueries The compiled queries to use.
*/
constructor(queryCompiler, queryManager, compiledQueries) {
const method = 'constructor';
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const jsonata = require('jsonata');
const Logger = require('composer-common').Logger;
const Relationship = require('composer-common').Relationship;
const Resource = require('composer-common').Resource;
const LOG = Logger.getLog('QueryEngine');
/**
* Design documentation:
*
* The aim of this class to execute queries (currently JSONata expressions) on a
* resource or a set of resources. In order for this query support to be useful,
* the queries must be able to navigate relationships between resources. For example,
* I might want to execute a query of "find all the animals which are in a field,
* where that field is owned by a business, where that business is run by a farmer
* with the email address alice@farmers.com".
*
* We do not want to eagerly resolve all visible relationships, as this is slow.
* Most business networks are large and complex, with many relationships between
* resources, and additionally those relationships can be circular.
*
* Ideally, we would only resolve relationships that are needed in order to
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const Logger = require('composer-common').Logger;
const LOG = Logger.getLog('CompiledScriptBundle');
/**
* A script compiler compiles all scripts in a script manager into a compiled
* script bundle that can easily be called by the runtime.
* @protected
*/
class CompiledScriptBundle {
/**
* Constructor.
* @param {FunctionDeclaration[]} functionDeclarations The function declarations to use.
* @param {Function} generatorFunction The generator function to use.
*/
constructor(functionDeclarations, generatorFunction) {
this.functionDeclarations = functionDeclarations;
this.generatorFunction = generatorFunction;