@fctc/interface-logic 1.2.10 → 1.3.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.
@@ -0,0 +1,93 @@
1
+ declare class WesapError extends Error {
2
+ code: number;
3
+ constructor(message: string, code: number);
4
+ }
5
+ declare function handleError(error: Error, env: {
6
+ services: {
7
+ notification: {
8
+ error: (message: string) => void;
9
+ };
10
+ };
11
+ }): void;
12
+
13
+ declare const formatCurrency: (amount: number, currency?: string) => string;
14
+ declare const formatDate: (date: string | Date, locale?: string) => string;
15
+ declare const validateAndParseDate: (input: string, isDateTime?: boolean) => string | null;
16
+
17
+ type AST = {
18
+ type: number;
19
+ value: any;
20
+ };
21
+ type Condition = [string | 0 | 1, string, any];
22
+ type DomainListRepr = ('&' | '|' | '!' | Condition)[];
23
+ type DomainRepr = DomainListRepr | string | Domain;
24
+ declare class Domain {
25
+ ast: AST;
26
+ static TRUE: Domain;
27
+ static FALSE: Domain;
28
+ static combine(domains: DomainRepr[], operator: 'AND' | 'OR'): Domain;
29
+ static and(domains: DomainRepr[]): Domain;
30
+ static or(domains: DomainRepr[]): Domain;
31
+ static not(domain: DomainRepr): Domain;
32
+ static removeDomainLeaves(domain: DomainRepr, keysToRemove: string[]): Domain;
33
+ constructor(descr?: DomainRepr);
34
+ contains(record: any): boolean;
35
+ toString(): string;
36
+ toList(context: Record<string, any>): DomainListRepr;
37
+ toJson(): DomainListRepr | string;
38
+ }
39
+
40
+ declare const evalJSONContext: (_context: any, context?: {}) => any;
41
+ declare const evalJSONDomain: (domain: any, context: any) => any;
42
+ declare const formatSortingString: (input: string | null | undefined) => string | null;
43
+ declare const domainHelper: {
44
+ checkDomain: (context: any, domain: any) => boolean;
45
+ matchDomains: (context: any, domains: any) => boolean;
46
+ Domain: typeof Domain;
47
+ };
48
+ declare const toQueryString: (params: Record<string, string | number | boolean>) => string;
49
+ declare const convertFloatToTime: (floatValue: number) => string;
50
+ declare const convertTimeToFloat: (timeString: string) => number;
51
+ declare const stringToColor: (name: string, id: number) => string;
52
+ declare const getFieldsOnChange: (fields: any) => any;
53
+ declare const filterFieldDirty: ({ id, viewData, formValues, dirtyFields, model, defaultData, }: {
54
+ id?: any;
55
+ viewData?: any;
56
+ formValues?: any;
57
+ dirtyFields?: any;
58
+ model?: any;
59
+ defaultData?: any;
60
+ }) => any;
61
+ type MergeableObject = {
62
+ [key: string]: any;
63
+ } | null | undefined;
64
+ declare const mergeObjects: <T extends MergeableObject, U extends MergeableObject>(object1: T, object2: U) => (T & U) | undefined;
65
+ declare const formatUrlPath: ({ viewType, aid, model, id, actionPath, }: {
66
+ viewType: "list" | "form" | "kanban" | any;
67
+ actionPath: string;
68
+ aid: string | number;
69
+ model: string;
70
+ id?: string | number;
71
+ }) => string;
72
+ declare const removeUndefinedFields: <T extends Record<string, any>>(obj: T) => Partial<T>;
73
+ declare const useTabModel: (viewData: any, onchangeData: any) => any;
74
+ declare const isBase64File: (str: any) => boolean;
75
+ declare const isBase64Image: (str: any) => boolean;
76
+ declare const checkIsImageLink: (url: any) => boolean;
77
+ declare const formatFileSize: (size: any) => string;
78
+ declare const getSubdomain: (url?: string) => string | null;
79
+ declare const resequence: (arr: any, start: any, end: any) => any;
80
+ declare const getOffSet: (arr: any, start: any, end: any) => any;
81
+ declare const copyTextToClipboard: (text: string) => Promise<void>;
82
+ declare const updateTokenParamInOriginalRequest: (originalRequest: {
83
+ data?: any;
84
+ }, newAccessToken: string) => any;
85
+ declare const isObjectEmpty: (obj: object) => boolean;
86
+ declare const useField: (props: any) => {
87
+ invisible: boolean;
88
+ required: boolean;
89
+ readonly: boolean;
90
+ nameField: string | null;
91
+ };
92
+
93
+ export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
@@ -0,0 +1,93 @@
1
+ declare class WesapError extends Error {
2
+ code: number;
3
+ constructor(message: string, code: number);
4
+ }
5
+ declare function handleError(error: Error, env: {
6
+ services: {
7
+ notification: {
8
+ error: (message: string) => void;
9
+ };
10
+ };
11
+ }): void;
12
+
13
+ declare const formatCurrency: (amount: number, currency?: string) => string;
14
+ declare const formatDate: (date: string | Date, locale?: string) => string;
15
+ declare const validateAndParseDate: (input: string, isDateTime?: boolean) => string | null;
16
+
17
+ type AST = {
18
+ type: number;
19
+ value: any;
20
+ };
21
+ type Condition = [string | 0 | 1, string, any];
22
+ type DomainListRepr = ('&' | '|' | '!' | Condition)[];
23
+ type DomainRepr = DomainListRepr | string | Domain;
24
+ declare class Domain {
25
+ ast: AST;
26
+ static TRUE: Domain;
27
+ static FALSE: Domain;
28
+ static combine(domains: DomainRepr[], operator: 'AND' | 'OR'): Domain;
29
+ static and(domains: DomainRepr[]): Domain;
30
+ static or(domains: DomainRepr[]): Domain;
31
+ static not(domain: DomainRepr): Domain;
32
+ static removeDomainLeaves(domain: DomainRepr, keysToRemove: string[]): Domain;
33
+ constructor(descr?: DomainRepr);
34
+ contains(record: any): boolean;
35
+ toString(): string;
36
+ toList(context: Record<string, any>): DomainListRepr;
37
+ toJson(): DomainListRepr | string;
38
+ }
39
+
40
+ declare const evalJSONContext: (_context: any, context?: {}) => any;
41
+ declare const evalJSONDomain: (domain: any, context: any) => any;
42
+ declare const formatSortingString: (input: string | null | undefined) => string | null;
43
+ declare const domainHelper: {
44
+ checkDomain: (context: any, domain: any) => boolean;
45
+ matchDomains: (context: any, domains: any) => boolean;
46
+ Domain: typeof Domain;
47
+ };
48
+ declare const toQueryString: (params: Record<string, string | number | boolean>) => string;
49
+ declare const convertFloatToTime: (floatValue: number) => string;
50
+ declare const convertTimeToFloat: (timeString: string) => number;
51
+ declare const stringToColor: (name: string, id: number) => string;
52
+ declare const getFieldsOnChange: (fields: any) => any;
53
+ declare const filterFieldDirty: ({ id, viewData, formValues, dirtyFields, model, defaultData, }: {
54
+ id?: any;
55
+ viewData?: any;
56
+ formValues?: any;
57
+ dirtyFields?: any;
58
+ model?: any;
59
+ defaultData?: any;
60
+ }) => any;
61
+ type MergeableObject = {
62
+ [key: string]: any;
63
+ } | null | undefined;
64
+ declare const mergeObjects: <T extends MergeableObject, U extends MergeableObject>(object1: T, object2: U) => (T & U) | undefined;
65
+ declare const formatUrlPath: ({ viewType, aid, model, id, actionPath, }: {
66
+ viewType: "list" | "form" | "kanban" | any;
67
+ actionPath: string;
68
+ aid: string | number;
69
+ model: string;
70
+ id?: string | number;
71
+ }) => string;
72
+ declare const removeUndefinedFields: <T extends Record<string, any>>(obj: T) => Partial<T>;
73
+ declare const useTabModel: (viewData: any, onchangeData: any) => any;
74
+ declare const isBase64File: (str: any) => boolean;
75
+ declare const isBase64Image: (str: any) => boolean;
76
+ declare const checkIsImageLink: (url: any) => boolean;
77
+ declare const formatFileSize: (size: any) => string;
78
+ declare const getSubdomain: (url?: string) => string | null;
79
+ declare const resequence: (arr: any, start: any, end: any) => any;
80
+ declare const getOffSet: (arr: any, start: any, end: any) => any;
81
+ declare const copyTextToClipboard: (text: string) => Promise<void>;
82
+ declare const updateTokenParamInOriginalRequest: (originalRequest: {
83
+ data?: any;
84
+ }, newAccessToken: string) => any;
85
+ declare const isObjectEmpty: (obj: object) => boolean;
86
+ declare const useField: (props: any) => {
87
+ invisible: boolean;
88
+ required: boolean;
89
+ readonly: boolean;
90
+ nameField: string | null;
91
+ };
92
+
93
+ export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
package/dist/utils.js CHANGED
@@ -51,11 +51,9 @@ __export(utils_exports, {
51
51
  isBase64File: () => isBase64File,
52
52
  isBase64Image: () => isBase64Image,
53
53
  isObjectEmpty: () => isObjectEmpty,
54
- localStorageUtils: () => localStorageUtils,
55
54
  mergeObjects: () => mergeObjects,
56
55
  removeUndefinedFields: () => removeUndefinedFields,
57
56
  resequence: () => resequence,
58
- sessionStorageUtils: () => sessionStorageUtils,
59
57
  stringToColor: () => stringToColor,
60
58
  toQueryString: () => toQueryString,
61
59
  updateTokenParamInOriginalRequest: () => updateTokenParamInOriginalRequest,
@@ -2929,43 +2927,6 @@ var useField = (props) => {
2929
2927
  nameField
2930
2928
  };
2931
2929
  };
2932
-
2933
- // src/utils/storage/local-storage.ts
2934
- var localStorageUtils = () => {
2935
- const setToken = async (access_token) => {
2936
- localStorage.setItem("accessToken", access_token);
2937
- };
2938
- const setRefreshToken = async (refresh_token) => {
2939
- localStorage.setItem("refreshToken", refresh_token);
2940
- };
2941
- const getAccessToken = async () => {
2942
- return localStorage.getItem("accessToken");
2943
- };
2944
- const getRefreshToken = async () => {
2945
- return localStorage.getItem("refreshToken");
2946
- };
2947
- const clearToken = async () => {
2948
- localStorage.removeItem("accessToken");
2949
- localStorage.removeItem("refreshToken");
2950
- };
2951
- return {
2952
- setToken,
2953
- setRefreshToken,
2954
- getAccessToken,
2955
- getRefreshToken,
2956
- clearToken
2957
- };
2958
- };
2959
-
2960
- // src/utils/storage/session-storage.ts
2961
- var sessionStorageUtils = () => {
2962
- const getBrowserSession = async () => {
2963
- return sessionStorage.getItem("browserSession");
2964
- };
2965
- return {
2966
- getBrowserSession
2967
- };
2968
- };
2969
2930
  // Annotate the CommonJS export names for ESM import in node:
2970
2931
  0 && (module.exports = {
2971
2932
  WesapError,
@@ -2989,11 +2950,9 @@ var sessionStorageUtils = () => {
2989
2950
  isBase64File,
2990
2951
  isBase64Image,
2991
2952
  isObjectEmpty,
2992
- localStorageUtils,
2993
2953
  mergeObjects,
2994
2954
  removeUndefinedFields,
2995
2955
  resequence,
2996
- sessionStorageUtils,
2997
2956
  stringToColor,
2998
2957
  toQueryString,
2999
2958
  updateTokenParamInOriginalRequest,
package/dist/utils.mjs CHANGED
@@ -2862,43 +2862,6 @@ var useField = (props) => {
2862
2862
  nameField
2863
2863
  };
2864
2864
  };
2865
-
2866
- // src/utils/storage/local-storage.ts
2867
- var localStorageUtils = () => {
2868
- const setToken = async (access_token) => {
2869
- localStorage.setItem("accessToken", access_token);
2870
- };
2871
- const setRefreshToken = async (refresh_token) => {
2872
- localStorage.setItem("refreshToken", refresh_token);
2873
- };
2874
- const getAccessToken = async () => {
2875
- return localStorage.getItem("accessToken");
2876
- };
2877
- const getRefreshToken = async () => {
2878
- return localStorage.getItem("refreshToken");
2879
- };
2880
- const clearToken = async () => {
2881
- localStorage.removeItem("accessToken");
2882
- localStorage.removeItem("refreshToken");
2883
- };
2884
- return {
2885
- setToken,
2886
- setRefreshToken,
2887
- getAccessToken,
2888
- getRefreshToken,
2889
- clearToken
2890
- };
2891
- };
2892
-
2893
- // src/utils/storage/session-storage.ts
2894
- var sessionStorageUtils = () => {
2895
- const getBrowserSession = async () => {
2896
- return sessionStorage.getItem("browserSession");
2897
- };
2898
- return {
2899
- getBrowserSession
2900
- };
2901
- };
2902
2865
  export {
2903
2866
  WesapError,
2904
2867
  checkIsImageLink,
@@ -2921,11 +2884,9 @@ export {
2921
2884
  isBase64File,
2922
2885
  isBase64Image,
2923
2886
  isObjectEmpty,
2924
- localStorageUtils,
2925
2887
  mergeObjects,
2926
2888
  removeUndefinedFields,
2927
2889
  resequence,
2928
- sessionStorageUtils,
2929
2890
  stringToColor,
2930
2891
  toQueryString,
2931
2892
  updateTokenParamInOriginalRequest,
@@ -0,0 +1,100 @@
1
+ interface LoginCredentialBody {
2
+ email: string;
3
+ password: string;
4
+ path?: string;
5
+ }
6
+ interface ResetPasswordRequest {
7
+ password: string;
8
+ confirmPassword: string;
9
+ }
10
+ interface UpdatePasswordRequest {
11
+ newPassword: string;
12
+ oldPassword: string;
13
+ }
14
+ interface ForgotPasswordBody {
15
+ data: ResetPasswordRequest;
16
+ token: string | null;
17
+ }
18
+ interface updatePasswordBody {
19
+ data: UpdatePasswordRequest;
20
+ token: string | null;
21
+ }
22
+ interface SocialTokenBody {
23
+ state: object;
24
+ access_token: string;
25
+ db: string;
26
+ }
27
+
28
+ interface Specification {
29
+ [key: string]: any;
30
+ }
31
+ interface ContextApi {
32
+ [key: string]: any;
33
+ }
34
+ interface GetListParams {
35
+ model: string;
36
+ ids?: number[];
37
+ specification?: Specification;
38
+ domain?: any[];
39
+ offset?: number;
40
+ order?: string;
41
+ context?: ContextApi;
42
+ limit?: number;
43
+ }
44
+ interface GetDetailParams {
45
+ ids?: number[];
46
+ model?: string;
47
+ specification?: Specification;
48
+ context?: ContextApi;
49
+ }
50
+ interface SaveParams {
51
+ model: string;
52
+ ids?: number[] | [];
53
+ data?: Record<string, any>;
54
+ specification?: Specification;
55
+ context?: ContextApi;
56
+ }
57
+ interface DeleteParams {
58
+ ids?: number[];
59
+ model: string;
60
+ }
61
+ interface OnChangeParams {
62
+ ids?: number[];
63
+ model: string;
64
+ object?: Record<string, any>;
65
+ specification: Specification;
66
+ context?: ContextApi;
67
+ fieldChange?: string[];
68
+ }
69
+ interface ViewData {
70
+ models?: {
71
+ [key: string]: {
72
+ [key: string]: {
73
+ type: string;
74
+ relation?: string;
75
+ };
76
+ };
77
+ };
78
+ }
79
+ type GetSelectionType = {
80
+ domain: any;
81
+ context: any;
82
+ model: string;
83
+ specification?: any;
84
+ };
85
+
86
+ type View = [number | boolean, string];
87
+ type Option = {
88
+ action_id?: number;
89
+ load_filters?: boolean;
90
+ toolbar?: boolean;
91
+ };
92
+ interface GetViewParams {
93
+ model?: string;
94
+ views?: View[];
95
+ context?: Record<string, any>;
96
+ options?: Option;
97
+ aid?: number | string | null | boolean;
98
+ }
99
+
100
+ export type { ContextApi as C, DeleteParams as D, ForgotPasswordBody as F, GetListParams as G, LoginCredentialBody as L, OnChangeParams as O, ResetPasswordRequest as R, SaveParams as S, UpdatePasswordRequest as U, ViewData as V, GetDetailParams as a, GetViewParams as b, GetSelectionType as c, SocialTokenBody as d, updatePasswordBody as u };
@@ -0,0 +1,100 @@
1
+ interface LoginCredentialBody {
2
+ email: string;
3
+ password: string;
4
+ path?: string;
5
+ }
6
+ interface ResetPasswordRequest {
7
+ password: string;
8
+ confirmPassword: string;
9
+ }
10
+ interface UpdatePasswordRequest {
11
+ newPassword: string;
12
+ oldPassword: string;
13
+ }
14
+ interface ForgotPasswordBody {
15
+ data: ResetPasswordRequest;
16
+ token: string | null;
17
+ }
18
+ interface updatePasswordBody {
19
+ data: UpdatePasswordRequest;
20
+ token: string | null;
21
+ }
22
+ interface SocialTokenBody {
23
+ state: object;
24
+ access_token: string;
25
+ db: string;
26
+ }
27
+
28
+ interface Specification {
29
+ [key: string]: any;
30
+ }
31
+ interface ContextApi {
32
+ [key: string]: any;
33
+ }
34
+ interface GetListParams {
35
+ model: string;
36
+ ids?: number[];
37
+ specification?: Specification;
38
+ domain?: any[];
39
+ offset?: number;
40
+ order?: string;
41
+ context?: ContextApi;
42
+ limit?: number;
43
+ }
44
+ interface GetDetailParams {
45
+ ids?: number[];
46
+ model?: string;
47
+ specification?: Specification;
48
+ context?: ContextApi;
49
+ }
50
+ interface SaveParams {
51
+ model: string;
52
+ ids?: number[] | [];
53
+ data?: Record<string, any>;
54
+ specification?: Specification;
55
+ context?: ContextApi;
56
+ }
57
+ interface DeleteParams {
58
+ ids?: number[];
59
+ model: string;
60
+ }
61
+ interface OnChangeParams {
62
+ ids?: number[];
63
+ model: string;
64
+ object?: Record<string, any>;
65
+ specification: Specification;
66
+ context?: ContextApi;
67
+ fieldChange?: string[];
68
+ }
69
+ interface ViewData {
70
+ models?: {
71
+ [key: string]: {
72
+ [key: string]: {
73
+ type: string;
74
+ relation?: string;
75
+ };
76
+ };
77
+ };
78
+ }
79
+ type GetSelectionType = {
80
+ domain: any;
81
+ context: any;
82
+ model: string;
83
+ specification?: any;
84
+ };
85
+
86
+ type View = [number | boolean, string];
87
+ type Option = {
88
+ action_id?: number;
89
+ load_filters?: boolean;
90
+ toolbar?: boolean;
91
+ };
92
+ interface GetViewParams {
93
+ model?: string;
94
+ views?: View[];
95
+ context?: Record<string, any>;
96
+ options?: Option;
97
+ aid?: number | string | null | boolean;
98
+ }
99
+
100
+ export type { ContextApi as C, DeleteParams as D, ForgotPasswordBody as F, GetListParams as G, LoginCredentialBody as L, OnChangeParams as O, ResetPasswordRequest as R, SaveParams as S, UpdatePasswordRequest as U, ViewData as V, GetDetailParams as a, GetViewParams as b, GetSelectionType as c, SocialTokenBody as d, updatePasswordBody as u };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@fctc/interface-logic",
3
- "version": "1.2.10",
3
+ "version": "1.3.1",
4
4
  "types": "dist/index.d.ts",
5
- "main": "dist/index.js",
5
+ "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "exports": {
8
8
  ".": {
@@ -10,10 +10,10 @@
10
10
  "import": "./dist/index.mjs",
11
11
  "require": "./dist/index.cjs"
12
12
  },
13
- "./config": {
14
- "types": "./dist/index.d.ts",
15
- "import": "./dist/config.mjs",
16
- "require": "./dist/config.cjs"
13
+ "./configs": {
14
+ "types": "./dist/configs.d.ts",
15
+ "import": "./dist/configs.mjs",
16
+ "require": "./dist/configs.cjs"
17
17
  },
18
18
  "./constants": {
19
19
  "types": "./dist/constants.d.ts",
@@ -30,10 +30,10 @@
30
30
  "import": "./dist/hooks.mjs",
31
31
  "require": "./dist/hooks.cjs"
32
32
  },
33
- "./model": {
34
- "types": "./dist/model.d.ts",
35
- "import": "./dist/model.mjs",
36
- "require": "./dist/model.cjs"
33
+ "./models": {
34
+ "types": "./dist/models.d.ts",
35
+ "import": "./dist/models.mjs",
36
+ "require": "./dist/models.cjs"
37
37
  },
38
38
  "./provider": {
39
39
  "types": "./dist/provider.d.ts",
@@ -61,7 +61,6 @@
61
61
  "require": "./dist/utils.cjs"
62
62
  }
63
63
  },
64
- "imports": {},
65
64
  "files": [
66
65
  "dist"
67
66
  ],