Determine application artifacts by inspecting flow, pages and widgets.
Module Members
- [- unknown -](#- unknown -)
- create()
- collectArtifacts()
- collectSchemas()
- collectFlows()
- collectThemes()
- collectPages()
- collectLayouts()
- collectWidgets()
- collectControls()
Types
Create an artifact collector instance.
Example:
const collector = laxarTooling.artifactCollector.create( {
paths: { widgets: 'custom/widgets/path' },
resolve: ref => path.relative( base, path.resolve( ref ) ),
readJson: filename => new Promise( ( resolve, reject ) => {
fs.readFile( filename, ( err, contents ) => {
try {
err ? reject( err ) : resolve( JSON.parse( contents ) );
}
catch( err ) {
reject( err );
}
} );
} )
} );
Property | Type | Description |
---|---|---|
options | Object |
additional options |
options.paths | Object |
configuration where to look for flows, pages, etc. |
options.resolve | Function |
a function resolving a given file path to something that can be read by the readJson function and either returning it as a String or asynchronously |
options.readJson | Function |
a function accepting a file path as an argument and returning a promise that resolves to the parsed JSON contents of the file as a Promise |
options.fileContents | Object |
an object mapping file paths (as returned by options.resolve ) to promises that resolve to the parsed JSON contents of the file (used if readJson is omitted) |
Type | Description |
---|---|
ArtifactCollector |
the created artifact collector |
Obtain artifact information asynchronously, starting from a set of flow definitions.
Example:
collector.collectArtifacts( [ { flows: [ "flow" ], themes: [ "my", "default" ] } ] )
.then( artifacts => {
assert( Array.isArray( artifacts.flows ) );
assert( Array.isArray( artifacts.themes ) );
assert( Array.isArray( artifacts.pages ) );
assert( Array.isArray( artifacts.layouts ) );
assert( Array.isArray( artifacts.widgets ) );
assert( Array.isArray( artifacts.controls ) );
} );
// => {
// flows: [ ... ],
// themes: [ ... ],
// pages: [ ... ],
// layouts: [ ... ],
// widgets: [ ... ],
// contros: [ ... ]
// }
Property | Type | Description |
---|---|---|
entries | Array.<Object> |
a list of entries containing themes and flows to follow to find all the pages reachable from the flow and their required artifacts |
Type | Description |
---|---|
Promise.<Object> |
the artifact listing with the keys flows , themes , pages , layouts , widgets and controls , of which each is an array of artifact objects |
Asynchronously collect all schemas corresponding to the given paths.
Example:
collector.collectSchemas( [ { schemas: [ 'schema' ] } ] )
.then( schemas => {
assert( Array.isArray( schemas ) );
} );
// => [ {
// refs: [ 'schema' ],
// name: 'schema',
// path: 'path/to/schema.json',
// pages: [ ... ]
// } ]
Property | Type | Description |
---|---|---|
entries | Array |
a list of entry objects containing a schemas key |
Type | Description |
---|---|
Promise.<Array> |
a promise for an array of schema-meta objects |
Asynchronously collect all flows corresponding to the given refs.
Example:
collector.collectFlows( [ { flows: [ 'flow' ] } ] )
.then( flows => {
assert( Array.isArray( flows ) );
} );
// => [ {
// refs: [ 'flow' ],
// name: 'flow',
// path: 'path/to/flow.json',
// pages: [ ... ]
// } ]
Property | Type | Description |
---|---|---|
entries | Array |
a list of entry objects containing a flows key |
Type | Description |
---|---|
Promise.<Array> |
a promise for an array of flow-meta objects |
Collect meta information on the given themes.
Example:
collector.collectThemes( [ { themes: [ 'my.theme', 'default.theme' ] } ] )
.then( themes => {
assert( Array.isArray( themes ) );
} );
// => [ {
// refs: [ 'my.theme' ],
// name: 'my.theme',
// path: 'path/to/my.theme'
// }, {
// refs: [ 'default.theme' ],
// name: 'default.theme',
// path: 'path/to/laxar-uikit/themes/default.theme'
// } ]
Property | Type | Description |
---|---|---|
entries | Array.<Object> |
a list of entries with themes to include in the artifacts |
Type | Description |
---|---|
Promise.<Array> |
a promise for an array of meta-information about all themes |
Asynchronously collect all pages that are reachable from the given list of flows.
Example:
collector.collectPages( flows )
.then( pages => {
assert( Array.isArray( pages ) );
} );
// => [ {
// refs: [ 'page' ],
// name: 'page',
// path: 'path/to/page.json',
// pages: [ ... ],
// layouts: [ ... ],
// widgets: [ ... ]
// }, ... ]
Property | Type | Description |
---|---|---|
flows | Array.<String> |
a list of flow artifacts as returned by ArtifactCollector#collectFlows |
Type | Description |
---|---|
Promise.<Array> |
a promise for a combined array of page meta information for these flows |
Finds layouts based on them being referenced in page areas.
Example:
collector.collectLayouts( pages )
.then( layouts => {
assert( Array.isArray( layouts ) );
} );
// => [ {
// refs: [ 'layout' ],
// name: 'layout',
// path: 'path/to/layout'
// }, ... ]
Property | Type | Description |
---|---|---|
pages | Array |
a list of page artifacts as returned by ArtifactCollector#collectPages |
Type | Description |
---|---|
Promise.<Array> |
a promise for an array of meta-information about all layouts |
Collect meta information on all widget that are referenced from the given pages.
Example:
collector.collectWidgets( pages )
.then( widgets => {
assert( Array.isArray( widgets ) );
} );
// => [ {
// refs: [ 'widget' ],
// name: 'widget',
// path: 'path/to/widget',
// controls: [ ... ]
// }, ... ]
Property | Type | Description |
---|---|---|
pages | Array |
a list of page artifacts as returned by ArtifactCollector#collectPages |
Type | Description |
---|---|
Promise.<Array> |
a promise for an array of meta-information about all reachable widgets |
Collect meta information on all controls that are referenced by the given widgets.
Example:
collector.collectControls( widgets, themes )
.then( controls => {
assert( Array.isArray( controls ) );
} );
// => [ {
// refs: [ 'control' ],
// name: 'control',
// path: 'path/to/control',
// controls: [ ... ]
// }, ... ]
Property | Type | Description |
---|---|---|
widgets | Array |
a list of widget artifacts as returned by ArtifactCollector#collectWidgets |
Type | Description |
---|---|
Promise.<Array> |
a promise for an array of meta-information about all reachable controls |