@nizza/core 0.3.0-alpha.8 → 0.3.0-beta.0

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.
@@ -0,0 +1,13 @@
1
+ export interface ApiPagination {
2
+ limit: number;
3
+ cursor: ApiCursor;
4
+ }
5
+ export interface ApiCursor {
6
+ pk: string;
7
+ sk: string;
8
+ [key: string]: string;
9
+ }
10
+ export interface ApiListResult<T> {
11
+ cursor: ApiCursor | null;
12
+ items: T[];
13
+ }
@@ -1,12 +1,12 @@
1
1
  import { RouteProps } from 'react-router-dom';
2
2
  import { StoreClass } from './mobx-store';
3
- declare type Store<T extends {
3
+ type Store<T extends {
4
4
  new (): InstanceType<T>;
5
5
  }> = Readonly<{
6
6
  readonly class: T;
7
7
  readonly value: InstanceType<T>;
8
8
  }>;
9
- export declare type AppModuleStoreList = Store<any>[];
9
+ export type AppModuleStoreList = Store<any>[];
10
10
  export interface AppModule {
11
11
  key: string;
12
12
  label: string;
@@ -1,4 +1,5 @@
1
1
  import * as ApiGraphqlTypes from './api-graphql-types';
2
+ export * from './api';
2
3
  export * from './app-module';
3
4
  export * from './mobx-store';
4
5
  export * from './nizzaGlobalObject';
@@ -1,3 +1,3 @@
1
1
  import { Constructor } from './utils';
2
- export declare type StoreClass<T = any> = Constructor<T>;
3
- export declare type StoreFactory<T = any> = (...args: any[]) => T;
2
+ export type StoreClass<T = any> = Constructor<T>;
3
+ export type StoreFactory<T = any> = (...args: any[]) => T;
@@ -1,6 +1,6 @@
1
1
  import { NizzaProductRepository } from './products';
2
2
  export interface NizzaGlobalObjet {
3
- config: NizzaConfiguration;
3
+ config: NizzaConfiguration | null;
4
4
  configure: (config: NizzaConfiguration) => void;
5
5
  }
6
6
  export interface NizzaConfiguration {
@@ -1,10 +1,10 @@
1
1
  import { NizzaProduct } from './base';
2
- export declare type NizzaGetProductHandler = (input: NizzaGetProductHandlerInput) => Promise<NizzaProduct>;
3
- export declare type NizzaGetProductListHandler = (input: NizzaGetProductListHandlerInput) => Promise<NizzaProduct[]>;
4
- declare type NizzaGetProductHandlerInput = {
2
+ export type NizzaGetProductHandler = (input: NizzaGetProductHandlerInput) => Promise<NizzaProduct>;
3
+ export type NizzaGetProductListHandler = (input: NizzaGetProductListHandlerInput) => Promise<NizzaProduct[]>;
4
+ type NizzaGetProductHandlerInput = {
5
5
  productId: string;
6
6
  };
7
- declare type NizzaGetProductListHandlerInput = {
7
+ type NizzaGetProductListHandlerInput = {
8
8
  search?: string;
9
9
  page?: number;
10
10
  limit?: number;
@@ -1,5 +1,5 @@
1
1
  import environment from '../../environments/environment';
2
- export declare type Constructor<T = any> = new (...args: any[]) => T;
2
+ export type Constructor<T = any> = new (...args: any[]) => T;
3
3
  export interface ApiV1Response<T = any> {
4
4
  success: boolean;
5
5
  message: string;
@@ -12,12 +12,12 @@ export interface ApiV2Response<T = any> {
12
12
  duration: string;
13
13
  method: 'GET' | 'POST' | 'PUT' | 'DELETE';
14
14
  }
15
- export declare type Primitive = string | boolean | number;
15
+ export type Primitive = string | boolean | number;
16
16
  export interface ApiCall extends RequestInit {
17
17
  url: RequestInfo;
18
18
  raw?: boolean;
19
19
  }
20
- export declare type Environment<T> = typeof environment & T;
21
- export declare type RequiredKeys<T> = {
20
+ export type Environment<T> = typeof environment & T;
21
+ export type RequiredKeys<T> = {
22
22
  [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
23
23
  }[keyof T];
@@ -9,7 +9,7 @@ export declare class Result<V, E = string> {
9
9
  static fail<F = string>(error: F): Result<never, F>;
10
10
  static combine(results: Result<any, any>[]): Result<any, any>;
11
11
  }
12
- export declare type Either<L, A> = Err<L, A> | Ok<L, A>;
12
+ export type Either<L, A> = Err<L, A> | Ok<L, A>;
13
13
  export declare class Err<L, A> {
14
14
  readonly value: L;
15
15
  constructor(value: L);
@@ -1,4 +1,4 @@
1
- declare type StorageType = 'localStorage' | 'sessionStorage';
1
+ type StorageType = 'localStorage' | 'sessionStorage';
2
2
  export declare function isStorageAvailable(type: StorageType): boolean;
3
3
  export declare function setProperty(obj: unknown, name: string, value: unknown): void;
4
4
  export {};
@@ -1,6 +1,7 @@
1
+ export * from './Result';
1
2
  export * from './apiCall';
2
3
  export * from './customStorage';
3
4
  export * from './fingerprint';
4
5
  export * from './helpers';
5
6
  export * from './lazyLoad';
6
- export * from './Result';
7
+ export * from './mobxHooks';
@@ -2,6 +2,6 @@ import React, { ComponentProps, ReactNode } from 'react';
2
2
  interface Opts {
3
3
  fallback: ReactNode;
4
4
  }
5
- declare type Unpromisify<T> = T extends Promise<infer P> ? P : never;
6
- export declare const lazyLoad: <T extends Promise<any>, U extends React.ComponentType<any>>(importFunc: () => T, selectorFunc?: ((s: Unpromisify<T>) => U) | undefined, opts?: Opts) => (props: React.ComponentProps<U>) => JSX.Element;
5
+ type Unpromisify<T> = T extends Promise<infer P> ? P : never;
6
+ export declare const lazyLoad: <T extends Promise<any>, U extends React.ComponentType<any>>(importFunc: () => T, selectorFunc?: ((s: Unpromisify<T>) => U) | undefined, opts?: Opts) => (props: React.ComponentProps<U>) => import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -0,0 +1,24 @@
1
+ import { DependencyList, EffectCallback } from 'react';
2
+ /**
3
+ * This hook is just like the standard MobX autorun function, but it hooks into the React component
4
+ * lifecycle. This means the set up for the autorun only happens once, and it's automatically
5
+ * disposed of when the component unmounts.
6
+ *
7
+ * @param effect The function that's called when the store's properties are changed. This
8
+ * function is called initially when the autorun is initialized.
9
+ * @param deps The non-MobX dependencies that should retrigger the callback.
10
+ */
11
+ export declare function useAutorun(effect: EffectCallback, deps?: DependencyList): void;
12
+ export declare function useSelect<T>(trigger: () => T, deps?: DependencyList): T | undefined;
13
+ /**
14
+ * This hook is just like the standard MobX reaction function, but it hooks into the React component
15
+ * lifecycle. This means the set up for the reaction only happens once, and it's automatically
16
+ * disposed of when the component unmounts.
17
+ *
18
+ * @param trigger This function determines what data will trigger the effect function to rerun.
19
+ * Only the *accessed* data is important in this function—not the return value.
20
+ * @param effect The function that's called when the store's properties are changed. This
21
+ * function is called initially when the autorun is initialized.
22
+ * @param deps The non-MobX dependencies that should retrigger the callback.
23
+ */
24
+ export declare function useReaction(trigger: () => any, effect: EffectCallback, deps?: DependencyList): void;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/core",
3
- "version": "0.3.0-alpha.8",
3
+ "version": "0.3.0-beta.0",
4
4
  "type": "module",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.cjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/core",
3
- "version": "0.3.0-alpha.8",
3
+ "version": "0.3.0-beta.0",
4
4
  "type": "module",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.cjs",
File without changes