vineanova-redux-artifacts 1.119.22 → 1.119.24

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +1 -1
  3. package/readme.md +156 -0
package/CHANGELOG.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### 1.119.22 (2024-02-01)
5
+ ### 1.119.24 (2024-02-01)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vineanova-redux-artifacts",
3
- "version": "1.119.22",
3
+ "version": "1.119.24",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "browser": "lib/index.js",
package/readme.md ADDED
@@ -0,0 +1,156 @@
1
+ # VineaOpenApiReduxArtifacts
2
+
3
+ ## Overview
4
+
5
+ VineaOpenApiReduxArtifacts is a powerful npm library designed to simplify the integration of Swagger APIs into Redux architecture. By leveraging templates (Mustache files), this library automatically generates Redux ducks, actions, sagas, selectors, and API clients, eliminating the need for repetitive boilerplate code for each API request. This streamlined approach enhances code readability and accelerates development for New Zealand's vineyard and livestock industries.
6
+
7
+ ## Example Usage
8
+
9
+ ### Generated Ducks Actions
10
+
11
+ ```javascript
12
+ const ducksActions = createActions({
13
+ api: {
14
+ v1: {
15
+ cropBlockVintage: {
16
+ get: {
17
+ // ... (generated actions for GET request)
18
+ },
19
+ post: {
20
+ // ... (generated actions for POST request)
21
+ },
22
+ put: {
23
+ // ... (generated actions for PUT request)
24
+ },
25
+ delete: {
26
+ // ... (generated actions for DELETE request)
27
+ },
28
+ },
29
+ },
30
+ },
31
+ });
32
+ ```
33
+
34
+ ### Generated Saga
35
+
36
+ ```javascript
37
+ export function* getCropBlockVintageSagas(action) {
38
+ const {
39
+ payload = {},
40
+ meta: { reducerName },
41
+ } = action;
42
+ try {
43
+ yield put({
44
+ type: "FETCHING",
45
+ name: reducerName,
46
+ });
47
+
48
+ const response = yield call(APIServices.getCropBlockVintage, payload);
49
+ yield put({
50
+ type: "SUCCESS",
51
+ payload: response,
52
+ name: reducerName,
53
+ });
54
+
55
+ const CropBlockVintageSchema = new schema.Entity("byId");
56
+ const CropBlockVintageListSchema = new schema.Array(CropBlockVintageSchema);
57
+ const {entities: {byId}, result: allIds} = normalize(response, CropBlockVintageListSchema);
58
+ yield put({
59
+ type: "MERGE_ALL_IDS",
60
+ payload: {byId, allIds},
61
+ name: reducerName,
62
+ });
63
+
64
+ } catch (err) {
65
+ logger.error(err);
66
+ /* istanbul ignore next */
67
+ yield put({
68
+ type: "ERROR",
69
+ payload: err,
70
+ name: reducerName,
71
+ });
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### Usage in Application
77
+
78
+ ```javascript
79
+ import {
80
+ VineaNovaActions,
81
+ VineaNovaSelectors,
82
+ } from 'vineanova-redux-artifacts';
83
+
84
+ dispatchAPI(
85
+ VineaNovaActions.api.v1.cropBlockVintage.get.request({
86
+ queryParams: {
87
+ VineyardBlockID: cbvData.vineyardBlockId,
88
+ VintageID: cbvData.vintageId,
89
+ },
90
+ }),
91
+ );
92
+ ```
93
+
94
+ ### Example Selector
95
+
96
+ ```javascript
97
+ import {
98
+ VineaNovaActions,
99
+ VineaNovaSelectors,
100
+ } from 'vineanova-redux-artifacts';
101
+
102
+ const cropBlockVintageEntityData = useSelector(
103
+ VineaNovaSelectors.getCropBlockVintageEntityData,
104
+ );
105
+ ```
106
+
107
+ ### Example API Client
108
+
109
+ ```javascript
110
+ export const getCropBlockVintage = async (payload) => {
111
+ try {
112
+ const { queryParams, postBody, options } = payload || {};
113
+ let apiUrl = '/CropBlockVintage';
114
+ const response = await serviceConfig.request({
115
+ url: apiUrl,
116
+ method: 'get',
117
+ params: {
118
+ ...queryParams,
119
+ },
120
+ headers: {
121
+ 'Content-Type': 'application/json',
122
+ Accept: 'application/json',
123
+ },
124
+ ...options,
125
+ });
126
+ return response;
127
+ } catch (err) {
128
+ logger.error(err);
129
+ throw err;
130
+ }
131
+ };
132
+ ```
133
+ ## Environment Variables
134
+
135
+ Ensure the following environment variables are set for proper library functionality:
136
+
137
+ - `SWAGGER_URL`: The base URL for the Swagger API.
138
+ - `CODE`: A code parameter for authenticating the Swagger API.
139
+
140
+
141
+ ## Installation
142
+
143
+ To install VineaOpenApiReduxArtifacts, simply run:
144
+
145
+ ```bash
146
+ npm install vineanova-redux-artifacts
147
+ ```
148
+
149
+ ## Get Started
150
+
151
+ There is no documentation , but download the generated code, navigate thru the generated code. These are simple functions and easy to navigate through.
152
+
153
+ To learn more about integrating this library into your project.Feel free to reach out to our support team at [support@vineanova.com](mailto:support@vineanova.com) for any assistance or inquiries.
154
+
155
+ Happy coding!
156
+