@react-pakistan/util-functions 1.25.7 → 1.25.8

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.
@@ -13,6 +13,17 @@ export interface FetchConfig extends Omit<RequestInit, 'credentials'> {
13
13
  * (e.g. 'omit' | 'same-origin' | 'include').
14
14
  */
15
15
  credentials?: boolean | RequestCredentials;
16
+ /**
17
+ * Query parameters to append to GET requests.
18
+ * Supports strings, numbers, booleans, arrays, and objects.
19
+ * - Primitives (string, number, boolean) are converted to strings
20
+ * - Arrays are repeated as multiple params with the same key
21
+ * - Objects are JSON-stringified
22
+ * - null and undefined values are skipped
23
+ *
24
+ * Example: { active: true, page: 1, tags: ['a', 'b'] }
25
+ * Results in: ?active=true&page=1&tags=a&tags=b
26
+ */
16
27
  params?: Record<string, any>;
17
28
  }
18
29
  export interface Return {
@@ -19,12 +19,18 @@
19
19
  * using a short timeout (default 300ms) to avoid unnecessary list reloads.
20
20
  *
21
21
  * Parameters (object)
22
- * - `byIdCallback(data)`, `byIdDeps`, `byIdParams`
23
- * - `deleteCallback(data)`, `deleteDeps`, `deleteParams`
24
- * - `listCallback(data)`, `listDeps`, `listParams`, `listUrl`
22
+ * - `byIdCallback(data)`, `byIdDeps`, `byIdParams` — params for GET by ID request
23
+ * - `deleteCallback(data)`, `deleteDeps`, `deleteParams` — body for DELETE request
24
+ * - `listCallback(data)`, `listDeps`, `listParams`, `listUrl` — params for GET list
25
25
  * - `searchQuery` (string) — debounced before influencing the list fetch
26
26
  * - `unitByIdUrl`, `unitUrl`
27
- * - `updateCallback(data)`, `updateDeps`, `updateParams`
27
+ * - `updateCallback(data)`, `updateDeps`, `updateParams` — body for PUT request
28
+ *
29
+ * Parameter types
30
+ * - `listParams` and `byIdParams` support all primitive types including booleans.
31
+ * They are appended as URL query parameters for GET requests.
32
+ * Example: { active: true, page: 1 } → ?active=true&page=1
33
+ * - `updateParams` and `deleteParams` are sent as JSON in request body.
28
34
  *
29
35
  * Return values
30
36
  * - `byIdFetchNow(url?, config?)`, `byIdLoading`, `byIdError`
@@ -44,7 +50,7 @@
44
50
  * Example
45
51
  * const { listFetchNow, updateFetchNow } = useModuleEntityV2({
46
52
  * listUrl: '/items',
47
- * listParams: { page: 1 },
53
+ * listParams: { page: 1, active: true },
48
54
  * listCallback: (res) => console.log(res),
49
55
  * unitUrl: '/items',
50
56
  * updateCallback: () => {},
@@ -20,12 +20,18 @@
20
20
  * using a short timeout (default 300ms) to avoid unnecessary list reloads.
21
21
  *
22
22
  * Parameters (object)
23
- * - `byIdCallback(data)`, `byIdDeps`, `byIdParams`
24
- * - `deleteCallback(data)`, `deleteDeps`, `deleteParams`
25
- * - `listCallback(data)`, `listDeps`, `listParams`, `listUrl`
23
+ * - `byIdCallback(data)`, `byIdDeps`, `byIdParams` — params for GET by ID request
24
+ * - `deleteCallback(data)`, `deleteDeps`, `deleteParams` — body for DELETE request
25
+ * - `listCallback(data)`, `listDeps`, `listParams`, `listUrl` — params for GET list
26
26
  * - `searchQuery` (string) — debounced before influencing the list fetch
27
27
  * - `unitByIdUrl`, `unitUrl`
28
- * - `updateCallback(data)`, `updateDeps`, `updateParams`
28
+ * - `updateCallback(data)`, `updateDeps`, `updateParams` — body for PUT request
29
+ *
30
+ * Parameter types
31
+ * - `listParams` and `byIdParams` support all primitive types including booleans.
32
+ * They are appended as URL query parameters for GET requests.
33
+ * Example: { active: true, page: 1 } → ?active=true&page=1
34
+ * - `updateParams` and `deleteParams` are sent as JSON in request body.
29
35
  *
30
36
  * Return values
31
37
  * - `byIdFetchNow(url?, config?)`, `byIdLoading`, `byIdError`
@@ -45,7 +51,7 @@
45
51
  * Example
46
52
  * const { listFetchNow, updateFetchNow } = useModuleEntityV2({
47
53
  * listUrl: '/items',
48
- * listParams: { page: 1 },
54
+ * listParams: { page: 1, active: true },
49
55
  * listCallback: (res) => console.log(res),
50
56
  * unitUrl: '/items',
51
57
  * updateCallback: () => {},
@@ -94,7 +100,7 @@ var useModuleEntityV2 = function (_a) {
94
100
  try {
95
101
  // pass current list params explicitly so the fetch uses the latest values
96
102
  listFetchNow(undefined, {
97
- method: constants_1.API_METHODS.POST,
103
+ method: constants_1.API_METHODS.GET,
98
104
  params: listParams,
99
105
  });
100
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.25.7",
3
+ "version": "1.25.8",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {