-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
165 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,17 @@ | ||
import { Properties } from 'sequential-workflow-model'; | ||
import { ModelActivator } from '../activator'; | ||
import { PropertyModel, ValueModel } from '../model'; | ||
import { ValueContext } from './value-context'; | ||
import { readPropertyValue } from './read-property-value'; | ||
import { PropertyContext } from './property-context'; | ||
|
||
export class DefaultValueContext<TProperties extends Properties = Properties> { | ||
public static create<TProps extends Properties = Properties>( | ||
activator: ModelActivator, | ||
object: object, | ||
model: PropertyModel | ||
propertyContext: PropertyContext<TProps> | ||
): DefaultValueContext<TProps> { | ||
return new DefaultValueContext<TProps>(activator, name => readPropertyValue(name, model, object)); | ||
return new DefaultValueContext<TProps>(activator, propertyContext); | ||
} | ||
|
||
public static createFromValueContext<TProps extends Properties = Properties>( | ||
activator: ModelActivator, | ||
valueContext: ValueContext<ValueModel, TProps> | ||
): DefaultValueContext<TProps> { | ||
return new DefaultValueContext(activator, valueContext.getPropertyValue); | ||
} | ||
|
||
private constructor( | ||
private readonly activator: ModelActivator, | ||
public readonly getPropertyValue: <Key extends keyof TProperties>(name: Key) => TProperties[Key] | ||
) {} | ||
private constructor(private readonly activator: ModelActivator, public readonly propertyContext: PropertyContext<TProperties>) {} | ||
|
||
public readonly getPropertyValue = this.propertyContext.getPropertyValue; | ||
public readonly activateStep = this.activator.activateStep; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './default-value-context'; | ||
export * from './property-context'; | ||
export * from './scoped-property-context'; | ||
export * from './value-context'; | ||
export * from './definition-context'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Properties } from 'sequential-workflow-model'; | ||
import { DefinitionModel, PropertyModel } from '../model'; | ||
import { ValueType } from '../types'; | ||
import { readPropertyValue } from './read-property-value'; | ||
|
||
export class PropertyContext<TProperties extends Properties = Properties> { | ||
public static create<TProps extends Properties = Properties>( | ||
object: object, | ||
propertyModel: PropertyModel, | ||
definitionModel: DefinitionModel | ||
): PropertyContext<TProps> { | ||
return new PropertyContext<TProps>(object, propertyModel, definitionModel); | ||
} | ||
|
||
private constructor( | ||
public readonly object: object, | ||
private readonly propertyModel: PropertyModel, | ||
private readonly definitionModel: DefinitionModel | ||
) {} | ||
|
||
public readonly getPropertyValue = <Key extends keyof TProperties>(name: Key): TProperties[Key] => { | ||
return readPropertyValue(name, this.propertyModel, this.object); | ||
}; | ||
|
||
public readonly getValueTypes = (): ValueType[] => { | ||
return this.definitionModel.valueTypes; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Properties } from 'sequential-workflow-model'; | ||
import { ContextVariable } from '../model'; | ||
import { ParentsProvider } from './variables-provider'; | ||
import { PropertyContext } from './property-context'; | ||
|
||
export class ScopedPropertyContext<TProperties extends Properties> { | ||
public static create<TProps extends Properties>( | ||
propertyContext: PropertyContext<TProps>, | ||
parentsProvider: ParentsProvider | ||
): ScopedPropertyContext<TProps> { | ||
return new ScopedPropertyContext<TProps>(propertyContext, parentsProvider); | ||
} | ||
|
||
private constructor(public readonly propertyContext: PropertyContext<TProperties>, private readonly parentsProvider: ParentsProvider) {} | ||
|
||
public readonly getPropertyValue = this.propertyContext.getPropertyValue; | ||
public readonly getValueTypes = this.propertyContext.getValueTypes; | ||
|
||
public readonly hasVariable = (variableName: string, valueType: string | null): boolean => { | ||
return this.getVariables().some(v => v.name === variableName && (valueType === null || v.type === valueType)); | ||
}; | ||
|
||
public readonly findFirstUndefinedVariable = (variableNames: string[]): string | undefined => { | ||
const variables = new Set(this.getVariables().map(v => v.name)); | ||
return variableNames.find(name => !variables.has(name)); | ||
}; | ||
|
||
public readonly isVariableDuplicated = (variableName: string): boolean => { | ||
return this.getVariables().filter(v => v.name === variableName).length > 1; | ||
}; | ||
|
||
public readonly getVariables = (): ContextVariable[] => { | ||
return this.parentsProvider.getVariables(); | ||
}; | ||
} |
Oops, something went wrong.