Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions clients/environments-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# @epilot/environments-client

## 0.4.2

### Patch Changes

- Upgrade openapi-client-axios to ^7.8.0 across all clients

## 0.4.1

### Patch Changes

- Mark access as public for all packages

## 0.4.0

### Minor Changes

- Minor version bump for all client packages
30 changes: 30 additions & 0 deletions clients/environments-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# @epilot/environments-client

[![CI](https://github.com/epilot-dev/sdk-js/workflows/CI/badge.svg)](https://github.com/epilot-dev/sdk-js/actions?query=workflow%3ACI)
[![npm version](https://img.shields.io/npm/v/@epilot/environments-client.svg)](https://www.npmjs.com/package/@epilot/environments-client-client)
[![bundle size](https://img.shields.io/bundlephobia/minzip/@epilot/environments-client?label=gzip%20bundle)](https://bundlephobia.com/package/@epilot/environments-client)
[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/epilot-dev/sdk-js/blob/main/LICENSE)

Client library for epilot [Environments API](https://docs.epilot.io/api/environments)
tbw

Uses [`openapi-client-axios`](https://github.com/openapistack/openapi-client-axios)

## Installation

```bash
npm install --save @epilot/environments-client
```

## Usage

```typescript
import { getClient } from '@epilot/environments-client';
const environmentsClient = getClient();

const logs = await environmentsClient.listEnvironmentVariables()
```

## API Docs:

https://docs.api.epilot.io
16 changes: 16 additions & 0 deletions clients/environments-client/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
testPathIgnorePatterns: ['node_modules'],
coveragePathIgnorePatterns: ['__tests__', 'node_modules'],
verbose: true,
silent: true,
moduleNameMapper: {
'^axios$': require.resolve('axios'),
},
};

export default config;
77 changes: 77 additions & 0 deletions clients/environments-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "@epilot/environments-client",
"version": "0.1.0",
"description": "JavaScript client library for the epilot Environments API",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "epilot GmbH",
"license": "MIT",
"private": false,
"repository": {
"type": "git",
"url": "git+https://github.com/epilot-dev/sdk-js.git",
"directory": "clients/environments-client"
},
"bugs": {
"url": "https://github.com/epilot-dev/sdk-js/issues"
},
"homepage": "https://github.com/epilot-dev/sdk-js/tree/main/clients/environments-client#readme",
"keywords": [
"epilot",
"sdk",
"environments"
],
"scripts": {
"test": "jest",
"typescript": "tsc",
"bundle-definition": "webpack",
"openapi": "node ../../scripts/update-openapi.js ../../../../gitlab/environments-api/openapi.yml",
"typegen": "openapi typegen src/openapi.json --client -b '/* eslint-disable */' > src/openapi.d.ts",
"build": "tsc && npm run build:patch && npm run bundle-definition",
"build:patch": "sed -i'' -e '/^__exportStar.*openapi.*$/d' dist/index.js",
"build:watch": "npm run build && tsc -w",
"release-alpha": "npm version prerelease --preid alpha",
"prepublishOnly": "npm run typegen && npm run build",
"lint": "pnpm exec eslint src"
},
"files": [
"*.js",
"*.d.ts",
"**/*.json",
"**/*.js",
"**/*.d.ts",
"!*.test.*",
"!**/*.test.*",
"!node_modules",
"!src",
"!src/**",
"!*.config.js"
],
"peerDependencies": {
"axios": "^1.0.0 || >=0.25.0 <1.0.0"
},
"dependencies": {
"@dazn/lambda-powertools-correlation-ids": "^1.28.1",
"buffer": "^6.0.3",
"https-browserify": "^1.0.0",
"openapi-client-axios": "^7.8.0",
"stream-http": "^3.1.1",
"url": "^0.11.0",
"util": "^0.12.3"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"axios": "^1.11.0",
"copy-webpack-plugin": "^7.0.0",
"jest": "^29.6.2",
"json-loader": "^0.5.7",
"openapicmd": "^2.7.0",
"ts-jest": "^29.4.1",
"ts-loader": "^8.0.14",
"ts-node": "^10.9.1",
"typescript": "^4.1.3",
"webpack": "^5.18.0",
"webpack-cli": "^4.4.0"
},
"gitHead": "39426e86cfb320fa3227dc03f60ee6a10848e7c7"
}
25 changes: 25 additions & 0 deletions clients/environments-client/src/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { getClient } from './client';

describe('client', () => {
describe('getClient', () => {
it('should inititalise and return client', async () => {
const client = getClient();

expect(client.api.initialized).toBe(true);
});

it('should have operations', async () => {
const client = getClient();

const operations = client.api.getOperations();

expect(operations.length).toBeGreaterThan(0);
});

it('should have a default server defined', async () => {
const client = getClient();

expect(client.defaults.baseURL).toBeDefined();
});
});
});
26 changes: 26 additions & 0 deletions clients/environments-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import CorrelationIds from '@dazn/lambda-powertools-correlation-ids';
import OpenAPIClientAxios from 'openapi-client-axios';

import definition from './definition';
import { Client } from './openapi';

let client: Client;
export const getClient = () => {
if (!client) {
client = createClient();
}

return client;
};

export const createClient = () => {
const api = new OpenAPIClientAxios({ definition, quick: true });
const apiClient = api.initSync<Client>();

apiClient.defaults.headers.common = {
...(apiClient.defaults.headers.common ?? {}),
...(CorrelationIds.get() || {}),
};

return apiClient;
};
5 changes: 5 additions & 0 deletions clients/environments-client/src/definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { Document } from 'openapi-client-axios';

import definition from './openapi-runtime.json';

export default definition as unknown as Document;
4 changes: 4 additions & 0 deletions clients/environments-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './client';
export * from './openapi';

export type { OpenAPIClient, OpenAPIClientAxios, Document } from 'openapi-client-axios';
55 changes: 55 additions & 0 deletions clients/environments-client/src/openapi-runtime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"openapi": "3.0.3",
"info": {
"title": "",
"version": ""
},
"paths": {
"/v1/environments": {
"get": {
"operationId": "listEnvironmentVariables",
"responses": {}
},
"post": {
"operationId": "createEnvironmentVariable",
"requestBody": {
"required": true,
"content": {
"application/json": {}
}
},
"responses": {}
}
},
"/v1/environments/{key}": {
"parameters": [
{
"name": "key",
"in": "path",
"required": true,
"description": "Environment variable key"
}
],
"get": {
"operationId": "getEnvironmentVariable",
"responses": {}
},
"put": {
"operationId": "updateEnvironmentVariable",
"requestBody": {
"required": true,
"content": {
"application/json": {}
}
},
"responses": {}
},
"delete": {
"operationId": "deleteEnvironmentVariable",
"responses": {}
}
}
},
"components": {},
"servers": []
}
Loading
Loading