@carbonorm/carbonreact 1.3.1 → 2.0.1

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.
@@ -8,38 +8,34 @@ import {ToastContainer} from 'react-toastify';
8
8
  import 'react-toastify/dist/ReactToastify.min.css';
9
9
  import BackendThrowable from 'components/Errors/BackendThrowable';
10
10
  import Nest from 'components/Nest/Nest';
11
- import {iCarbons} from "variables/C6";
11
+ import {initialRestfulObjectsState, iRestfulObjectArrayTypes} from "variables/C6";
12
12
 
13
13
 
14
- export type tStatefulApiData<T> = T[] | undefined | null;
15
-
16
-
17
- // this refers to the value types of the keys above, aka values in the state
18
- export interface iRestfulObjectArrayTypes {
19
- carbons: tStatefulApiData<iCarbons>,
20
- }
21
-
22
- export type tRestfulObjectArrayKeys = keyof iRestfulObjectArrayTypes
23
-
24
- export type tRestfulObjectArrayValues = iRestfulObjectArrayTypes[tRestfulObjectArrayKeys];
25
-
26
- // @ts-ignore
27
- export type tRestfulObjectValues = tRestfulObjectArrayValues[number];
28
14
 
29
15
  // our central container, single page application is best with the DigApi
30
- export interface iCarbonORMState extends iRestfulObjectArrayTypes {
16
+ export interface iCarbonORMState {
17
+ alertsWaiting: any[],
31
18
  websocketEvents: MessageEvent[],
32
19
  websocketData: any[],
33
20
  websocket?: WebSocket,
34
- websocketMounted: boolean,
35
- alert?: boolean,
36
- alertsWaiting: any[],
37
21
  backendThrowable: any[],
38
22
  }
39
23
 
24
+ export const initialRequiredCarbonORMState: iCarbonORMState = {
25
+ alertsWaiting: [],
26
+ backendThrowable: [],
27
+ websocketData: [],
28
+ websocketEvents: [],
29
+ }
30
+
31
+ export const initialCarbonORMState: iCarbonORMState = {
32
+ ...initialRequiredCarbonORMState,
33
+ ...initialRestfulObjectsState,
34
+ }
35
+
40
36
  export default class CarbonReact<P = {}, S = {}> extends React.Component<{
41
37
  children?: ReactNode | ReactNode[],
42
- } & P, iCarbonORMState & S> {
38
+ } & P, ( iRestfulObjectArrayTypes |& S ) & iCarbonORMState> {
43
39
 
44
40
  static instance: CarbonReact;
45
41
 
@@ -53,14 +49,7 @@ export default class CarbonReact<P = {}, S = {}> extends React.Component<{
53
49
 
54
50
  super(props);
55
51
 
56
- this.state = {
57
- carbons: undefined,
58
- alertsWaiting: [],
59
- backendThrowable: [],
60
- websocketData: [],
61
- websocketEvents: [],
62
- websocketMounted: false,
63
- } as unknown as iCarbonORMState & S;
52
+ this.state = initialCarbonORMState as unknown as iCarbonORMState & S;
64
53
 
65
54
  CarbonReact.instance = this;
66
55
 
@@ -271,7 +271,7 @@ function axiosInterceptors(axios: AxiosInstance): void {
271
271
 
272
272
  if (isTest) {
273
273
 
274
- throw new Error(error?.response.data['CarbonPHP\\Error\\PublicAlert'] ?? error?.response.data['DropInGaming\\PHP\\Errors\\DropException'] ?? JSON.stringify(error?.response.data, undefined, 4))
274
+ throw new Error(error?.response.data['CarbonPHP\\Error\\PublicAlert'] ?? error?.response.data['TRACE'] ?? JSON.stringify(error?.response.data, undefined, 4))
275
275
 
276
276
  }
277
277
 
@@ -1,18 +1,20 @@
1
- import CarbonReact, {iCarbonORMState, iRestfulObjectArrayTypes, tRestfulObjectValues} from "CarbonReact";
1
+ import CarbonReact, {iCarbonORMState} from "CarbonReact";
2
+ import {iRestfulObjectArrayTypes, tRestfulObjectValues} from "variables/C6";
2
3
 
3
4
 
4
5
  //ObjectType, UniqueIdType extends keyof ObjectType
5
- export default function deleteRestfulObjectArrays<ObjectType extends tRestfulObjectValues>
6
+ export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectValues, ObjectArrayTypes = iRestfulObjectArrayTypes>
6
7
  (dataOrCallback: ((prev: Readonly<iCarbonORMState>) => ObjectType[]) | ObjectType[],
7
- stateKey: keyof iRestfulObjectArrayTypes,
8
+ stateKey: keyof ObjectArrayTypes,
8
9
  uniqueObjectId: keyof ObjectType,
9
10
  callback?: () => void): void {
10
11
 
11
- return CarbonReact.instance.setState((previousBootstrapState): {} => {
12
+ return CarbonReact.instance.setState((previousBootstrapState ): {} => {
12
13
 
13
14
  let newOrReplacementData: ObjectType[] = dataOrCallback instanceof Function ? dataOrCallback(previousBootstrapState) : dataOrCallback;
14
15
 
15
- const previousStateProperty = previousBootstrapState[stateKey] as ObjectType[];
16
+ // @ts-ignore
17
+ const previousStateProperty = previousBootstrapState[stateKey];
16
18
 
17
19
  return {
18
20
  [stateKey]: null === previousBootstrapState ? null : [
@@ -1,6 +1,6 @@
1
1
  import classNames from "classnames";
2
2
  import BootstrapStyle from "variables/bootstrap.module.css"
3
- import DropInGamingStyles from "style.module.css"
3
+ import Styles from "style.module.css"
4
4
 
5
5
  export const getRootStyleValue = (property = '--dig_primary_color') : string => {
6
6
 
@@ -27,13 +27,13 @@ function mergeStyles<iStyleA extends iStyle, iStyleB extends iStyle>(styleA : iS
27
27
 
28
28
  }
29
29
 
30
- const dropStyles = mergeStyles(BootstrapStyle, DropInGamingStyles);
30
+ const dropStyles = mergeStyles(BootstrapStyle, Styles);
31
31
 
32
32
  type tBootstrap = typeof BootstrapStyle
33
33
 
34
- type tDropInGaming = typeof DropInGamingStyles
34
+ type tStyles = typeof Styles
35
35
 
36
- export default function getStyles<iCSS extends {}>(overrides: iCSS = {} as iCSS): tBootstrap & tDropInGaming & iCSS {
36
+ export default function getStyles<iCSS extends {}>(overrides: iCSS = {} as iCSS): tBootstrap & tStyles & iCSS {
37
37
 
38
38
  if (0 === Object.keys(overrides).length) {
39
39
  return dropStyles as (typeof dropStyles) & iCSS
@@ -5,7 +5,7 @@ export default function setUrl() {
5
5
 
6
6
  const isGitHubActions = process.env.REACT_APP_TEST_REMOTE === 'true'
7
7
 
8
- const host = ( isGitHubActions ? process.env.REACT_APP_REMOTE_SUBDOMAIN : process.env.REACT_APP_LOCAL_SUBDOMAIN ) + '.dropingaming.com' + (isGitHubActions ? '' : ':8080')
8
+ const host = ( isGitHubActions ? process.env.REACT_APP_REMOTE_SUBDOMAIN : process.env.REACT_APP_LOCAL_SUBDOMAIN ) + '.example.com' + (isGitHubActions ? '' : ':8080')
9
9
 
10
10
  console.log("test host:: ", host, isGitHubActions)
11
11
 
@@ -1,8 +1,7 @@
1
1
  import CarbonReact, {
2
- iCarbonORMState,
3
- iRestfulObjectArrayTypes,
4
- tRestfulObjectValues
2
+ iCarbonORMState
5
3
  } from "CarbonReact";
4
+ import {iRestfulObjectArrayTypes, tRestfulObjectValues} from "variables/C6";
6
5
 
7
6
 
8
7
  export enum eUpdateInsertMethod {
@@ -21,9 +20,9 @@ export enum eUpdateInsertMethod {
21
20
  * @param callback - if you want to do something with the updated state, you can pass a callback here. Run as the second
22
21
  * parameter of setState.
23
22
  */
24
- export default function updateRestfulObjectArray<ObjectType extends tRestfulObjectValues>
23
+ export default function updateRestfulObjectArray<ObjectType = tRestfulObjectValues, ObjectArrayTypes = iRestfulObjectArrayTypes>
25
24
  (dataOrCallback: ((prev: Readonly<iCarbonORMState>) => ObjectType[]) | ObjectType[],
26
- stateKey: keyof iRestfulObjectArrayTypes,
25
+ stateKey: keyof ObjectArrayTypes,
27
26
  uniqueObjectId: keyof ObjectType,
28
27
  insertUpdateOrder: eUpdateInsertMethod = eUpdateInsertMethod.LAST,
29
28
  callback?: () => void): void {
@@ -34,7 +33,8 @@ export default function updateRestfulObjectArray<ObjectType extends tRestfulObje
34
33
 
35
34
  let newOrReplacementData: ObjectType[] = dataOrCallback instanceof Function ? dataOrCallback(previousBootstrapState) : dataOrCallback;
36
35
 
37
- const previousStateProperty = previousBootstrapState[stateKey] as ObjectType[];
36
+ // @ts-ignore
37
+ const previousStateProperty = previousBootstrapState[stateKey];
38
38
 
39
39
  let updatedData = newOrReplacementData.map(value => {
40
40
  return {
package/src/index.ts CHANGED
@@ -12,8 +12,6 @@ export { default as BackendThrowable } from "./components/Errors/BackendThrowabl
12
12
  export * from "./components/Errors/BackendThrowable";
13
13
  export { default as ErrorHttpCode } from "./components/Errors/ErrorHttpCode";
14
14
  export * from "./components/Errors/ErrorHttpCode";
15
- export { default as Localhost } from "./components/Errors/Localhost";
16
- export * from "./components/Errors/Localhost";
17
15
  export { default as PageNotFound } from "./components/Errors/PageNotFound";
18
16
  export * from "./components/Errors/PageNotFound";
19
17
  export { default as Loading } from "./components/Loading/Loading";