rlz-engine 1.0.13 → 1.0.15

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.
@@ -6,4 +6,4 @@ export interface AuthParam {
6
6
  userId: string;
7
7
  tempPassword: string;
8
8
  }
9
- export declare function apiCall<T extends ZodType>(method: string, version: string, path: string, auth: AuthParam | null, queryString: Record<string, string> | null, request: object | null, validator: T): Promise<z.infer<T>>;
9
+ export declare function apiCall<T extends ZodType>(method: 'GET' | 'POST', version: string, path: string, auth: AuthParam | null, queryString: Record<string, string> | null, request: object | null, validator: T): Promise<z.infer<T>>;
@@ -7,15 +7,15 @@ export async function apiSignup(name, email, password) {
7
7
  email,
8
8
  password
9
9
  };
10
- return apiCall('v0', 'post', 'signup', null, null, req, API_AUTH_RESPONSE_SCHEMA_V0);
10
+ return apiCall('POST', 'v0', 'signup', null, null, req, API_AUTH_RESPONSE_SCHEMA_V0);
11
11
  }
12
12
  export async function apiSignin(name, password) {
13
13
  const req = {
14
14
  name,
15
15
  password
16
16
  };
17
- return apiCall('v0', 'post', 'signin', null, null, req, API_AUTH_RESPONSE_SCHEMA_V0);
17
+ return apiCall('POST', 'v0', 'signin', null, null, req, API_AUTH_RESPONSE_SCHEMA_V0);
18
18
  }
19
19
  export async function apiLogout(auth) {
20
- await apiCall('v0', 'post', 'logout', auth, null, null, z.undefined());
20
+ await apiCall('POST', 'v0', 'logout', auth, null, null, z.undefined());
21
21
  }
@@ -9,4 +9,5 @@ export declare class AuthState {
9
9
  login(id: string, name: string, email: string, tempPassword: string): void;
10
10
  get authParam(): AuthParam | null;
11
11
  }
12
+ export declare const AuthStateContext: import("react").Context<AuthState | null>;
12
13
  export declare function useAuthState(): AuthState;
@@ -1,4 +1,5 @@
1
1
  import { autorun, makeAutoObservable } from 'mobx';
2
+ import { createContext, useContext } from 'react';
2
3
  const AUTH_ID_KEY = 'AUTH_ID';
3
4
  const AUTH_NAME_KEY = 'AUTH_NAME';
4
5
  const AUTH_EMAIL_KEY = 'AUTH_EMAIL';
@@ -65,10 +66,12 @@ export class AuthState {
65
66
  };
66
67
  }
67
68
  }
68
- let state = null;
69
+ // eslint-disable-next-line @typescript-eslint/naming-convention
70
+ export const AuthStateContext = createContext(null);
69
71
  export function useAuthState() {
72
+ const state = useContext(AuthStateContext);
70
73
  if (state === null) {
71
- state = new AuthState();
74
+ throw Error('AuthState is not provided');
72
75
  }
73
76
  return state;
74
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlz-engine",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Deps and tools for my style of development",
5
5
  "scripts": {
6
6
  "build": "tsc",