@m4l/core 0.0.10 → 0.0.13

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.
Files changed (33) hide show
  1. package/dist/axios.js +1235 -0
  2. package/dist/index.js +4 -1350
  3. package/dist/snakecase-keys.js +116 -0
  4. package/package.json +1 -1
  5. package/dist/contexts/EnvironmentContext/index.d.ts +0 -5
  6. package/dist/contexts/EnvironmentContext/types.d.ts +0 -6
  7. package/dist/contexts/FlagsContext/index.d.ts +0 -5
  8. package/dist/contexts/FlagsContext/types.d.ts +0 -10
  9. package/dist/contexts/HostToolsContext/index.d.ts +0 -6
  10. package/dist/contexts/HostToolsContext/types.d.ts +0 -6
  11. package/dist/contexts/ModuleDictionaryContext/index.d.ts +0 -5
  12. package/dist/contexts/ModuleDictionaryContext/types.d.ts +0 -15
  13. package/dist/contexts/NetworkContext/index.d.ts +0 -5
  14. package/dist/contexts/NetworkContext/types.d.ts +0 -11
  15. package/dist/contexts/index.d.ts +0 -5
  16. package/dist/hooks/index.d.ts +0 -6
  17. package/dist/hooks/useEnvironment/index.d.ts +0 -2
  18. package/dist/hooks/useFlags/index.d.ts +0 -3
  19. package/dist/hooks/useHostTools/index.d.ts +0 -2
  20. package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +0 -1
  21. package/dist/hooks/useModuleDictionary/index.d.ts +0 -1
  22. package/dist/hooks/useNetwork/index.d.ts +0 -2
  23. package/dist/index.d.ts +0 -6
  24. package/dist/types/dictionary.d.ts +0 -13
  25. package/dist/types/index.d.ts +0 -39
  26. package/dist/utils/axiosOperation/index.d.ts +0 -2
  27. package/dist/utils/axiosOperation/types.d.ts +0 -5
  28. package/dist/utils/getLocalStorage.d.ts +0 -1
  29. package/dist/utils/getPropertyByString.d.ts +0 -1
  30. package/dist/utils/index.d.ts +0 -5
  31. package/dist/utils/setLocalStorage.d.ts +0 -1
  32. package/dist/utils/voidFunction.d.ts +0 -1
  33. package/dist/vite-env.d.ts +0 -3
@@ -0,0 +1,116 @@
1
+ import { g as getAugmentedNamespace } from "./axios.js";
2
+ var mapObj = { exports: {} };
3
+ const isObject = (value) => typeof value === "object" && value !== null;
4
+ const mapObjectSkip = Symbol("skip");
5
+ const isObjectCustom = (value) => isObject(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
6
+ const mapObject = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap()) => {
7
+ options = {
8
+ deep: false,
9
+ target: {},
10
+ ...options
11
+ };
12
+ if (isSeen.has(object)) {
13
+ return isSeen.get(object);
14
+ }
15
+ isSeen.set(object, options.target);
16
+ const { target } = options;
17
+ delete options.target;
18
+ const mapArray = (array) => array.map((element) => isObjectCustom(element) ? mapObject(element, mapper, options, isSeen) : element);
19
+ if (Array.isArray(object)) {
20
+ return mapArray(object);
21
+ }
22
+ for (const [key, value] of Object.entries(object)) {
23
+ const mapResult = mapper(key, value, object);
24
+ if (mapResult === mapObjectSkip) {
25
+ continue;
26
+ }
27
+ let [newKey, newValue, { shouldRecurse = true } = {}] = mapResult;
28
+ if (newKey === "__proto__") {
29
+ continue;
30
+ }
31
+ if (options.deep && shouldRecurse && isObjectCustom(newValue)) {
32
+ newValue = Array.isArray(newValue) ? mapArray(newValue) : mapObject(newValue, mapper, options, isSeen);
33
+ }
34
+ target[newKey] = newValue;
35
+ }
36
+ return target;
37
+ };
38
+ mapObj.exports = (object, mapper, options) => {
39
+ if (!isObject(object)) {
40
+ throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
41
+ }
42
+ return mapObject(object, mapper, options);
43
+ };
44
+ mapObj.exports.mapObjectSkip = mapObjectSkip;
45
+ var __assign = function() {
46
+ __assign = Object.assign || function __assign2(t) {
47
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
48
+ s = arguments[i];
49
+ for (var p in s)
50
+ if (Object.prototype.hasOwnProperty.call(s, p))
51
+ t[p] = s[p];
52
+ }
53
+ return t;
54
+ };
55
+ return __assign.apply(this, arguments);
56
+ };
57
+ function lowerCase(str) {
58
+ return str.toLowerCase();
59
+ }
60
+ var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
61
+ var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
62
+ function noCase(input, options) {
63
+ if (options === void 0) {
64
+ options = {};
65
+ }
66
+ var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
67
+ var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
68
+ var start = 0;
69
+ var end = result.length;
70
+ while (result.charAt(start) === "\0")
71
+ start++;
72
+ while (result.charAt(end - 1) === "\0")
73
+ end--;
74
+ return result.slice(start, end).split("\0").map(transform).join(delimiter);
75
+ }
76
+ function replace(input, re, value) {
77
+ if (re instanceof RegExp)
78
+ return input.replace(re, value);
79
+ return re.reduce(function(input2, re2) {
80
+ return input2.replace(re2, value);
81
+ }, input);
82
+ }
83
+ function dotCase(input, options) {
84
+ if (options === void 0) {
85
+ options = {};
86
+ }
87
+ return noCase(input, __assign({ delimiter: "." }, options));
88
+ }
89
+ function snakeCase$1(input, options) {
90
+ if (options === void 0) {
91
+ options = {};
92
+ }
93
+ return dotCase(input, __assign({ delimiter: "_" }, options));
94
+ }
95
+ const dist_es2015 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
96
+ __proto__: null,
97
+ snakeCase: snakeCase$1
98
+ }, Symbol.toStringTag, { value: "Module" }));
99
+ const require$$1 = /* @__PURE__ */ getAugmentedNamespace(dist_es2015);
100
+ const map = mapObj.exports;
101
+ const { snakeCase } = require$$1;
102
+ var snakecaseKeys = function(obj, options) {
103
+ options = Object.assign({ deep: true, exclude: [], parsingOptions: {} }, options);
104
+ return map(obj, function(key, val) {
105
+ return [
106
+ matches(options.exclude, key) ? key : snakeCase(key, options.parsingOptions),
107
+ val
108
+ ];
109
+ }, options);
110
+ };
111
+ function matches(patterns, value) {
112
+ return patterns.some(function(pattern) {
113
+ return typeof pattern === "string" ? pattern === value : pattern.test(value);
114
+ });
115
+ }
116
+ export { snakecaseKeys as s };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
3
  "private": false,
4
- "version": "0.0.10",
4
+ "version": "0.0.13",
5
5
  "license": "UNLICENSED",
6
6
  "author": "M4L Team",
7
7
  "scripts": {
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { EnvironmentProviderProps } from './types';
3
- declare const EnvironmentContext: import("react").Context<import("../..").EnvironmentType>;
4
- declare function EnvironmentProvider(props: EnvironmentProviderProps): JSX.Element;
5
- export { EnvironmentProvider, EnvironmentContext };
@@ -1,6 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { EnvironmentType } from '../../types';
3
- export interface EnvironmentProviderProps extends EnvironmentType {
4
- children: ReactNode;
5
- }
6
- export declare type EnvironmentContextType = EnvironmentType;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { FlagsContextProps, FlagsProviderProps } from './types';
3
- declare const FlagsContext: import("react").Context<FlagsContextProps>;
4
- declare function FlagsProvider({ children }: FlagsProviderProps): JSX.Element;
5
- export { FlagsProvider, FlagsContext };
@@ -1,10 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export interface FlagsProviderProps {
3
- children: ReactNode;
4
- }
5
- export declare type Flag = string;
6
- export interface FlagsContextProps {
7
- flags: Array<Flag>;
8
- clearFlags: () => void;
9
- addFlag: (flag: Flag) => void;
10
- }
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { HostToolsType } from '../../types';
3
- import { HostToolsProviderProps } from './types';
4
- declare const HostToolsContext: import("react").Context<HostToolsType>;
5
- declare function HostToolsProvider(props: HostToolsProviderProps): JSX.Element;
6
- export { HostToolsProvider, HostToolsContext };
@@ -1,6 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { HostToolsType } from '../../types';
3
- export interface HostToolsProviderProps extends HostToolsType {
4
- children: ReactNode;
5
- }
6
- export declare type HostToolsContextType = HostToolsType;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { ModuleDictionaryContextProps, ModuleDictionaryProviderProps } from './types';
3
- declare const ModuleDictionaryContext: import("react").Context<ModuleDictionaryContextProps>;
4
- declare function ModuleDictionaryProvider(props: ModuleDictionaryProviderProps): JSX.Element;
5
- export { ModuleDictionaryProvider, ModuleDictionaryContext };
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import type { GetLabelType, ModuleDictionary } from 'src/types/dictionary';
3
- export interface ModuleDictionaryProviderProps {
4
- currentLang?: string;
5
- isAuth?: boolean;
6
- moduleId: number;
7
- moduleName?: string;
8
- componentsDictionary: string[];
9
- children: ReactNode;
10
- }
11
- export interface ModuleDictionaryContextProps {
12
- moduleDictionary?: ModuleDictionary;
13
- getLabel: GetLabelType;
14
- getModuleLabel: () => string;
15
- }
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { NetworkProviderProps } from './types';
3
- declare const NetworkContext: import("react").Context<import("./types").NetworkType>;
4
- declare function NetworkProvider(props: NetworkProviderProps): JSX.Element;
5
- export { NetworkProvider, NetworkContext };
@@ -1,11 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { AxiosOperation, NetworkProps } from '../../types';
3
- export declare type EventFunListener = (...args: any[]) => void;
4
- export interface NetworkType {
5
- networkOperation: (props: NetworkProps) => Promise<any>;
6
- }
7
- export interface NetworkProviderProps {
8
- axiosOperation: AxiosOperation;
9
- children: ReactNode;
10
- }
11
- export declare type NetworkContextType = NetworkType;
@@ -1,5 +0,0 @@
1
- export { EnvironmentContext, EnvironmentProvider } from './EnvironmentContext';
2
- export { HostToolsContext, HostToolsProvider } from './HostToolsContext';
3
- export { NetworkContext, NetworkProvider } from './NetworkContext';
4
- export { FlagsContext, FlagsProvider } from './FlagsContext';
5
- export { ModuleDictionaryContext, ModuleDictionaryProvider } from './ModuleDictionaryContext';
@@ -1,6 +0,0 @@
1
- export { useLocalStorage } from './useLocalStorage/useLocalStorage';
2
- export { useHostTools } from './useHostTools';
3
- export { useNetwork } from './useNetwork';
4
- export { useEnvironment } from './useEnvironment';
5
- export { useFlags, useFlagsPresent } from './useFlags';
6
- export { useModuleDictionary } from './useModuleDictionary';
@@ -1,2 +0,0 @@
1
- export declare const useEnvironment: () => import("../..").EnvironmentType;
2
- export default useEnvironment;
@@ -1,3 +0,0 @@
1
- import type { Flag, FlagsContextProps } from '../../contexts/FlagsContext/types';
2
- export declare const useFlags: () => FlagsContextProps;
3
- export declare const useFlagsPresent: (compareFlags: Array<Flag>) => boolean;
@@ -1,2 +0,0 @@
1
- export declare const useHostTools: () => import("../..").HostToolsType;
2
- export default useHostTools;
@@ -1 +0,0 @@
1
- export declare function useLocalStorage<ValueType>(key: string, initialValue: ValueType): any[];
@@ -1 +0,0 @@
1
- export declare const useModuleDictionary: () => import("../../contexts/ModuleDictionaryContext/types").ModuleDictionaryContextProps;
@@ -1,2 +0,0 @@
1
- export declare const useNetwork: () => import("../../contexts/NetworkContext/types").NetworkType;
2
- export default useNetwork;
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './contexts';
2
- export * from './hooks';
3
- export { EmitEvents } from './types';
4
- export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventFunListener, } from './types';
5
- export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
6
- export * from './utils';
@@ -1,13 +0,0 @@
1
- export declare type GetLabelType = (key: string) => string;
2
- export interface ComponentDictionary {
3
- [key: string]: string;
4
- }
5
- export interface Dictionary {
6
- [key: string]: ComponentDictionary | boolean | undefined | string;
7
- }
8
- export interface DataDictionary extends ComponentDictionary {
9
- module_name: string;
10
- }
11
- export interface ModuleDictionary extends Dictionary {
12
- data: DataDictionary;
13
- }
@@ -1,39 +0,0 @@
1
- import type { Method } from 'axios';
2
- import type { Id, ToastContent, ToastOptions } from 'react-toastify';
3
- import type { BrowserHistory } from 'history';
4
- export declare type Maybe<T> = T | undefined | null;
5
- export declare interface EnvironmentType {
6
- isLocalhost: boolean;
7
- host: string;
8
- domain_token: string;
9
- host_api_remote: string;
10
- host_api_local: string;
11
- host_static_assets: string;
12
- environment: string;
13
- }
14
- export declare type NetworkProps = {
15
- method: Method;
16
- endPoint: string;
17
- timeout?: number;
18
- parms?: object;
19
- data?: object;
20
- checkUnAuthorized?: boolean;
21
- isRemote?: boolean;
22
- showSuccesInfo?: boolean;
23
- };
24
- export declare type ToastFunction = (content: ToastContent, options?: ToastOptions) => Id;
25
- export declare type EventFunListener = (...args: any[]) => void;
26
- export declare interface HostToolsType {
27
- history?: BrowserHistory;
28
- toast: ToastFunction;
29
- startProgress: VoidFunction;
30
- stopProgress: VoidFunction;
31
- events_add_listener: (eventName: string, handler: EventFunListener) => void;
32
- events_remove_listener: (eventName: string, handler: Maybe<EventFunListener>) => void;
33
- events_emit: (eventName: string, arg: any) => void;
34
- }
35
- export declare enum EmitEvents {
36
- EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized",
37
- EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change"
38
- }
39
- export declare type AxiosOperation = (props: NetworkProps, enviroment: EnvironmentType, hostTools: HostToolsType) => Promise<any>;
@@ -1,2 +0,0 @@
1
- import type { EnvironmentType, HostToolsType, NetworkProps } from '../../types';
2
- export declare const axiosOperation: (props: NetworkProps, enviroment: EnvironmentType, hostTools: HostToolsType) => Promise<any>;
@@ -1,5 +0,0 @@
1
- export declare type AxiosOperationError = {
2
- message: string;
3
- status: number;
4
- code: string | number;
5
- };
@@ -1 +0,0 @@
1
- export declare function getLocalStorage<ValueType>(key: string, initialValue: ValueType): ValueType;
@@ -1 +0,0 @@
1
- export declare function getPropertyByString(object: Record<string, unknown>, propString: string): any;
@@ -1,5 +0,0 @@
1
- export { voidFunction } from './voidFunction';
2
- export { getPropertyByString } from './getPropertyByString';
3
- export { getLocalStorage } from './getLocalStorage';
4
- export { setLocalStorage } from './setLocalStorage';
5
- export { axiosOperation } from './axiosOperation';
@@ -1 +0,0 @@
1
- export declare function setLocalStorage<ValueType>(key: string, value: ValueType): void;
@@ -1 +0,0 @@
1
- export declare function voidFunction(): void;
@@ -1,3 +0,0 @@
1
- /// <reference types="vite/client" />
2
- /// <reference types="vitest" />
3
- /// <reference types="vitest/importMeta" />