new RepoDataClient(...)

Class representing an Origami Repo Data client.

Create an Origami Repo Data client.

parameter type default description
options (optional) Object The client options.
options.apiKey (optional) String The API key to use when making requests. Defaults to the value of the <code>REPO_DATA_API_KEY</code> environment variable.
options.apiSecret (optional) String The API secret to use when making requests. Defaults to the value of the <code>REPO_DATA_API_SECRET</code> environment variable.
options.apiUrl (optional) String The URL of the Origami Repo Data service. Defaults to the value of the <code>REPO_DATA_API_URL</code> environment variable or the production service.

Methods

  • listRepos - (instance) Get a list of all available Origami repositories as an array.
  • getRepo(repoId) - (instance) Get a single Origami repository by ID or name.
  • listVersions(repoId) - (instance) Get a list of all versions for an Origami repository as an array.
  • getVersion(repoId, versionId) - (instance) Get a single version for an Origami repository by ID or name.
  • getManifest(...) - (instance) Get a single manifest for an Origami repository and version by type.
  • getMarkdown(...) - (instance) Get a single markdown document for an Origami repository and version by type.
  • getReadme(repoId, versionId) - (instance) Get the README text for an Origami repository and version. This is a shortcut method which uses [RepoDataClient.getMarkdown](#RepoDataClient.getMarkdown).
  • listDemos(...) - (instance) Get a list of all demos for an Origami repository and version as an array.
  • listImages(...) - (instance) Get a list of all image set images for an Origami repository and version as an array.
  • listDependencies(repoId, versionId) - (instance) Get a list of all dependencies for an Origami repository and version as an array.
  • createKey(...) - (instance) Create a new API key which can be used to access the service (requires admin permissions).
  • listKeys - (instance) Get a list of all available API keys for the service as an array (requires admin permissions).
  • getKey(keyId) - (instance) Get a single API key for the service by ID.
  • deleteKey(keyId) - (instance) Delete a single API key from the service by ID.
  • createIngestion(...) - (instance) Create a new ingestion and add it to the queue (requires write permissions).
  • listIngestions - (instance) Get a list of all current ingestions in the queue as an array.
  • getIngestion(ingestionId) - (instance) Get a single ingestion in the queue by ID.
  • deleteIngestion(ingestionID) - (instance) Delete a single ingestion from the queue by ID, preventing that repo/tag combination from being ingested (requires admin permissions).

Example

Create a client

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

Links

RepoDataClient#listRepos

Instance Method

Get a list of all available Origami repositories as an array.

Returns

  • Promise.<Array> - A promise which resolves with the repositories.

Example

List repositories

const repos = await repoData.listRepos();

Links

RepoDataClient#getRepo(repoId)

Instance Method

Get a single Origami repository by ID or name.

parameter type default description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.

Returns

  • Promise.<Object> - A promise which resolves with the repository.

Examples

Example #1

Get a repository using a UUID

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

Example #2

Get a repository using a name

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

Links

RepoDataClient#listVersions(repoId)

Instance Method

Get a list of all versions for an Origami repository as an array.

parameter type default description
repoId String The repository UUID or name. Warning: using name over ID incurs a redirect.

Returns

  • Promise.<Array> - A promise which resolves with the versions.

Examples

Example #1

Get all repository versions using a UUID

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

Example #2

Get all repository versions using a name

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

Links

RepoDataClient#getVersion(repoId, versionId)

Instance Method

Get a single version for an Origami repository by ID or name.

parameter 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.

Returns

  • Promise.<Object> - A promise which resolves with the version.

Examples

Example #1

Get a repository version using UUIDs

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

Example #2

Get a repository version using a name and number

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

Links

RepoDataClient#getManifest(...)

Instance Method

Get a single manifest for an Origami repository and version by type.

parameter 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.
manifestType String The type of manifest to retrieve. One of "about", "bower", "imageSet", "origami", or "package".

Returns

  • Promise.<Object> - A promise which resolves with the manifest file contents parsed as JSON.

Examples

Example #1

Get a manifest using UUIDs

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

Example #2

Get a manifest using a name and number

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

Links

RepoDataClient#getMarkdown(...)

Instance Method

Get a single markdown document for an Origami repository and version by type.

parameter 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.
markdownType String The type of markdown document to retrieve. One of "designguidelines" or "readme".

Returns

  • Promise.<String> - A promise which resolves with the markdown document as a string.

Examples

Example #1

Get a markdown document using UUIDs

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

Example #2

Get a markdown document using a name and number

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

Links

RepoDataClient#getReadme(repoId, versionId)

Instance Method

Get the README text for an Origami repository and version. This is a shortcut method which uses RepoDataClient.getMarkdown.

parameter 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.

Returns

  • Promise.<String> - A promise which resolves with the README as a string.

Examples

Example #1

Get the README using UUIDs

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

Example #2

Get the README using a name and number

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

Links

RepoDataClient#listDemos(...)

Instance Method

Get a list of all demos for an Origami repository and version as an array.

parameter 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 (optional) String The brand to filter demos by. If included, only demos with the specified brand (or no brands at all) will be returned.

Returns

  • Promise.<String> - A promise which resolves with the demos.

Examples

Example #1

Get all demos

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

Example #2

Get all demos with a brand filter

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

Links

RepoDataClient#listImages(...)

Instance Method

Get a list of all image set images for an Origami repository and version as an array.

parameter 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.
imageOptions (optional) Object Options which change the format of the returned images.
imageOptions.sourceParam (optional) String The Image Service source parameter to add to the returned image URLs. Defaults to "origami-repo-data-client-node".

Returns

  • 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');

Links

RepoDataClient#listDependencies(repoId, versionId)

Instance Method

Get a list of all dependencies for an Origami repository and version as an array.

parameter 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.

Returns

  • 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');

Links

RepoDataClient#createKey(...)

Instance Method

Create a new API key which can be used to access the service (requires admin permissions).

parameter type default description
data Object Information about the key being created.
data.description String A short human-readable description of the API key.
data.read (optional) Boolean true Whether the API key grants read permissions.
data.write (optional) Boolean false Whether the API key grants write permissions.
data.admin (optional) Boolean false Whether the API key grants admin permissions.

Returns

  • 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
});

Links

RepoDataClient#listKeys

Instance Method

Get a list of all available API keys for the service as an array (requires admin permissions).

Returns

  • Promise.<Array> - A promise which resolves with the API keys.

Example

List API keys

const repos = await repoData.listKeys();

Links

RepoDataClient#getKey(keyId)

Instance Method

Get a single API key for the service by ID.

parameter type default description
keyId String The key UUID.

Returns

  • 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');

Links

RepoDataClient#deleteKey(keyId)

Instance Method

Delete a single API key from the service by ID.

parameter type default description
keyId String The key UUID.

Returns

  • Promise.<Object> - A promise which resolves when the key is deleted.

Example

Delete an API key

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

Links

RepoDataClient#createIngestion(...)

Instance Method

Create a new ingestion and add it to the queue (requires write permissions).

parameter type default description
data Object Information about the ingestion being created.
data.url String The GitHub repository URL to ingest.
data.tag String The GitHub repository tag to ingest.

Returns

  • 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'
});

Links

RepoDataClient#listIngestions

Instance Method

Get a list of all current ingestions in the queue as an array.

Returns

  • Promise.<Array> - A promise which resolves with the ingestion queue.

Example

List the ingestion queue

const ingestionQueue = await repoData.listIngestions();

Links

RepoDataClient#getIngestion(ingestionId)

Instance Method

Get a single ingestion in the queue by ID.

parameter type default description
ingestionId String The ingestion UUID.

Returns

  • Promise.<Object> - A promise which resolves with the ingestion.

Example

Get an ingestion

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

Links

RepoDataClient#deleteIngestion(ingestionID)

Instance Method

Delete a single ingestion from the queue by ID, preventing that repo/tag combination from being ingested (requires admin permissions).

parameter type default description
ingestionID String The ingestion UUID.

Returns

  • Promise.<Object> - A promise which resolves when the ingestion is deleted.

Example

Delete an ingestion

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

Links