-
Notifications
You must be signed in to change notification settings - Fork 378
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
1 parent
8d39960
commit da7afa4
Showing
243 changed files
with
7,890 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ThunkAction } from 'redux-thunk'; | ||
import { JsonFormsRendererConstructable } from './renderers/renderer.util'; | ||
import { RankedTester } from './core/testers'; | ||
export declare const INIT = "INIT"; | ||
export declare const UPDATE_DATA = "UPDATE"; | ||
export declare const UPDATE_UI = "UPDATE_UI"; | ||
export declare const VALIDATE = "VALIDATE"; | ||
export declare const SHOW = "SHOW"; | ||
export declare const HIDE = "HIDE"; | ||
export declare const ENABLE = "ENABLE"; | ||
export declare const DISABLE = "DISABLE"; | ||
export declare const ADD_RENDERER = "ADD_RENDERER"; | ||
export declare const REMOVE_RENDERER = "REMOVE_RENDERER"; | ||
export declare const update: (path: string, updater: (any: any) => any) => ThunkAction<void, any, void>; | ||
export declare const validate: () => (dispatch: any, getState: any) => void; | ||
export declare const registerRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { | ||
type: string; | ||
tester: RankedTester; | ||
renderer: JsonFormsRendererConstructable; | ||
}; | ||
export declare const unregisterRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { | ||
type: string; | ||
tester: RankedTester; | ||
renderer: JsonFormsRendererConstructable; | ||
}; |
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,75 @@ | ||
import { UISchemaElement } from './models/uischema'; | ||
import { JsonSchema } from './models/jsonSchema'; | ||
import { UISchemaRegistry } from './core/uischema.registry'; | ||
import { StylingRegistry } from './core/styling.registry'; | ||
import { SchemaService } from './core/schema.service'; | ||
import { Store } from 'redux'; | ||
/** | ||
* Represents a JSONForms service. | ||
*/ | ||
export interface JsonFormService { | ||
/** | ||
* Disposes this service. | ||
*/ | ||
dispose(): void; | ||
} | ||
export declare class JsonFormsConfig { | ||
private _identifyingProp; | ||
setIdentifyingProp(propName: string): void; | ||
getIdentifyingProp(): any; | ||
shouldGenerateIdentifier(): boolean; | ||
} | ||
/** | ||
* Encapsulates instantiation logic of a JSONForms service. | ||
*/ | ||
export interface JsonFormsServiceConstructable { | ||
/** | ||
* Constructor logic. | ||
* | ||
* @param {store} | ||
* @param {JsonSchema} dataSchema the JSON schema describing the data | ||
* @param {UISchemaElement} uiSchema the UI schema to be rendered | ||
*/ | ||
new (store: Store<any>, dataSchema: JsonSchema, uiSchema: UISchemaElement): JsonFormService; | ||
} | ||
/** | ||
* Global JSONForms object that holds services and registries. | ||
*/ | ||
export declare class JsonForms { | ||
private static _config; | ||
private static _schemaService; | ||
static renderers: any[]; | ||
static jsonFormsServices: JsonFormsServiceConstructable[]; | ||
static uischemaRegistry: UISchemaRegistry; | ||
static stylingRegistry: StylingRegistry; | ||
static modelMapping: any; | ||
static schema: JsonSchema; | ||
static readonly schemaService: SchemaService; | ||
static readonly config: JsonFormsConfig; | ||
/** | ||
* Uses the model mapping to filter all objects that are associated with the type | ||
* defined by the given schema id. If there is no applicable mapping, | ||
* we assume that no mapping is necessary and do not filter out affected data objects. | ||
* | ||
* @param objects the list of data objects to filter | ||
* @param schemaId The id of the JsonSchema defining the type to filter for | ||
* @return The filtered data objects or all objects if there is no applicable mapping | ||
*/ | ||
static filterObjectsByType: (objects: Object[], schemaId: string) => Object[]; | ||
/** | ||
* Uses the model mapping to find the schema id defining the type of the given object. | ||
* If no schema id can be determined either because the object is empty, there is no model | ||
* mapping, or the object does not contain a mappable property. | ||
* TODO expected behavior? | ||
* | ||
* @param object The object whose type is determined | ||
* @return The schema id of the object or null if it could not be determined | ||
*/ | ||
static getSchemaIdForObject: (object: Object) => string; | ||
} | ||
/** | ||
* Annotation for registering a class as JSONForms service. | ||
* @param config | ||
* @constructor | ||
*/ | ||
export declare const JsonFormsServiceElement: (config: any) => (cls: JsonFormsServiceConstructable) => void; |
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,20 @@ | ||
import Component from 'inferno-component'; | ||
import { JsonSchema } from '../models/jsonSchema'; | ||
import { Scopable, UISchemaElement } from '../models/uischema'; | ||
import { JsonFormsStore } from '../json-forms'; | ||
export declare const convertToClassName: (value: string) => string; | ||
export declare const getValue: (data: any, controlElement: Scopable, prefix?: string) => any; | ||
export interface RendererProps { | ||
uischema: UISchemaElement; | ||
store: JsonFormsStore; | ||
schema: JsonSchema; | ||
} | ||
export interface RendererState { | ||
selected?: any; | ||
} | ||
export declare class Renderer<P extends RendererProps, S> extends Component<P, S> { | ||
} | ||
export declare const isVisible: (props: any, state: any) => boolean; | ||
export declare const isEnabled: (props: any, state: any) => boolean; | ||
export declare const evalVisibility: (uischema: UISchemaElement, data: any) => boolean; | ||
export declare const evalEnablement: (uischema: UISchemaElement, data: any) => boolean; |
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,75 @@ | ||
/** | ||
* The different types of runtime related changes. | ||
*/ | ||
export declare enum RUNTIME_TYPE { | ||
VALIDATION_ERROR = 0, | ||
VISIBLE = 1, | ||
ENABLED = 2, | ||
} | ||
/** | ||
* A listener that is notified about any runtime related changes. | ||
*/ | ||
export interface RuntimeListener { | ||
/** | ||
* Called when a runtime related property changes. | ||
* @param {RUNTIME_TYPE} type the type of runtime change | ||
*/ | ||
runtimeUpdated(type: RUNTIME_TYPE): void; | ||
} | ||
/** | ||
* A runtime object holds information about runtime related properties | ||
* of a rendered UI schema element, like the visible/disabled state and | ||
* possible validation errors. | ||
*/ | ||
export declare class Runtime { | ||
private validationErrorMessages; | ||
private isVisible; | ||
private isEnabled; | ||
private listeners; | ||
/** | ||
* Whether the element is visible. | ||
* @return {boolean} true, if the element is visible, false otherwise | ||
*/ | ||
/** | ||
* Set the visibility state of the element | ||
* @param {boolean} visible whether the element should be visible | ||
*/ | ||
visible: boolean; | ||
/** | ||
* Whether the element is enabled. | ||
* @return {boolean} true, if the element is enabled, false otherwise | ||
*/ | ||
/** | ||
* Set the enabled state of the element | ||
* @param {boolean} enabled whether the element should be enabled | ||
*/ | ||
enabled: boolean; | ||
/** | ||
* Returns the validation errors associated with the element. | ||
* @return {Array<string>} the validation errors | ||
*/ | ||
/** | ||
* Set the validation errors. | ||
* | ||
* @param {string[]} validationErrors the validation errors | ||
*/ | ||
validationErrors: string[]; | ||
/** | ||
* Add the given runtime listener. | ||
* | ||
* @param {RuntimeListener} listener the runtime listener to be added | ||
*/ | ||
registerRuntimeListener(listener: RuntimeListener): void; | ||
/** | ||
* Remove the given runtime listener. | ||
* | ||
* @param {RuntimeListener} listener the runtime listener to be removed | ||
*/ | ||
deregisterRuntimeListener(listener: RuntimeListener): void; | ||
/** | ||
* Notifies any runtime listeners about a runtime change. | ||
* | ||
* @param {RUNTIME_TYPE} type the runtime type | ||
*/ | ||
private notifyRuntimeListeners(type); | ||
} |
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,158 @@ | ||
import { JsonSchema } from '../models/jsonSchema'; | ||
/** | ||
* A Property wraps a JsonSchema and provides additional information | ||
* like a label and the property key. | ||
*/ | ||
export interface Property { | ||
/** | ||
* The label is a text donating a human readable name of the schema the property describes. | ||
*/ | ||
readonly label: string; | ||
/** | ||
* The property is a text donating the schema key from which this property was created. | ||
*/ | ||
readonly property: string; | ||
/** | ||
* The schema is the JsonSchema this property describes. | ||
*/ | ||
readonly schema: JsonSchema; | ||
} | ||
/** | ||
* A ContainmentProperty extends the Property and provides methods | ||
* which allow to modify containment data. | ||
* @see Property | ||
*/ | ||
export interface ContainmentProperty extends Property { | ||
/** | ||
* This allows to add data to the containment. | ||
* @param data The object to add to | ||
* @return a function that expects the element to be added and optionally the value next to which | ||
* the new value is added. insertAfter defines whether the new value should be added | ||
* after or before the neighbourValue. If no neighbour value is provided or it does not | ||
* exist in the containment, the valueToAdd is inserted at the end. | ||
*/ | ||
addToData(data: Object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; | ||
/** | ||
* This allows to delete data from the containment. | ||
* The result is a function accepting the value to delete. | ||
* @param data The object to delete from | ||
* @return function accepting the value to delete | ||
*/ | ||
deleteFromData(data: Object): (valueToDelete: object) => void; | ||
/** | ||
* This allows to retrieve the data of the containment. | ||
* @param data The object the containment is in | ||
* @return The containment value (e.g. an array) | ||
*/ | ||
getData(data: Object): Object; | ||
} | ||
/** | ||
* A ReferenceProperty extends the Property and provides methods | ||
* which allow to modify reference data. | ||
*/ | ||
export interface ReferenceProperty extends Property { | ||
/** | ||
* The schema of the referenced elements. | ||
*/ | ||
readonly targetSchema: JsonSchema; | ||
/** | ||
* This allows to set the reference. | ||
* @param root The root object, needed for matching the valueToAdd | ||
* @param data The object to add to | ||
* @param valueToAdd The object to add | ||
*/ | ||
addToData(root: Object, data: Object, valueToAdd: object): void; | ||
/** | ||
* This allows to retrieve the data of the reference. | ||
* @param root The root object, needed for finding the value to retrieve | ||
* @param data The object the reference is in | ||
* @return The referenced value | ||
*/ | ||
getData(root: Object, data: Object): Object; | ||
/** | ||
* Returns all possible objects which can be referenced by this property. | ||
* | ||
* @param root The root data object needed for finding the values | ||
* @return The array of data objects which are possible reference targets | ||
* for this reference property. | ||
*/ | ||
findReferenceTargets(rootData: Object): Object[]; | ||
/** | ||
* Resolves a reference value for this Reference by using the given porpertyValue to | ||
* identify the referenced Object. | ||
* | ||
* @param rootData The root data object needed for finding the referenced value. | ||
* @param propertyValue The property value identifying the referenced data object. | ||
* @return The resolved data object or null if it coiuld not be resolved. | ||
*/ | ||
resolveReference(rootData: Object, propertyValue: string): Object; | ||
} | ||
export declare class ContainmentPropertyImpl implements ContainmentProperty { | ||
private innerSchema; | ||
private key; | ||
private name; | ||
private addFunction; | ||
private deleteFunction; | ||
private getFunction; | ||
constructor(innerSchema: JsonSchema, key: string, name: string, addFunction: (data: object) => (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void, deleteFunction: (data: object) => (valueToDelete: object) => void, getFunction: (data: object) => Object); | ||
readonly label: string; | ||
readonly schema: JsonSchema; | ||
readonly property: string; | ||
addToData(data: object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; | ||
deleteFromData(data: object): (valueToDelete: object) => void; | ||
getData(data: object): Object; | ||
} | ||
export declare class ReferencePropertyImpl implements ReferenceProperty { | ||
private innerSchema; | ||
private innerTargetSchema; | ||
private key; | ||
private name; | ||
private pathToContainment; | ||
private identifyingProperty; | ||
private addFunction; | ||
private getFunction; | ||
constructor(innerSchema: JsonSchema, innerTargetSchema: JsonSchema, key: string, name: string, pathToContainment: string, identifyingProperty: string, addFunction: (root: object, data: object, valueToAdd: object) => void, getFunction: (root: object, data: object) => Object); | ||
readonly label: string; | ||
readonly schema: JsonSchema; | ||
readonly property: string; | ||
readonly targetSchema: JsonSchema; | ||
addToData(root: object, data: object, valueToAdd: object): void; | ||
getData(root: object, data: object): Object; | ||
findReferenceTargets(rootData: Object): Object[]; | ||
resolveReference(rootData: Object, propertyValue: string): Object; | ||
} | ||
export declare const isContainmentProperty: (property: Property) => property is ContainmentProperty; | ||
export declare const isReferenceProperty: (property: Property) => property is ReferenceProperty; | ||
/** | ||
* The Schema Service allows to retrieve containments and references. | ||
*/ | ||
export interface SchemaService { | ||
/** | ||
* Retrieves an array of containment properties based on the provided schema. | ||
* @param schema The schema to check for containments | ||
* @return The array of {@link ContainmentProperty} or empty if no containments are available | ||
* @see ContainmentProperty | ||
*/ | ||
getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; | ||
/** | ||
* Checks whether a containment properties are available in the provided schema. | ||
* @param schema The schema to check for containments | ||
* @return true if containment properties are available, false otherwise | ||
* @see {@link getContainmentProperties} | ||
*/ | ||
hasContainmentProperties(schema: JsonSchema): boolean; | ||
/** | ||
* Retieves a self contained schema. | ||
* @param parentSchema The schema to use for resolvement | ||
* @param refPath The path to resolve | ||
* @return a JsonSchema that is self-contained | ||
*/ | ||
getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; | ||
/** | ||
* Retrieves an array of reference properties based on the provided schema. | ||
* @param schema The schema to check for references | ||
* @return The array of {@link ReferenceProperty} or empty if no references are available | ||
* @see ReferenceProperty | ||
*/ | ||
getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; | ||
} |
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,24 @@ | ||
import { JsonSchema } from '../models/jsonSchema'; | ||
import { ContainmentProperty, ReferenceProperty, SchemaService } from './schema.service'; | ||
export declare class SchemaServiceImpl implements SchemaService { | ||
private rootSchema; | ||
private selfContainedSchemas; | ||
constructor(rootSchema: JsonSchema); | ||
getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; | ||
hasContainmentProperties(schema: JsonSchema): boolean; | ||
getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; | ||
getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; | ||
private getContainment(key, name, schema, rootSchema, isInContainment, addFunction, deleteFunction, getFunction); | ||
/** | ||
* Makes the given JsonSchema self-contained. This means all referenced definitions | ||
* are contained in the schema's definitions block and references equal to | ||
* outerReference are set to root ('#'). | ||
* | ||
* @param schema The current schema to make self contained | ||
* @param outerSchema The root schema to which missing definitions are added | ||
* @param outerReference The reference which is considered to be self ('#') | ||
* @param includedDefs The list of definitions which were already added to the outer schema | ||
*/ | ||
private selfContainSchema(schema, outerSchema, outerReference, includedDefs?); | ||
private copyAndResolveInner(resolved, innerRef, outerSchema, outerReference, includedDefs); | ||
} |
Oops, something went wrong.