@hmxlabs/dax-client 1.0.6

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/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # DAX Client
2
+
3
+ Client API used to call the DAX Server from a React web application. To work correctly you need to have the following in place:
4
+
5
+ - Your tentant ID must be specified in the following environment variable: REACT_APP_TENANT_ID
6
+ - A reverse proxy which detects calls to '/dax-api' and redirects the calls the correct DAX server. It should also remove '/dax-api' from the url.
7
+
8
+ Most of the client code is automatically generated from the DAX Server API swagger page by running the following script:
9
+
10
+ `npm run generate-dax-api`
11
+
12
+ The files are output to '/src/services/generated/'.
13
+
14
+ `dax-api-service.ts` is a wrapper around the generated code to automatically specify the tenant Id and improve the request/response data types of the various calls.
15
+
16
+ **Note: This is a work in progress so only some of the routes have wrappers in dax-api-service.ts**
17
+
18
+ For routes which don't have a wrapper method implemented yet, you can call the route directly via the `daxApi`. For example:
19
+ ```
20
+ import { daxApi, ListingDetailFindAllResponse } from "dax-client";
21
+
22
+ const getListings = (listingType: string, listingStatus: string): Promise<ListingDetailFindAllResponse[]> => {
23
+ return daxApi.listingDetailFindAllByTenantId<ListingDetailFindAllResponse[]>(myTenantId, {listingType, listingStatus});
24
+ }
25
+ ```
26
+
27
+ ## Available Scripts
28
+
29
+ In the project directory, you can run:
30
+
31
+ ### `npm run build`
32
+
33
+ Generate the npm package to the `build` folder.
34
+
35
+ ### `npm run generate-dax-api`
36
+
37
+ Regenerate the client api code from the dax server api swagger page. It requires the dax server api to be running locally to work.
38
+
39
+ ## Using the DAX Client
40
+
41
+ If you check out this repo then you can use the client directly. Assuming your directory structure is something like:
42
+
43
+ - dax-client
44
+ - react-web-app
45
+
46
+ In dax-client, run:
47
+
48
+ `npm run build`
49
+
50
+ In react-web-app, run:
51
+
52
+ `npm i --save ../dax-client`
53
+
54
+ Then you can access the wrapper methods and models from `dax-client`. For example:
55
+
56
+ `import { listingDetailById, listingDetailFindAll, ListingDetailFindAllResponse, ListingDetailGetByIdResponse } from "dax-client";`
@@ -0,0 +1,8 @@
1
+ import { daxApi, listingDetailFindAll, listingDetailById, listingStatusCountFindAll } from "./services/dax-api-service";
2
+ import { ListingDetailFindAllNameValue, ListingDetailFindAllAttachment, ListingDetailFindAllResponse } from "./services/models/ListingDetailFindAllResponse";
3
+ import { ListingDetailGetByIdNameValue, ListingDetailGetByIdAttachment, ListingDetailGetByIdResponse } from "./services/models/ListingDetailGetByIdResponse";
4
+ import { ListingStatusCountFindAllResponse } from "./services/models/ListingStatusCountFindAllResponse";
5
+ export { daxApi, listingDetailFindAll, listingDetailById, listingStatusCountFindAll };
6
+ export { ListingDetailFindAllNameValue, ListingDetailFindAllAttachment, ListingDetailFindAllResponse };
7
+ export { ListingDetailGetByIdNameValue, ListingDetailGetByIdAttachment, ListingDetailGetByIdResponse };
8
+ export { ListingStatusCountFindAllResponse };