@epilot/entity-client 4.21.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.21.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;
@@ -646,6 +646,26 @@
646
646
  "in": "query",
647
647
  "name": "slug",
648
648
  "required": false
649
+ },
650
+ {
651
+ "in": "query",
652
+ "name": "sort",
653
+ "required": false
654
+ },
655
+ {
656
+ "in": "query",
657
+ "name": "from",
658
+ "required": false
659
+ },
660
+ {
661
+ "in": "query",
662
+ "name": "size",
663
+ "required": false
664
+ },
665
+ {
666
+ "in": "query",
667
+ "name": "fields",
668
+ "required": false
649
669
  }
650
670
  ]
651
671
  }
@@ -785,7 +805,11 @@
785
805
  "operationId": "taxonomiesClassificationsSearch",
786
806
  "parameters": [
787
807
  {
788
- "$ref": "#/components/parameters/TaxonomySlugQueryParam"
808
+ "$ref": "#/components/parameters/TaxonomySlugQueryParamOptional"
809
+ },
810
+ {
811
+ "in": "query",
812
+ "name": "query"
789
813
  }
790
814
  ],
791
815
  "requestBody": {
@@ -810,18 +834,7 @@
810
834
  }
811
835
  }
812
836
  },
813
- "/v2/entity/taxonomies/{taxonomySlug}/classifications/{classificationSlug}": {
814
- "get": {
815
- "operationId": "getTaxonomyClassification",
816
- "parameters": [
817
- {
818
- "$ref": "#/components/parameters/TaxonomySlugPathParam"
819
- },
820
- {
821
- "$ref": "#/components/parameters/TaxonomyClassificationSlugPathParam"
822
- }
823
- ]
824
- },
837
+ "/v2/entity/taxonomies/{taxonomySlug}/classifications": {
825
838
  "post": {
826
839
  "operationId": "createTaxonomyClassification",
827
840
  "parameters": [
@@ -833,41 +846,24 @@
833
846
  "content": {
834
847
  "application/json": {}
835
848
  }
836
- },
837
- "response": {
838
- "201": {
839
- "description": "Taxonomy classification created",
840
- "content": {
841
- "application/json": {}
842
- }
843
- },
844
- "409": {
845
- "description": "Taxonomy classification already exists\""
846
- }
847
849
  }
848
- },
850
+ }
851
+ },
852
+ "/v2/entity/taxonomies/{taxonomySlug}/classifications/{classificationSlug}": {
849
853
  "put": {
850
854
  "operationId": "updateTaxonomyClassification",
851
855
  "parameters": [
852
856
  {
853
857
  "$ref": "#/components/parameters/TaxonomySlugPathParam"
858
+ },
859
+ {
860
+ "$ref": "#/components/parameters/TaxonomyClassificationSlugPathParam"
854
861
  }
855
862
  ],
856
863
  "requestBody": {
857
864
  "content": {
858
865
  "application/json": {}
859
866
  }
860
- },
861
- "response": {
862
- "200": {
863
- "description": "Taxonomy classification updated",
864
- "content": {
865
- "application/json": {}
866
- }
867
- },
868
- "404": {
869
- "description": "Taxonomy classification not found"
870
- }
871
867
  }
872
868
  },
873
869
  "delete": {
@@ -877,20 +873,87 @@
877
873
  "$ref": "#/components/parameters/TaxonomySlugPathParam"
878
874
  },
879
875
  {
880
- "in": "path",
881
- "name": "classificationId",
882
- "required": true
876
+ "$ref": "#/components/parameters/TaxonomyClassificationSlugPathParam"
883
877
  },
884
878
  {
885
879
  "in": "query",
886
880
  "name": "permanent"
887
881
  }
882
+ ]
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
+ }
888
941
  ],
889
- "response": {
890
- "204": {
891
- "description": "Taxonomy classification deleted"
942
+ "requestBody": {
943
+ "content": {
944
+ "application/json": {}
892
945
  }
893
946
  }
947
+ },
948
+ "delete": {
949
+ "operationId": "deleteSchemaCapability",
950
+ "parameters": [
951
+ {
952
+ "name": "composite_id",
953
+ "in": "path",
954
+ "required": true
955
+ }
956
+ ]
894
957
  }
895
958
  }
896
959
  },
@@ -911,18 +974,17 @@
911
974
  "in": "path",
912
975
  "required": true
913
976
  },
914
- "TaxonomySlugQueryParam": {
915
- "name": "taxonomySlug",
916
- "in": "query",
917
- "required": true
918
- },
919
977
  "TaxonomySlugPathParam": {
920
978
  "name": "taxonomySlug",
921
979
  "in": "path",
922
980
  "required": true
923
981
  },
982
+ "TaxonomySlugQueryParamOptional": {
983
+ "name": "taxonomySlug",
984
+ "in": "query"
985
+ },
924
986
  "TaxonomyClassificationSlugPathParam": {
925
- "name": "taxonomyClassificationSlug",
987
+ "name": "classificationSlug",
926
988
  "in": "path",
927
989
  "required": true
928
990
  },