RepoDataClient

RepoDataClient

Class representing an Origami Repo Data client.

Constructor

new RepoDataClient(optionsopt) → {RepoDataClient}

Create an Origami Repo Data client.
Source:
Parameters:
Name Type Attributes Description
options Object <optional>
The client options.
Name Type Attributes Description
apiKey String <optional>
The API key to use when making requests. Defaults to the value of the REPO_DATA_API_KEY environment variable.
apiSecret String <optional>
The API secret to use when making requests. Defaults to the value of the REPO_DATA_API_SECRET environment variable.
apiUrl String <optional>
The URL of the Origami Repo Data service. Defaults to the value of the REPO_DATA_API_URL environment variable or the production service.
Returns:
Type:
RepoDataClient
A new RepoDataClient instance.
Example

Create a client

const repoData = new RepoDataClient({
    apiKey: 'xxxXxXxX-XXXX-XXXX-xXXx-xxxXXXxXXXXX',
    apiSecret: 'xxXXXxxXXXXXXXXXxxxxxxxXXXxXxXXXXXXxxXXx'
});

Methods

createIngestion(data) → {Promise.<Object>}

Create a new ingestion and add it to the queue (requires write permissions).
Source:
See:
Parameters:
Name Type Description
data Object Information about the ingestion being created.
Name Type Description
url String The GitHub repository URL to ingest.
tag String The GitHub repository tag to ingest.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the new ingestion.
Example

Create an ingestion

const credentials = await repoData.createIngestion({
    url: 'https://github.com/Financial-Times/origami-repo-data',
    tag: '57.0.0'
});

createKey(data) → {Promise.<Object>}

Create a new API key which can be used to access the service (requires admin permissions).
Source:
See:
Parameters:
Name Type Description
data Object Information about the key being created.
Name Type Attributes Default Description
description String A short human-readable description of the API key.
read Boolean <optional>
true Whether the API key grants read permissions.
write Boolean <optional>
false Whether the API key grants write permissions.
admin Boolean <optional>
false Whether the API key grants admin permissions.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the new credentials. These will need to be stored somewhere, as the secret will never be displayed again.
Example

Create an API key

const credentials = await repoData.createKey({
    description: 'A write key for manually adding ingestions',
    read: true,
    write: true,
    admin: false
});

deleteIngestion(ingestionID) → {Promise.<Object>}

Delete a single ingestion from the queue by ID, preventing that repo/tag combination from being ingested (requires admin permissions).
Source:
See:
Parameters:
Name Type Description
ingestionID String The ingestion UUID.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves when the ingestion is deleted.
Example

Delete an ingestion

await repoData.deleteIngestion('799798e6-967d-492e-8fee-f7f35ec39d44');

deleteKey(keyId) → {Promise.<Object>}

Delete a single API key from the service by ID.
Source:
See:
Parameters:
Name Type Description
keyId String The key UUID.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves when the key is deleted.
Example

Delete an API key

await repoData.deleteKey('xxxXxXxX-XXXX-XXXX-xXXx-xxxXXXxXXXXX');

getIngestion(ingestionId) → {Promise.<Object>}

Get a single ingestion in the queue by ID.
Source:
See:
Parameters:
Name Type Description
ingestionId String The ingestion UUID.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the ingestion.
Example

Get an ingestion

const ingestion = await repoData.getIngestion('799798e6-967d-492e-8fee-f7f35ec39d44');

getKey(keyId) → {Promise.<Object>}

Get a single API key for the service by ID.
Source:
See:
Parameters:
Name Type Description
keyId String The key UUID.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the API key.
Example

Get an API key

const key = await repoData.getKey('xxxXxXxX-XXXX-XXXX-xXXx-xxxXXXxXXXXX');

getManifest(repoId, versionId, manifestType) → {Promise.<Object>}

Get a single manifest for an Origami repository and version by type.
Source:
See:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
manifestType String The type of manifest to retrieve. One of "about", "bower", "imageSet", "origami", or "package".
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the manifest file contents parsed as JSON.
Examples

Get a manifest using UUIDs

const packageManifest = await repoData.getManifest('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c', 'package');

Get a manifest using a name and number

const packageManifest = await repoData.getManifest('origami-repo-data', '57.0.0', 'package');

getMarkdown(repoId, versionId, markdownType) → {Promise.<String>}

Get a single markdown document for an Origami repository and version by type.
Source:
See:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
markdownType String The type of markdown document to retrieve. One of "designguidelines" or "readme".
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<String>
A promise which resolves with the markdown document as a string.
Examples

Get a markdown document using UUIDs

const readme = await repoData.getMarkdown('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c', 'readme');

Get a markdown document using a name and number

const readme = await repoData.getMarkdown('origami-repo-data', '57.0.0', 'readme');

getReadme(repoId, versionId) → {Promise.<String>}

Get the README text for an Origami repository and version. This is a shortcut method which uses RepoDataClient.getMarkdown.
Source:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<String>
A promise which resolves with the README as a string.
Examples

Get the README using UUIDs

const readme = await repoData.getReadme('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c');

Get the README using a name and number

const readme = await repoData.getReadme('origami-repo-data', '57.0.0');

getRepo(repoId) → {Promise.<Object>}

Get a single Origami repository by ID or name.
Source:
See:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the repository.
Examples

Get a repository using a UUID

const repo = await repoData.getRepo('c3a499f8-3d20-503c-95b0-c4705bc272b3');

Get a repository using a name

const repo = await repoData.getRepo('origami-repo-data');

getVersion(repoId, versionId) → {Promise.<Object>}

Get a single version for an Origami repository by ID or name.
Source:
See:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Object>
A promise which resolves with the version.
Examples

Get a repository version using UUIDs

const version = await repoData.getVersion('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c');

Get a repository version using a name and number

const version = await repoData.getVersion('origami-repo-data', '57.0.0');

listBrandedRepos(brand) → {Promise.<Array>}

Get a list of all branded Origami repositories as an array.
Deprecated:
Source:
See:
Parameters:
Name Type Description
brand String Brand to look for. One of: 'all', 'master', 'internal', 'whitelabel' or 'none'
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Array>
A promise which resolves with the repositories.
Example

List repositories based on brand

const repos = await repoData.listBrandedRepos('all');

listBundles(repoId, versionId, language, brand) → {Promise.<String>}

Get a list of bundle information for an Origami repository and version as an array.
Source:
See:
Parameters:
Name Type Default Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
language String The bundle language. One of "js" or "css".
brand String null [null] - A brand (or an array of brands) to filter bundles by. One of: 'master', 'internal', 'whitelabel'. Any non-branded bundles will not be included in the response. If this parameter is set to 'none' or null then only bundles which are not branded will be output. If this parameter is set to 'all' then only branded bundles will be output.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<String>
A promise which resolves with the bundles.
Example

Get all CSS bundle information.

	const bundles = await repoData.listBundles(
		'c3a499f8-3d20-503c-95b0-c4705bc272b3',
		'a530dab8-f6ff-410a-9e56-8d6f49ecff2c',
		'css'
	);

listDemos(repoId, versionId, brand) → {Promise.<String>}

Get a list of all demos for an Origami repository and version as an array.
Source:
See:
Parameters:
Name Type Default Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
brand String null [null] - The brand to filter demos by. If included, only demos with the specified brand (or no brands at all) will be returned.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<String>
A promise which resolves with the demos.
Examples

Get all demos

const demos = await repoData.listDemos('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c');

Get all demos with a brand filter

const demos = await repoData.listDemos('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c', 'internal');

listDependencies(repoId, versionId) → {Promise.<String>}

Get a list of all dependencies for an Origami repository and version as an array.
Source:
See:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<String>
A promise which resolves with the dependencies.
Example

Get all dependencies

const dependencies = await repoData.listDependencies('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c');

listImages(repoId, versionId, imageOptionsopt) → {Promise.<String>}

Get a list of all image set images for an Origami repository and version as an array.
Source:
See:
Parameters:
Name Type Attributes Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
versionId String The version UUID or number. Warning: using number over ID incurs a redirect.
imageOptions Object <optional>
Options which change the format of the returned images.
Name Type Attributes Description
sourceParam String <optional>
The Image Service source parameter to add to the returned image URLs. Defaults to "origami-repo-data-client-node".
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<String>
A promise which resolves with the images.
Example

Get all images in an image set

const images = await repoData.listImages('c3a499f8-3d20-503c-95b0-c4705bc272b3', 'a530dab8-f6ff-410a-9e56-8d6f49ecff2c');

listIngestions() → {Promise.<Array>}

Get a list of all current ingestions in the queue as an array.
Source:
See:
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Array>
A promise which resolves with the ingestion queue.
Example

List the ingestion queue

const ingestionQueue = await repoData.listIngestions();

listKeys() → {Promise.<Array>}

Get a list of all available API keys for the service as an array (requires admin permissions).
Source:
See:
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Array>
A promise which resolves with the API keys.
Example

List API keys

const repos = await repoData.listKeys();

listRepos(filtersopt) → {Promise.<Array>}

Get a list of all available Origami repositories as an array.
Source:
See:
Parameters:
Name Type Attributes Description
filters Object <optional>
Parameters to filter repositories by.
Name Type Attributes Description
brand Array.<String> | String | null <optional>
A brand (or an array of brands) to filter repositories by. One of: 'master', 'internal', 'whitelabel'. Any repository which doesn't include this brand will not be included in the response. If this parameter is set to 'none' or null then only repositories which are not branded will be output. If this parameter is set to 'all' then only repositories which have at least one brand will be output.
search String <optional>
free text to search repositories by. Searchable fields are name, description, keywords, and demo titles. Any repository which doesn't match the search string will not be included in the response.
status Array.<String> | String <optional>
An Origami component support status (or an array of statuses) to filter repositories by. One of: 'active', 'maintained', 'experimental', 'deprecated', 'dead'. Any repository which doesn't have this status will not be included in the response.
type Array.<String> | String <optional>
An Origami repo type (or an array of types) to filter repositories by. One of: 'module', 'service', 'imageset'. Any repository which doesn't have this type will not be included in the response.
origamiVersion Array.<String> | String <optional>
An Origami Version (or an array of Origami Versions) to filter repositories by. E.g: '1', '2.0'. Any repository which doesn't support this version of the Origami Specification will not be included in the response.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Array>
A promise which resolves with the repositories.
Examples

List repositories

const repos = await repoData.listRepos();

List repositories with filters

const repos = await repoData.listRepos({
    brand: 'master',
    search: 'color',
    status: 'active',
    type: 'module'
});

listVersions(repoId) → {Promise.<Array>}

Get a list of all versions for an Origami repository as an array.
Source:
See:
Parameters:
Name Type Description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.
Throws:
Will throw if a network error occurs, or if the API responds with a 40x/50x status.
Type
Error
Returns:
Type:
Promise.<Array>
A promise which resolves with the versions.
Examples

Get all repository versions using a UUID

const versions = await repoData.listVersions('c3a499f8-3d20-503c-95b0-c4705bc272b3');

Get all repository versions using a name

const versions = await repoData.listVersions('origami-repo-data');