@jsonui/core 0.4.4 → 0.6.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.
@@ -9,5 +9,5 @@ import stockFunctions from './stock/functions';
9
9
  import persistConfig from './store/persistConfig';
10
10
  import storeReducers from './store/reducers';
11
11
  import appRootFunctions from './stock/appRootFunctions';
12
- export * from './utils/types';
12
+ export type * from './utils/types';
13
13
  export { Stock, I18n, wrapperUtil, util, constants, StockContext, PathModifierContext, appRootFunctions, compSelectorHook, stockFunctions, persistConfig, storeReducers, };
@@ -1,8 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { JsonUIFunctions, JsonUIFunctionType } from './appRootFunctions';
3
- interface JsonUIComponentsType {
4
- [key: string]: ReactNode;
5
- }
2
+ import { JsonUIComponentsType, JsonUIFunctions, JsonUIFunctionType } from 'utils/types';
6
3
  interface NewStockType {
7
4
  components: JsonUIComponentsType;
8
5
  functions: JsonUIFunctions;
@@ -1,7 +1,4 @@
1
- export declare type JsonUIFunctionType = (attr: any, props: any, callerArgs: any, stock: any) => Promise<void> | void | any;
2
- export interface JsonUIFunctions {
3
- [key: string]: JsonUIFunctionType;
4
- }
1
+ import { JsonUIFunctions, JsonUIFunctionType } from 'utils/types';
5
2
  export declare const deletePersistDataStore: JsonUIFunctionType;
6
3
  declare const appRootFunctions: JsonUIFunctions;
7
4
  export default appRootFunctions;
@@ -1,7 +1,7 @@
1
- import { JsonUIFunctionType } from './appRootFunctions';
1
+ import { JsonUIFunctionType } from '../utils/types';
2
2
  declare const _default: {
3
- getStateValue: JsonUIFunctionType;
4
3
  get: JsonUIFunctionType;
5
4
  set: JsonUIFunctionType;
5
+ jsonata: JsonUIFunctionType;
6
6
  };
7
7
  export default _default;
@@ -1,7 +1,11 @@
1
1
  import { ErrorObject } from 'ajv';
2
- export declare const errorConverter: (errors: ErrorObject<string, Record<string, any>, unknown>[] | null | undefined) => {};
3
- export declare const validateJSON: (schema: any, store: string, data: any) => {
2
+ export declare const errorConverter: (errors: ErrorObject<string, Record<string, any>, unknown>[] | null | undefined) => any;
3
+ export declare const validateJSON: (schema: any, data: any) => {
4
+ valid: boolean;
5
+ error: any;
6
+ };
7
+ export declare const validateJSONAndStore: (schema: any, store: string, data: any) => {
4
8
  store: string;
5
9
  valid: boolean;
6
- value: {} | null;
10
+ value: any;
7
11
  };
@@ -1,7 +1,7 @@
1
- import { PathModifiersType, PropsType, ReduxPathType } from '../../utils/types';
1
+ import { PathModifiersType, ReduxPath, ReduxPathTypeEnum } from '../../utils/types';
2
2
  import { RootStateType } from './reducer';
3
3
  export declare const getState: (state: any) => RootStateType;
4
4
  export declare const getValue: (state: any, store: string, path: string) => any;
5
- export declare const getStateValue: (globalState: any, { store, path, isError }: ReduxPathType, currentPaths: PathModifiersType) => any;
6
- export declare const genAllStateProps: (globalState: any, props: PropsType) => PropsType;
7
- export declare const compSelectorHook: (currentPaths: PathModifiersType, subscriberPaths: ReduxPathType[]) => (state: any) => any[] | undefined;
5
+ export declare const getStoreNameFromType: (store: string, type?: ReduxPathTypeEnum | undefined) => string;
6
+ export declare const getStateValue: (globalState: any, { store, path, type, jsonataDef }: ReduxPath, currentPaths: PathModifiersType) => any;
7
+ export declare const compSelectorHook: (currentPaths: PathModifiersType, subscriberPaths: ReduxPath[]) => (state: any) => any[] | undefined;
@@ -1,5 +1,6 @@
1
1
  export declare const SEPARATOR = "/";
2
2
  export declare const STORE_ERROR_POSTFIX = ".error";
3
+ export declare const STORE_TOUCH_POSTFIX = ".touch";
3
4
  export declare const PATH_MODIFIERS_KEY = "$pathModifiers";
4
5
  export declare const MODIFIER_KEY = "$modifier";
5
6
  export declare const ACTION_KEY = "$action";
@@ -27,6 +28,7 @@ export declare const REDUX_PATHS = "$$reduxPaths";
27
28
  export declare const V_CHILDREN_PREFIX = "$child";
28
29
  export declare const PARENT_PROP_NAME = "__parentprop";
29
30
  export declare const CURRENT_PATH_NAME = "__currentPaths";
31
+ export declare const REDUX_GET_SUBSCRIBERS_NAME = "__subscriberPaths";
30
32
  export declare const UNDEFINED_COMP_NAME = "_Undefined";
31
33
  export declare const PRIMITIVE_COMP_NAME = "_PrimitiveProp";
32
34
  export declare const FRAGMENT_COMP_NAME = "Fragment";
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import * as c from 'utils/constants';
3
3
  export declare type UIDefinition = any;
4
4
  export declare type Path = string;
@@ -25,8 +25,21 @@ export interface ValidationType {
25
25
  path: string;
26
26
  schema: any;
27
27
  }
28
- export interface ReduxPathType {
28
+ export declare enum ReduxPathTypeEnum {
29
+ ERROR = "ERROR",
30
+ TOUCH = "TOUCH",
31
+ NORMAL = "NORMAL"
32
+ }
33
+ export interface ReduxPath {
29
34
  store?: string;
30
35
  path?: string;
31
- isError?: boolean;
36
+ type?: ReduxPathTypeEnum;
37
+ jsonataDef?: string;
38
+ }
39
+ export interface JsonUIComponentsType {
40
+ [key: string]: ReactNode;
41
+ }
42
+ export declare type JsonUIFunctionType = (attr: any, props: any, callerArgs: any, stock: any) => Promise<void> | void | any;
43
+ export interface JsonUIFunctions {
44
+ [key: string]: JsonUIFunctionType;
32
45
  }
@@ -1,6 +1,7 @@
1
1
  export declare const findLastIndex: (arr: any[], func: any) => number;
2
2
  export declare const drop: (arr: any[], n?: number) => any[];
3
3
  export declare const isNumber: (a: any) => boolean;
4
+ export declare const jsonPointerFix: (path?: string | undefined) => string;
4
5
  export declare const jsonPointerGet: (json: any, path?: string | undefined) => any;
5
6
  export declare const jsonPointerSet: (json: any, path?: string | undefined, value?: any) => any;
6
7
  export declare const pathArrayToPathString: (array: (string | number)[]) => string;
@@ -15,5 +16,7 @@ export declare const changeRelativePath: (path: string) => string;
15
16
  */
16
17
  export declare function mergeDeep(target: any, ...sources: any): any;
17
18
  export declare const collectObjMerge: (refConst: string, json: any) => {};
18
- export declare const collectObjToArray: (refConst: string, json: any) => any[];
19
- export declare const isCircular: (d: any) => boolean;
19
+ export declare const collectObjToArray: (refConst: string, json: any, flatten?: boolean) => any[];
20
+ export declare const isValidJson: (d: any) => boolean;
21
+ export declare const isPrimitiveValue: (value: any, emptyStringAllowed?: boolean) => boolean;
22
+ export declare const hasLeaf: (obj: any, emptyStringAllowed?: boolean) => boolean;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import * as c from '../utils/constants';
3
3
  import Stock from '../stock/Stock';
4
- import { PathModifiersType, PropsType, ReduxPathType, WrapperType } from '../utils/types';
4
+ import { PathModifiersType, PropsType, ReduxPath, WrapperType } from '../utils/types';
5
5
  interface OwnTraverse {
6
6
  key: string;
7
7
  value: PropsType;
@@ -11,13 +11,10 @@ interface OwnTraverse {
11
11
  }
12
12
  export declare const getFilteredPath: ({ [c.PARENT_PROP_NAME]: parentComp, ...propsNew }: PropsType, func: (filterProps: OwnTraverse) => boolean) => OwnTraverse[];
13
13
  export declare const actionBuilder: (props: PropsType, stock: InstanceType<typeof Stock>) => void;
14
- export declare const calculatePropsFromModifier: (props: PropsType, stock: InstanceType<typeof Stock>) => ReduxPathType[];
14
+ export declare const calculatePropsFromModifier: (props: PropsType, stock: InstanceType<typeof Stock>) => ReduxPath[];
15
15
  export declare const getCurrentPaths: (props: PropsType, pathModifier: PathModifiersType) => PathModifiersType;
16
16
  export declare const normalisePrimitives: (props: PropsType, parentComp?: any) => any;
17
- export declare const getRootWrapperProps: (props: PropsType, stock: InstanceType<typeof Stock>) => {
18
- [x: string]: import("../utils/types").PropValue;
19
- $pathModifiers?: PathModifiersType | undefined;
20
- };
17
+ export declare const getRootWrapperProps: (props: PropsType, stock: InstanceType<typeof Stock>) => void;
21
18
  export declare const isChildrenProp: (propName?: string | undefined) => boolean;
22
19
  export declare const getParentProps: (props: PropsType) => PropsType;
23
20
  export declare const getPropsChildrenFilter: ({ props, filter }: {
package/dist/index.d.ts CHANGED
@@ -3,26 +3,18 @@
3
3
  /// <reference types="redux-persist" />
4
4
  import * as react from 'react';
5
5
  import react__default, { ReactNode } from 'react';
6
+ import { JsonUIComponentsType as JsonUIComponentsType$1, JsonUIFunctions as JsonUIFunctions$1, JsonUIFunctionType as JsonUIFunctionType$1 } from 'utils/types';
6
7
  import * as c from 'utils/constants';
7
8
  import Stock$1 from 'stock/Stock';
8
9
  import * as redux_persist from 'redux-persist';
9
10
  import * as redux from 'redux';
10
11
 
11
- declare type JsonUIFunctionType = (attr: any, props: any, callerArgs: any, stock: any) => Promise<void> | void | any;
12
- interface JsonUIFunctions {
13
- [key: string]: JsonUIFunctionType;
14
- }
15
- declare const appRootFunctions: JsonUIFunctions;
16
-
17
- interface JsonUIComponentsType {
18
- [key: string]: ReactNode;
19
- }
20
12
  interface NewStockType {
21
- components: JsonUIComponentsType;
22
- functions: JsonUIFunctions;
13
+ components: JsonUIComponentsType$1;
14
+ functions: JsonUIFunctions$1;
23
15
  }
24
16
  declare type InitType = (prop: NewStockType) => void;
25
- declare type RegisterFunctionType = (key: string, value: JsonUIFunctionType) => void;
17
+ declare type RegisterFunctionType = (key: string, value: JsonUIFunctionType$1) => void;
26
18
  declare type RegisterComponentType = (key: string, value: ReactNode) => void;
27
19
  declare type CallFunctionType = (name: string, attr?: any, props?: any, callerArgs?: any) => any;
28
20
  declare type GetComponentType = (componentName: string) => ReactNode;
@@ -64,14 +56,28 @@ interface ValidationType {
64
56
  path: string;
65
57
  schema: any;
66
58
  }
67
- interface ReduxPathType {
59
+ declare enum ReduxPathTypeEnum {
60
+ ERROR = "ERROR",
61
+ TOUCH = "TOUCH",
62
+ NORMAL = "NORMAL"
63
+ }
64
+ interface ReduxPath {
68
65
  store?: string;
69
66
  path?: string;
70
- isError?: boolean;
67
+ type?: ReduxPathTypeEnum;
68
+ jsonataDef?: string;
69
+ }
70
+ interface JsonUIComponentsType {
71
+ [key: string]: ReactNode;
72
+ }
73
+ declare type JsonUIFunctionType = (attr: any, props: any, callerArgs: any, stock: any) => Promise<void> | void | any;
74
+ interface JsonUIFunctions {
75
+ [key: string]: JsonUIFunctionType;
71
76
  }
72
77
 
73
78
  declare const SEPARATOR = "/";
74
79
  declare const STORE_ERROR_POSTFIX = ".error";
80
+ declare const STORE_TOUCH_POSTFIX = ".touch";
75
81
  declare const PATH_MODIFIERS_KEY = "$pathModifiers";
76
82
  declare const MODIFIER_KEY = "$modifier";
77
83
  declare const ACTION_KEY = "$action";
@@ -99,12 +105,14 @@ declare const REDUX_PATHS = "$$reduxPaths";
99
105
  declare const V_CHILDREN_PREFIX = "$child";
100
106
  declare const PARENT_PROP_NAME = "__parentprop";
101
107
  declare const CURRENT_PATH_NAME = "__currentPaths";
108
+ declare const REDUX_GET_SUBSCRIBERS_NAME = "__subscriberPaths";
102
109
  declare const UNDEFINED_COMP_NAME = "_Undefined";
103
110
  declare const PRIMITIVE_COMP_NAME = "_PrimitiveProp";
104
111
  declare const FRAGMENT_COMP_NAME = "Fragment";
105
112
 
106
113
  declare const constants_d_SEPARATOR: typeof SEPARATOR;
107
114
  declare const constants_d_STORE_ERROR_POSTFIX: typeof STORE_ERROR_POSTFIX;
115
+ declare const constants_d_STORE_TOUCH_POSTFIX: typeof STORE_TOUCH_POSTFIX;
108
116
  declare const constants_d_PATH_MODIFIERS_KEY: typeof PATH_MODIFIERS_KEY;
109
117
  declare const constants_d_MODIFIER_KEY: typeof MODIFIER_KEY;
110
118
  declare const constants_d_ACTION_KEY: typeof ACTION_KEY;
@@ -132,6 +140,7 @@ declare const constants_d_REDUX_PATHS: typeof REDUX_PATHS;
132
140
  declare const constants_d_V_CHILDREN_PREFIX: typeof V_CHILDREN_PREFIX;
133
141
  declare const constants_d_PARENT_PROP_NAME: typeof PARENT_PROP_NAME;
134
142
  declare const constants_d_CURRENT_PATH_NAME: typeof CURRENT_PATH_NAME;
143
+ declare const constants_d_REDUX_GET_SUBSCRIBERS_NAME: typeof REDUX_GET_SUBSCRIBERS_NAME;
135
144
  declare const constants_d_UNDEFINED_COMP_NAME: typeof UNDEFINED_COMP_NAME;
136
145
  declare const constants_d_PRIMITIVE_COMP_NAME: typeof PRIMITIVE_COMP_NAME;
137
146
  declare const constants_d_FRAGMENT_COMP_NAME: typeof FRAGMENT_COMP_NAME;
@@ -139,6 +148,7 @@ declare namespace constants_d {
139
148
  export {
140
149
  constants_d_SEPARATOR as SEPARATOR,
141
150
  constants_d_STORE_ERROR_POSTFIX as STORE_ERROR_POSTFIX,
151
+ constants_d_STORE_TOUCH_POSTFIX as STORE_TOUCH_POSTFIX,
142
152
  constants_d_PATH_MODIFIERS_KEY as PATH_MODIFIERS_KEY,
143
153
  constants_d_MODIFIER_KEY as MODIFIER_KEY,
144
154
  constants_d_ACTION_KEY as ACTION_KEY,
@@ -166,6 +176,7 @@ declare namespace constants_d {
166
176
  constants_d_V_CHILDREN_PREFIX as V_CHILDREN_PREFIX,
167
177
  constants_d_PARENT_PROP_NAME as PARENT_PROP_NAME,
168
178
  constants_d_CURRENT_PATH_NAME as CURRENT_PATH_NAME,
179
+ constants_d_REDUX_GET_SUBSCRIBERS_NAME as REDUX_GET_SUBSCRIBERS_NAME,
169
180
  constants_d_UNDEFINED_COMP_NAME as UNDEFINED_COMP_NAME,
170
181
  constants_d_PRIMITIVE_COMP_NAME as PRIMITIVE_COMP_NAME,
171
182
  constants_d_FRAGMENT_COMP_NAME as FRAGMENT_COMP_NAME,
@@ -181,13 +192,10 @@ interface OwnTraverse {
181
192
  }
182
193
  declare const getFilteredPath: ({ [c.PARENT_PROP_NAME]: parentComp, ...propsNew }: PropsType, func: (filterProps: OwnTraverse) => boolean) => OwnTraverse[];
183
194
  declare const actionBuilder: (props: PropsType, stock: InstanceType<typeof Stock>) => void;
184
- declare const calculatePropsFromModifier: (props: PropsType, stock: InstanceType<typeof Stock>) => ReduxPathType[];
195
+ declare const calculatePropsFromModifier: (props: PropsType, stock: InstanceType<typeof Stock>) => ReduxPath[];
185
196
  declare const getCurrentPaths: (props: PropsType, pathModifier: PathModifiersType) => PathModifiersType;
186
197
  declare const normalisePrimitives: (props: PropsType, parentComp?: any) => any;
187
- declare const getRootWrapperProps: (props: PropsType, stock: InstanceType<typeof Stock>) => {
188
- [x: string]: PropValue;
189
- $pathModifiers?: PathModifiersType | undefined;
190
- };
198
+ declare const getRootWrapperProps: (props: PropsType, stock: InstanceType<typeof Stock>) => void;
191
199
  declare const isChildrenProp: (propName?: string | undefined) => boolean;
192
200
  declare const getParentProps: (props: PropsType) => PropsType;
193
201
  declare const getPropsChildrenFilter: ({ props, filter }: {
@@ -236,6 +244,7 @@ declare namespace wrapperUtil_d {
236
244
  declare const findLastIndex: (arr: any[], func: any) => number;
237
245
  declare const drop: (arr: any[], n?: number) => any[];
238
246
  declare const isNumber: (a: any) => boolean;
247
+ declare const jsonPointerFix: (path?: string | undefined) => string;
239
248
  declare const jsonPointerGet: (json: any, path?: string | undefined) => any;
240
249
  declare const jsonPointerSet: (json: any, path?: string | undefined, value?: any) => any;
241
250
  declare const pathArrayToPathString: (array: (string | number)[]) => string;
@@ -250,12 +259,15 @@ declare const changeRelativePath: (path: string) => string;
250
259
  */
251
260
  declare function mergeDeep(target: any, ...sources: any): any;
252
261
  declare const collectObjMerge: (refConst: string, json: any) => {};
253
- declare const collectObjToArray: (refConst: string, json: any) => any[];
254
- declare const isCircular: (d: any) => boolean;
262
+ declare const collectObjToArray: (refConst: string, json: any, flatten?: boolean) => any[];
263
+ declare const isValidJson: (d: any) => boolean;
264
+ declare const isPrimitiveValue: (value: any, emptyStringAllowed?: boolean) => boolean;
265
+ declare const hasLeaf: (obj: any, emptyStringAllowed?: boolean) => boolean;
255
266
 
256
267
  declare const util_d_findLastIndex: typeof findLastIndex;
257
268
  declare const util_d_drop: typeof drop;
258
269
  declare const util_d_isNumber: typeof isNumber;
270
+ declare const util_d_jsonPointerFix: typeof jsonPointerFix;
259
271
  declare const util_d_jsonPointerGet: typeof jsonPointerGet;
260
272
  declare const util_d_jsonPointerSet: typeof jsonPointerSet;
261
273
  declare const util_d_pathArrayToPathString: typeof pathArrayToPathString;
@@ -266,12 +278,15 @@ declare const util_d_changeRelativePath: typeof changeRelativePath;
266
278
  declare const util_d_mergeDeep: typeof mergeDeep;
267
279
  declare const util_d_collectObjMerge: typeof collectObjMerge;
268
280
  declare const util_d_collectObjToArray: typeof collectObjToArray;
269
- declare const util_d_isCircular: typeof isCircular;
281
+ declare const util_d_isValidJson: typeof isValidJson;
282
+ declare const util_d_isPrimitiveValue: typeof isPrimitiveValue;
283
+ declare const util_d_hasLeaf: typeof hasLeaf;
270
284
  declare namespace util_d {
271
285
  export {
272
286
  util_d_findLastIndex as findLastIndex,
273
287
  util_d_drop as drop,
274
288
  util_d_isNumber as isNumber,
289
+ util_d_jsonPointerFix as jsonPointerFix,
275
290
  util_d_jsonPointerGet as jsonPointerGet,
276
291
  util_d_jsonPointerSet as jsonPointerSet,
277
292
  util_d_pathArrayToPathString as pathArrayToPathString,
@@ -282,7 +297,9 @@ declare namespace util_d {
282
297
  util_d_mergeDeep as mergeDeep,
283
298
  util_d_collectObjMerge as collectObjMerge,
284
299
  util_d_collectObjToArray as collectObjToArray,
285
- util_d_isCircular as isCircular,
300
+ util_d_isValidJson as isValidJson,
301
+ util_d_isPrimitiveValue as isPrimitiveValue,
302
+ util_d_hasLeaf as hasLeaf,
286
303
  };
287
304
  }
288
305
 
@@ -316,12 +333,12 @@ declare class I18n {
316
333
  declare const StockContext: react.Context<Stock$1 | null>;
317
334
  declare const PathModifierContext: react.Context<{}>;
318
335
 
319
- declare const compSelectorHook: (currentPaths: PathModifiersType, subscriberPaths: ReduxPathType[]) => (state: any) => any[] | undefined;
336
+ declare const compSelectorHook: (currentPaths: PathModifiersType, subscriberPaths: ReduxPath[]) => (state: any) => any[] | undefined;
320
337
 
321
338
  declare const _default$1: {
322
- getStateValue: JsonUIFunctionType;
323
339
  get: JsonUIFunctionType;
324
340
  set: JsonUIFunctionType;
341
+ jsonata: JsonUIFunctionType;
325
342
  };
326
343
 
327
344
  declare const _default: {
@@ -334,4 +351,6 @@ declare const rootReducer: redux.Reducer<redux.CombinedState<{
334
351
  root: any;
335
352
  }>, redux.AnyAction>;
336
353
 
337
- export { ArraysType, I18n, Path, PathModifierContext, PathModifierType, PathModifiersType, PathType, PathsType, PropValue, PropsType, ReduxPathType, Stock, StockContext, UIDefinition, ValidationType, WrapperType, appRootFunctions, compSelectorHook, constants_d as constants, _default as persistConfig, _default$1 as stockFunctions, rootReducer as storeReducers, util_d as util, wrapperUtil_d as wrapperUtil };
354
+ declare const appRootFunctions: JsonUIFunctions$1;
355
+
356
+ export { ArraysType, I18n, JsonUIComponentsType, JsonUIFunctionType, JsonUIFunctions, Path, PathModifierContext, PathModifierType, PathModifiersType, PathType, PathsType, PropValue, PropsType, ReduxPath, ReduxPathTypeEnum, Stock, StockContext, UIDefinition, ValidationType, WrapperType, appRootFunctions, compSelectorHook, constants_d as constants, _default as persistConfig, _default$1 as stockFunctions, rootReducer as storeReducers, util_d as util, wrapperUtil_d as wrapperUtil };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonui/core",
3
- "version": "0.4.4",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/cjs/index.js",
@@ -22,6 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "ajv": "^8.9.0",
25
+ "ajv-errors": "^3.0.0",
26
+ "ajv-formats": "^3.0.1",
25
27
  "immer": "^9.0.12",
26
28
  "jsonata": "^1.8.5",
27
29
  "jsonpointer": "^5.0.0",
@@ -56,5 +58,5 @@
56
58
  "rollup-plugin-visualizer": "^5.5.4",
57
59
  "ts-jest": "^27.1.3"
58
60
  },
59
- "gitHead": "bd8d7759fb0c8bec66cdc73d87585832f07ae894"
61
+ "gitHead": "8cb10d757549ac50a7d2d1e7285b26015a0867eb"
60
62
  }