@carbonorm/carbonreact 3.0.5 → 3.0.7

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": "@carbonorm/carbonreact",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -5,7 +5,7 @@ import {KeysMatching} from "./KeysMatching";
5
5
 
6
6
  //ObjectType, UniqueIdType extends keyof ObjectType
7
7
  // @link https://www.typescriptlang.org/docs/handbook/2/mapped-types.html
8
- export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = {}, P = {}>
8
+ export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = typeof CarbonReact.instance.state, P = typeof CarbonReact.instance.props>
9
9
  (dataOrCallback: ObjectType[] | (<K extends keyof S>(
10
10
  state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
11
11
  callback?: () => void
@@ -0,0 +1,34 @@
1
+ import {AxiosResponse} from "axios";
2
+
3
+
4
+ export default function setCookies(cookies: string[], req: AxiosResponse | undefined = undefined): void {
5
+
6
+ console.log("Setting cookies", cookies);
7
+
8
+ cookies.map(cookie => {
9
+
10
+ const newCookie = cookie
11
+ .replace("HttpOnly", "")
12
+ .replace("secure", "");
13
+
14
+ if (document === undefined || document === null) {
15
+
16
+ const getStackTrace = function () {
17
+ let obj: any = {};
18
+ Error.captureStackTrace(obj, getStackTrace);
19
+ return obj.stack;
20
+ };
21
+
22
+ console.error(req)
23
+
24
+ console.log('Testing error, document not defined', req)
25
+
26
+ throw new Error("Document is undefined while trying to set cookie: (" + newCookie + ") in axiosInterceptors.tsx after (" + JSON.stringify([req?.config, req?.data], undefined, 4) + ") Please make sure all requests are wrapped in an act() from import {act} from '@testing-library/react'; (" + JSON.stringify(getStackTrace(), undefined, 4) + ")");
27
+
28
+ }
29
+
30
+ document.cookie = newCookie
31
+
32
+ });
33
+
34
+ }
@@ -19,7 +19,7 @@ export enum eUpdateInsertMethod {
19
19
  * @param callback - if you want to do something with the updated state, you can pass a callback here. Run as the second
20
20
  * parameter of setState.
21
21
  */
22
- export default function updateRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = {}, P = {}>
22
+ export default function updateRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = typeof CarbonReact.instance.state, P = typeof CarbonReact.instance.props>
23
23
  (dataOrCallback: ObjectType[] | (<K extends keyof S>(
24
24
  state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
25
25
  callback?: () => void
package/src/index.ts CHANGED
@@ -37,6 +37,8 @@ export * from "./hoc/isEdgeBrowser";
37
37
  export * from "./hoc/parseMultipleJson";
38
38
  export { default as scrollIntoView } from "./hoc/scrollIntoView";
39
39
  export * from "./hoc/scrollIntoView";
40
+ export { default as setCookies } from "./hoc/setCookies";
41
+ export * from "./hoc/setCookies";
40
42
  export { default as setUrl } from "./hoc/setUrl";
41
43
  export * from "./hoc/setUrl";
42
44
  export { default as updateRestfulObjectArrays } from "./hoc/updateRestfulObjectArrays";