Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
@financial-times/biz-ops-schema
Advanced tools
Schema for biz-ops data store and api. It provides two things: - yaml files which define which types, properties and relationships are allowed - a nodejs library for extracting subsets of this information
Schema for biz-ops data store and api. It provides two things:
npm install @financial-times/biz-ops-schema
In production the component should be used in either 'poll' or 'stale' update modes, depending on the type of environment.
The component should be initialised once and once only per application. The component is a singleton, and once initialised, @financial-times/biz-ops-schema
can be required multiple times in the application, and will already be hydrated with schema data.
const { configure, startPolling } = require('@financial-times/biz-ops-schema');
configure({
baseUrl: process.env.SCHEMA_BASE_URL,
updateMode: 'poll',
logger: require('n-logger'), // or whichever logger you prefer
ttl: 10000, // in milliseconds, defaults to 60000
});
startPolling().then(() => {
// you can now start your app and use the schema
});
const { configure, refresh } = require('@financial-times/biz-ops-schema');
configure({
baseUrl: process.env.SCHEMA_BASE_URL,
updateMode: 'stale',
logger: require('n-lambda-logger'), // or whichever logger you prefer
ttl: 10000, // in milliseconds, defaults to 60000
});
// in your function handler
const handler = async event => {
await refresh();
// now go ahead
};
Speak to a member of the biz ops team to obtain a suitable value for SCHEMA_BASE_URL
.
When npm linking to test schema changes in an application, set updateMode: 'dev'
to retrieve schema files from the local yaml files and disable polling/refersh on stale.
See CONTRIBUTING.md
Create an appropriate semver tag:
Creating a github tag (1.) triggers a circleci build (2.) which, on success, publishes the schema files to s3 on the path /latest/vX.json
(where X is the major version) (3a.), and publishes the javascript library to NPM (3b.). biz-ops-api polls /latest/vX.json
(4.) and when an update is detected, it constructs and updated graphQL api, then publishes the schema file to /api/vX.json
(5.). biz-ops-admin and other secondary consumers of the data poll /api/vX.json
for updates to the schema (6.).
The reasoning behind this solution can be seen in this gist
All methods use an internal caching mechanism, whih is flushed whenever the schema updates. For this reason
Get an object defining the structure of a given type
. The following transforms will be executed on the raw yaml data.
pluralName
field is defined, it will be generatedThe full object structure returned by getType() can been seen here
withRelationships
[default: true
]: Include the relationships for the type, expressed as graphql property definitions.primitiveTypes
[default: 'biz-ops'
]: Graphql only has 4 primitive types - String, Boolean, Int and Float - whereas the biz-ops ecosystem recognises a richer variety e.g Document, Url. They are stored in the schema as these biz-ops types. Setting primitiveTypes: 'graphql'
will output property type names converted to their graphql equivalent. This option shouldn't really be needed by anywhere other than the graphql servergroupProperties
[default: false
]: Each property may have a fieldset
attribute. Setting groupProperties: true
removes the properties
object from the data, and replaces it with fieldsets
, where all properties are then grouped by fieldsetincludeMetaFields
[default: false
]: Determines whether to include metadatafields (prefixed with _
) in the schema object returnedGet an array of objects defining the structure of all types. All options
for getType
are supported and determine the internal structure of each type. Additionally, the following options can be specified:
grouped
[default: false
] - determines whether to return the types as a flat array, or an object grouping types in categories. Each category specifies a label, description and list of types.Retrieves an array of key:value objects defining the acceptable values of an enum
withMeta
: wrap the enum in an object which also has metadata about the enum (e.g. 'description'.). In this case, the actual enum options will be in a options
propertyValidates that a type of the given name exists in the schema
Validates that a code string matches the validation pattern defined for codes for the given type
Validates that a string is a valid name for an attribute (i.e. camelCase)
Validates that the value of a property for a given type is valid
Retrieves graphql defs to be used to power a graphql api
Should be used when reading a type name from e.g. a url. Currently is a noop, but will allow consistent rolling out of more forgiving url parsing in futre if necessary
The methods below are unimplemented
Decorates a graphql query with metadata from the schema
FAQs
Schema for biz-ops data store and api. It provides two things: - yaml files which define which types, properties and relationships are allowed - a nodejs library for extracting subsets of this information
The npm package @financial-times/biz-ops-schema receives a total of 9 weekly downloads. As such, @financial-times/biz-ops-schema popularity was classified as not popular.
We found that @financial-times/biz-ops-schema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 18 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.