Where capabilities are born. In this repository we build curated capabilities. Examples in this repository are ideal staring point for writing your own capability.
Superface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.
Through its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.
Superface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.
Motivation behind Superface is nicely described in this video from APIdays conference.
You can get more information at https://superface.ai and https://superface.ai/docs.
Install dependencies:
yarn install
# Validate capabilities are correctly linked and ahve all requirements
$ yarn capabilities:validate
# Run tests
$ yarn capabilities:test
# Record new trafic with live API calls
$ yarn capabilities:test:record capabilites/path/to/test.ts
Superface is not man-in-the-middle so it does not require any access to secrets that are needed to communicate with provider API. Superface CLI only prepares super.json file with authorization fields in form of environment variable. You just set correct variables and communicate directly with provider API.
You can find more information in OneSDK repository.
If you need any additional support, have any questions or you just want to talk you can do that through our documentation page.
If you are starting with Capabilities authoring check our guide.
Station repository has defined structure, here are commands for Superface CLI how to create profiles, maps and providers.
yarn superface create --profileId [scope](optional)/[name] --profile --profileFileName capabilities/[scope]/[name]/profile.supr
yarn superface create --providerName [provider_name] --provider --providerFileName providers/[provider_name].json
yarn superface create --profileId [scope](optional)/[name] --providerName [provider_name] --map --mapFileName capabilities/[scope]/[name]/maps/[provider_name].suma
We encourage to use Superface Testing to write tests.
1. Create test file
Alongside .suma
file create .test.ts
and use this template.
import { SuperfaceTest } from '@superfaceai/testing-lib';
describe(`scope/name/provider_name}`, () => {
let superface: SuperfaceTest;
beforeEach(() => {
superface = new SuperfaceTest();
});
describe('UseCase', () => {
it('should perform successfully', async () => {
await expect(
superface.run({
profile: 'scope/name',
provider: 'provider_name',
useCase: 'UseCase',
input: {
field1: '',
field2: '',
},
})
).resolves.toMatchSnapshot();
});
});
});
All inputs should be written directly to the test file and shouldn't use environment variables.
2. Do call against live API to record traffic and create snapshot
$ yarn capabilities:test:record capabilities/scope/name/maps/example.test.ts
3. Check result in snapshot
Snapshot for test run should be created in location:
capabilities/scope/name/maps/__snapshots__/example.test.ts.snap
4. Do post processing for traffic recording
We try to sanitize recordings and remove any sensitive data. But you should still look at the recording and make sure it doesn't contain in sensitive data such as credentials or personal information, that shouldn't be public.
5. Run tests with recorded traffic
$ yarn capabilities:test capabilities/scope/name/maps/example.test.ts
Secretes used for authentication during tests are stored in .env.capabilities
and loaded using dotenv. Run cp .env.capabilities.example .env.capabilities
to start from the template.
Station have Workflow to automate capabilities publishing. For details see CI / CD workflow.
Please open an issue first if you want to make larger changes
Feel free to contribute! Please follow the Contribution Guide.
Licenses of node_modules are checked during CI/CD for every commit. Only the following licenses are allowed:
- 0BDS
- MIT
- Apache-2.0
- ISC
- BSD-3-Clause
- BSD-2-Clause
- CC-BY-4.0
- CC-BY-3.0;BSD
- CC0-1.0
- Unlicense
- UNLICENSED
Note: If editing the README, please conform to the standard-readme specification.
The Superface is licensed under the MIT. © 2021 Superface