Nutritious Polygonal Meatball
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

yaas-api-schema-v1

0.1.0 • Public • Published

YaasApiSchemaV1

TypeScript abstraction library for RAML-based REST API YaasApiSchemaV1.

Auto-generated using raml-typescript-generator.

Installation

npm install yaas-api-schema-v1 --save

Usage

TypeScript

import {YaasApiSchemaV1} from 'yaas-api-schema-v1';
...
constructor(..) {
  this.yaasApiSchemaV1 = new YaasApiSchemaV1({});
}

To support multiple versions of the API, it is recommended to alias the import so it can easily be mapped to a later API version - and, due to the nature of Typescript, you should be alerted on API signature changes already at compile time:

import {YaasApiSchemaV1 as YaasApiSchema} from 'yaas-api-schema-v1';

JS (Legacy)

API skeleton as it would be produced by MuleSoft's raml-javascript-generator JS generator is shipped for reference and to ease migrations:

var YaasApiSchemaV1 = require('yaas-api-schema-v1/leagcy.js')
 
var client = new YaasApiSchemaV1()

Options

You can set options when you initialize a client or at any time with the options property. You may also override options per request by passing an object as the last argument of request methods. For example:

client = new YaasApiSchemaV1({ ... })
 
client('GET', '/', {
  baseUri: 'https://api.eu.yaas.io/hybris/schema/anotherVersion',
  headers: {
    'Content-Type': 'application/json'
  }
})

For dynamic header injection - for example required for non-standard REST services asking for custom authentication token - a provider may be defined:

client = new YaasApiSchemaV1({
  getHeaders: ()=>{ return(this.myToken ? {Authorization: "Bearer " + this.myToken} : {}) }
});

Base URI

By default, endpoint as defined in RAML file https://api.eu.yaas.io/hybris/schema/v1 is used.

Note If supported by API provider, it is recommended to use one API version definition (i.e. RAML file and corresponding API TypeScript library) and switch endpoint based on the desired environment, for example test, qa or prod

You can override the base URI by setting the baseUri property, or initializing a client with a base URI. For example:

new YaasApiSchemaV1({
  baseUri: 'https://api.eu.yaas.io/hybris/schema/anotherVersion',
});

Methods

All methods return an Observable wrapping a Popsicle obtained response:

tenant({ tenant }).get([query, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)

Returns a list, that contains the IDs of the schemas, their tags and metadata. It can be limited by a query on tags or metadata. The 'q' query parameter enables you to specify the conditions. Two types of operators are supported for tags:

  • IN - Checks if a tag contains any of the provided values, such as branch:in(apparel, food)
  • ALL - The tag must contain all values from the condition, such as branch:all(sport, food)
    There is also possibility to filter schema by metadata. In this case the only operator is EQUAL. Values should be quoted!
    Security / Access Control:
    To access this method, an access token must be issued for the tenant with the hybris.schema_view scope to manage this resource.
client.tenant({ tenant }).get([query, [options]]).then(...)

tenant({ tenant }).delete([body, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)

Deletes all schemas for a given tenant.

Security / Access Control:
To access this method, an access token must be issued for the tenant with the hybris.schema_admin scope to manage this resource.

client.tenant({ tenant }).delete([body, [options]]).then(...)

tenant({ tenant }).schema({ schema }).get([query, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema Name of the schema stored for the given tenant. (type: string)

Gets the schema file.

Security / Access Control:
Does not require access token.

client.tenant({ tenant }).schema({ schema }).get([query, [options]]).then(...)

tenant({ tenant }).schema({ schema }).post([body, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema Name of the schema stored for the given tenant. (type: string)

Creates a new schema file.

Security / Access Control:
To access this method, access token must be issued for tenant and have hybris.schema_manage scope to manage this resource.

client.tenant({ tenant }).schema({ schema }).post([body, [options]]).then(...)

tenant({ tenant }).schema({ schema }).metadata.get([query, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema (type: string)

Returns the metadata of a given schema.

Security / Access Control:
To access this method, an access token must be issued for the tenant with the hybris.schema_view scope to manage this resource.

client.tenant({ tenant }).schema({ schema }).metadata.get([query, [options]]).then(...)

tenant({ tenant }).schema({ schema }).metadata.put([body, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema (type: string)

Updates metadata stored along with the schema by replacing it. The metadata format is simple key-value pairs. Both keys and values must be strings and keys cannot contain any special characters like "." or "$".

Security / Access Control:
To access this method, access token must be issued for tenant and have hybris.schema_manage scope to manage this resource.

client.tenant({ tenant }).schema({ schema }).metadata.put([body, [options]]).then(...)

tenant({ tenant }).schema({ schema }).tags.get([query, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema Name of the schema stored for the given tenant. (type: string)

Get a list of all tags with all distinct values for a particular schema.

Security / Access Control:
To access this method, an access token must be issued for the tenant with the hybris.schema_view scope to manage this resource.

client.tenant({ tenant }).schema({ schema }).tags.get([query, [options]]).then(...)

tenant({ tenant }).schema({ schema }).tags.tag({ tag }).post([body, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema Name of the schema stored for the given tenant. (type: string)
  • tag Name of the tag attribute to which tags will be added or removed from. (type: string)

Append several tags values to a schema. Tags are added only if they are not already added.

Security / Access Control:
To access this method, access token must be issued for tenant and have hybris.schema_manage scope to manage this resource.

client.tenant({ tenant }).schema({ schema }).tags.tag({ tag }).post([body, [options]]).then(...)

tenant({ tenant }).schema({ schema }).tags.tag({ tag }).delete([body, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • schema Name of the schema stored for the given tenant. (type: string)
  • tag Name of the tag attribute to which tags will be added or removed from. (type: string)

Removes tags from a schema.

Security / Access Control:
To access this method, access token must be issued for tenant and have hybris.schema_manage scope to manage this resource.

client.tenant({ tenant }).schema({ schema }).tags.tag({ tag }).delete([body, [options]]).then(...)

tenant({ tenant }).all.tagvalues.get([query, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)

Returns a list of all tags with their distinct values. The result is based on all tenant's schemas and it is eventually consistent, which means it may be outdated as aggregation does not run on every GET request.

Security / Access Control:
To access this method, access token must be issued for tenant and have hybris.schema_view scope to manage this resource.

client.tenant({ tenant }).all.tagvalues.get([query, [options]]).then(...)

tenant({ tenant }).all.tagvalues.tag({ tag }).get([query, [options]])

  • tenant The tenant string is the project's Identifier from the Builder. Must match the project that is associated with the access token in the Authorization header. (type: string)
  • tag Name of the tag attribute whose values will be aggregated. (type: string)

Return distinct values for the given tag from all schemas. The result is eventually consistent, which means it may be outdated because the aggregation does not run on every GET request.

Security / Access Control:
To access this method, an access token must be issued for the tenant with the hybris.schema_view scope to manage this resource.

client.tenant({ tenant }).all.tagvalues.tag({ tag }).get([query, [options]]).then(...)

License

Apache 2.0

install

npm i yaas-api-schema-v1

Downloadsweekly downloads

20

version

0.1.0

license

Apache-2.0

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability