@epilot/entity-client 4.22.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epilot/entity-client",
3
- "version": "4.22.0",
3
+ "version": "4.23.0",
4
4
  "description": "JavaScript client library for the epilot Core Entity API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,25 @@
1
+ import { getClient } from './client';
2
+
3
+ describe('client', () => {
4
+ describe('getClient', () => {
5
+ it('should inititalise and return client', async () => {
6
+ const client = getClient();
7
+
8
+ expect(client.api.initialized).toBe(true);
9
+ });
10
+
11
+ it('should have operations', async () => {
12
+ const client = getClient();
13
+
14
+ const operations = client.api.getOperations();
15
+
16
+ expect(operations.length).toBeGreaterThan(0);
17
+ });
18
+
19
+ it('should have a default server defined', async () => {
20
+ const client = getClient();
21
+
22
+ expect(client.defaults.baseURL).toBeDefined();
23
+ });
24
+ });
25
+ });
package/src/client.ts ADDED
@@ -0,0 +1,26 @@
1
+ import CorrelationIds from '@dazn/lambda-powertools-correlation-ids';
2
+ import OpenAPIClientAxios from 'openapi-client-axios';
3
+
4
+ import definition from './definition';
5
+ import { Client } from './openapi';
6
+
7
+ let client: Client;
8
+ export const getClient = () => {
9
+ if (!client) {
10
+ client = createClient();
11
+ }
12
+
13
+ return client;
14
+ };
15
+
16
+ export const createClient = () => {
17
+ const api = new OpenAPIClientAxios({ definition, quick: true });
18
+ const apiClient = api.initSync<Client>();
19
+
20
+ apiClient.defaults.headers.common = {
21
+ ...(apiClient.defaults.headers.common ?? {}),
22
+ ...(CorrelationIds.get() || {}),
23
+ };
24
+
25
+ return apiClient;
26
+ };
@@ -0,0 +1,5 @@
1
+ import type { Document } from 'openapi-client-axios';
2
+
3
+ import definition from './openapi-runtime.json';
4
+
5
+ export default (definition as unknown) as Document;
@@ -881,6 +881,80 @@
881
881
  }
882
882
  ]
883
883
  }
884
+ },
885
+ "/v1/entity/schemas/attributes/{composite_id}": {
886
+ "get": {
887
+ "operationId": "getSchemaAttribute",
888
+ "parameters": [
889
+ {
890
+ "name": "composite_id",
891
+ "in": "path",
892
+ "required": true
893
+ }
894
+ ]
895
+ },
896
+ "put": {
897
+ "operationId": "putSchemaAttribute",
898
+ "parameters": [
899
+ {
900
+ "name": "composite_id",
901
+ "in": "path",
902
+ "required": true
903
+ }
904
+ ],
905
+ "requestBody": {
906
+ "content": {
907
+ "application/json": {}
908
+ }
909
+ }
910
+ },
911
+ "delete": {
912
+ "operationId": "deleteSchemaAttribute",
913
+ "parameters": [
914
+ {
915
+ "name": "composite_id",
916
+ "in": "path",
917
+ "required": true
918
+ }
919
+ ]
920
+ }
921
+ },
922
+ "/v1/entity/schemas/capabilities/{composite_id}": {
923
+ "get": {
924
+ "operationId": "getSchemaCapability",
925
+ "parameters": [
926
+ {
927
+ "name": "composite_id",
928
+ "in": "path",
929
+ "required": true
930
+ }
931
+ ]
932
+ },
933
+ "put": {
934
+ "operationId": "putSchemaCapability",
935
+ "parameters": [
936
+ {
937
+ "name": "composite_id",
938
+ "in": "path",
939
+ "required": true
940
+ }
941
+ ],
942
+ "requestBody": {
943
+ "content": {
944
+ "application/json": {}
945
+ }
946
+ }
947
+ },
948
+ "delete": {
949
+ "operationId": "deleteSchemaCapability",
950
+ "parameters": [
951
+ {
952
+ "name": "composite_id",
953
+ "in": "path",
954
+ "required": true
955
+ }
956
+ ]
957
+ }
884
958
  }
885
959
  },
886
960
  "components": {