@izara_frontend/remote-endpoint 1.0.3 → 1.0.4
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 +1 -1
- package/src/remoteEndpoint.js +7 -4
package/package.json
CHANGED
package/src/remoteEndpoint.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
* @param {string} objType.objectType - The object type identifier.
|
|
12
12
|
* @returns {object|null} Query endpoint object with name, type, and query configuration, or null if invalid.
|
|
13
13
|
*/
|
|
14
|
-
export function createGetEndpoint(objType) {
|
|
14
|
+
export function createGetEndpoint(objType, { customCacheKey = {} } = {}) {
|
|
15
15
|
if (!validateObjType(objType)) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
@@ -35,11 +35,13 @@ export function createGetEndpoint(objType) {
|
|
|
35
35
|
headers: headers
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
+
keepUnusedDataFor: 3600,
|
|
38
39
|
serializeQueryArgs: ({ queryArgs }) => {
|
|
39
40
|
return {
|
|
40
41
|
...queryArgs?.identifiers,
|
|
41
42
|
};
|
|
42
|
-
}
|
|
43
|
+
},
|
|
44
|
+
...customCacheKey
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
} else {
|
|
@@ -68,7 +70,7 @@ export function createQueryEndpoint(baseUrlLocations = [], endpointName, pathPar
|
|
|
68
70
|
name: `${endpointName}`,
|
|
69
71
|
type: "query",
|
|
70
72
|
query: {
|
|
71
|
-
query: ({ body, headers }) => ({
|
|
73
|
+
query: ({ body, headers = {} }) => ({
|
|
72
74
|
url: `https://${baseUrl}.execute-api.us-east-2.amazonaws.com/${pathParams}`,
|
|
73
75
|
method: method,
|
|
74
76
|
body: { ...body },
|
|
@@ -76,6 +78,7 @@ export function createQueryEndpoint(baseUrlLocations = [], endpointName, pathPar
|
|
|
76
78
|
...headers
|
|
77
79
|
}
|
|
78
80
|
}),
|
|
81
|
+
keepUnusedDataFor: 3600,
|
|
79
82
|
...customCacheKey
|
|
80
83
|
}
|
|
81
84
|
}
|
|
@@ -102,7 +105,7 @@ export function createMutationEndpoint(baseUrlLocations = [], endpointName, path
|
|
|
102
105
|
name: `${endpointName}`,
|
|
103
106
|
type: "mutation",
|
|
104
107
|
query: {
|
|
105
|
-
query: (body, headers = {}
|
|
108
|
+
query: ({ body, headers = {} }) => ({
|
|
106
109
|
url: `https://${baseUrl}.execute-api.us-east-2.amazonaws.com/${pathParams}`,
|
|
107
110
|
method: method,
|
|
108
111
|
body: { ...body },
|