@ayana/bento
Advanced tools
Comparing version 1.0.0-alpha1 to 1.0.0-alpha2
@@ -5,2 +5,5 @@ import { ComponentEvents } from './helpers/ComponentEvents'; | ||
} | ||
export interface SetProperties { | ||
[key: string]: any; | ||
} | ||
export declare class Bento { | ||
@@ -40,6 +43,6 @@ /** | ||
/** | ||
* Fetch a value for given application property | ||
* @param name - name of variable to get | ||
* Define multiple application properties at once | ||
* @param properties - SetProperties object | ||
*/ | ||
getProperty(name: string): any; | ||
setProperties(properties: SetProperties): void; | ||
/** | ||
@@ -52,9 +55,9 @@ * Update a given application property value | ||
/** | ||
* Fetch a value for given variable name | ||
* Fetch a value for given application property | ||
* @param name - name of variable to get | ||
*/ | ||
getVariable(name: string): any; | ||
getProperty(name: string): any; | ||
/** | ||
* Update a given variables value | ||
* @param name -name of variable to update | ||
* @param name - name of variable to update | ||
* @param value - new value | ||
@@ -64,2 +67,7 @@ */ | ||
/** | ||
* Fetch a value for given variable name | ||
* @param name - name of variable to get | ||
*/ | ||
getVariable(name: string): any; | ||
/** | ||
* Add a Plugin to Bento | ||
@@ -66,0 +74,0 @@ * @param plugin - plugin to add |
@@ -36,9 +36,9 @@ 'use strict'; | ||
/** | ||
* Fetch a value for given application property | ||
* @param name - name of variable to get | ||
* Define multiple application properties at once | ||
* @param properties - SetProperties object | ||
*/ | ||
getProperty(name) { | ||
if (!this.properties.has(name)) | ||
return null; | ||
return this.properties.get(name); | ||
setProperties(properties) { | ||
for (const [name, value] of Object.entries(properties)) { | ||
this.setProperty(name, value); | ||
} | ||
} | ||
@@ -54,19 +54,32 @@ /** | ||
/** | ||
* Fetch a value for given variable name | ||
* Fetch a value for given application property | ||
* @param name - name of variable to get | ||
*/ | ||
getVariable(name) { | ||
if (!this.variables.has(name)) | ||
getProperty(name) { | ||
if (!this.properties.has(name)) | ||
return null; | ||
return this.variables.get(name); | ||
return this.properties.get(name); | ||
} | ||
/** | ||
* Update a given variables value | ||
* @param name -name of variable to update | ||
* @param name - name of variable to update | ||
* @param value - new value | ||
*/ | ||
setVariable(name, value) { | ||
// Enforce all variables to upper case | ||
name = name.toUpperCase(); | ||
this.variables.set(name, value); | ||
} | ||
/** | ||
* Fetch a value for given variable name | ||
* @param name - name of variable to get | ||
*/ | ||
getVariable(name) { | ||
// Enforce all variables to upper case | ||
name = name.toUpperCase(); | ||
if (!this.variables.has(name)) | ||
return null; | ||
return this.variables.get(name); | ||
} | ||
/** | ||
* Add a Plugin to Bento | ||
@@ -73,0 +86,0 @@ * @param plugin - plugin to add |
@@ -48,2 +48,4 @@ 'use strict'; | ||
addDefinition(definition) { | ||
if (!definition.type) | ||
throw new errors_1.IllegalArgumentError('VariableDefinition must define a type'); | ||
if (!definition.name) | ||
@@ -91,2 +93,3 @@ throw new errors_1.IllegalArgumentError('VariableDefinition must define a name'); | ||
throw new VariableProcessError_1.VariableProcessError(this.name, definition, 'required variable not found'); | ||
// TODO: use definition.type to convert value to proper type | ||
// TODO: Validator support | ||
@@ -93,0 +96,0 @@ this.variables.set(definition.name, value); |
@@ -1,3 +0,3 @@ | ||
import { ComponentAPI } from "../helpers"; | ||
import { VariableDefinition } from "./VariableDefinition"; | ||
import { ComponentAPI } from '../helpers'; | ||
import { VariableDefinition } from './VariableDefinition'; | ||
export interface PrimaryComponent { | ||
@@ -4,0 +4,0 @@ api?: ComponentAPI; |
@@ -1,3 +0,3 @@ | ||
import { ComponentAPI } from "../helpers"; | ||
import { VariableDefinition } from "./VariableDefinition"; | ||
import { ComponentAPI } from '../helpers'; | ||
import { VariableDefinition } from './VariableDefinition'; | ||
export interface SecondaryComponent { | ||
@@ -4,0 +4,0 @@ api?: ComponentAPI; |
import { VariableDefinitionValidator } from './VariableDefinitionValidator'; | ||
export interface VariableDefinition { | ||
type: string; | ||
name: string; | ||
@@ -4,0 +5,0 @@ default?: any; |
{ | ||
"name": "@ayana/bento", | ||
"version": "1.0.0-alpha1", | ||
"version": "1.0.0-alpha2", | ||
"description": "Modular runtime framework designed to solve complex tasks", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114394
109
2013