@fixefy/fixefy-ui-utils 0.0.18 → 0.0.20

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 (167) hide show
  1. package/dist/auth/index.js +89 -0
  2. package/dist/aws/aws_lambda_helper.js +184 -0
  3. package/dist/aws/data_models.js +4 -0
  4. package/dist/aws/index.js +18 -0
  5. package/{dist-types → dist}/commander/index.d.ts +4 -2
  6. package/dist/commander/index.js +390 -0
  7. package/{dist-cjs → dist}/constants/index.d.ts +7 -0
  8. package/{dist-cjs → dist}/constants/index.js +41 -15
  9. package/dist/contents/index.js +154 -0
  10. package/{dist-cjs → dist}/files/index.js +22 -12
  11. package/dist/graphql/index.js +382 -0
  12. package/{dist-cjs → dist}/headers/index.d.ts +2 -4
  13. package/dist/headers/index.js +161 -0
  14. package/dist/images/index.js +18 -0
  15. package/{dist-cjs → dist}/index.d.ts +3 -0
  16. package/dist/index.js +43 -0
  17. package/{dist-cjs → dist}/json/index.js +67 -56
  18. package/{dist-es → dist}/page_context/index.d.ts +14 -0
  19. package/dist/page_context/index.js +742 -0
  20. package/dist/redirect/index.js +31 -0
  21. package/{dist-cjs → dist}/renderer/index.d.ts +1 -1
  22. package/dist/renderer/index.js +125 -0
  23. package/dist/resolvers/index.js +51 -0
  24. package/dist/transform/index.js +96 -0
  25. package/dist/types/index.js +4 -0
  26. package/{dist-cjs → dist}/validate/index.d.ts +1 -1
  27. package/dist/validate/index.js +68 -0
  28. package/package.json +8 -9
  29. package/dist-cjs/auth/index.js +0 -40
  30. package/dist-cjs/auth/index.js.map +0 -1
  31. package/dist-cjs/aws/aws_lambda_helper.js +0 -68
  32. package/dist-cjs/aws/aws_lambda_helper.js.map +0 -1
  33. package/dist-cjs/aws/aws_s3_helper.d.ts +0 -0
  34. package/dist-cjs/aws/aws_s3_helper.js +0 -243
  35. package/dist-cjs/aws/aws_s3_helper.js.map +0 -1
  36. package/dist-cjs/aws/data_models.js +0 -3
  37. package/dist-cjs/aws/data_models.js.map +0 -1
  38. package/dist-cjs/aws/index.js +0 -6
  39. package/dist-cjs/aws/index.js.map +0 -1
  40. package/dist-cjs/commander/index.d.ts +0 -33
  41. package/dist-cjs/commander/index.js +0 -292
  42. package/dist-cjs/commander/index.js.map +0 -1
  43. package/dist-cjs/constants/index.js.map +0 -1
  44. package/dist-cjs/contents/index.js +0 -33
  45. package/dist-cjs/contents/index.js.map +0 -1
  46. package/dist-cjs/files/index.js.map +0 -1
  47. package/dist-cjs/graphql/index.js +0 -338
  48. package/dist-cjs/graphql/index.js.map +0 -1
  49. package/dist-cjs/headers/index.js +0 -103
  50. package/dist-cjs/headers/index.js.map +0 -1
  51. package/dist-cjs/images/index.js +0 -16
  52. package/dist-cjs/images/index.js.map +0 -1
  53. package/dist-cjs/index.js +0 -21
  54. package/dist-cjs/index.js.map +0 -1
  55. package/dist-cjs/json/index.js.map +0 -1
  56. package/dist-cjs/package.json +0 -3
  57. package/dist-cjs/page_context/index.d.ts +0 -248
  58. package/dist-cjs/page_context/index.js +0 -511
  59. package/dist-cjs/page_context/index.js.map +0 -1
  60. package/dist-cjs/redirect/index.js +0 -19
  61. package/dist-cjs/redirect/index.js.map +0 -1
  62. package/dist-cjs/renderer/index.js +0 -67
  63. package/dist-cjs/renderer/index.js.map +0 -1
  64. package/dist-cjs/resolvers/index.js +0 -38
  65. package/dist-cjs/resolvers/index.js.map +0 -1
  66. package/dist-cjs/transform/index.js +0 -44
  67. package/dist-cjs/transform/index.js.map +0 -1
  68. package/dist-cjs/types/index.js +0 -3
  69. package/dist-cjs/types/index.js.map +0 -1
  70. package/dist-cjs/validate/index.js +0 -56
  71. package/dist-cjs/validate/index.js.map +0 -1
  72. package/dist-es/auth/index.d.ts +0 -2
  73. package/dist-es/auth/index.js +0 -38
  74. package/dist-es/auth/index.js.map +0 -1
  75. package/dist-es/aws/aws_lambda_helper.d.ts +0 -5
  76. package/dist-es/aws/aws_lambda_helper.js +0 -60
  77. package/dist-es/aws/aws_lambda_helper.js.map +0 -1
  78. package/dist-es/aws/aws_s3_helper.d.ts +0 -0
  79. package/dist-es/aws/aws_s3_helper.js +0 -243
  80. package/dist-es/aws/aws_s3_helper.js.map +0 -1
  81. package/dist-es/aws/data_models.d.ts +0 -21
  82. package/dist-es/aws/data_models.js +0 -2
  83. package/dist-es/aws/data_models.js.map +0 -1
  84. package/dist-es/aws/index.d.ts +0 -1
  85. package/dist-es/aws/index.js +0 -3
  86. package/dist-es/aws/index.js.map +0 -1
  87. package/dist-es/commander/index.d.ts +0 -33
  88. package/dist-es/commander/index.js +0 -262
  89. package/dist-es/commander/index.js.map +0 -1
  90. package/dist-es/constants/index.d.ts +0 -6
  91. package/dist-es/constants/index.js +0 -86
  92. package/dist-es/constants/index.js.map +0 -1
  93. package/dist-es/contents/index.d.ts +0 -3
  94. package/dist-es/contents/index.js +0 -32
  95. package/dist-es/contents/index.js.map +0 -1
  96. package/dist-es/files/index.d.ts +0 -2
  97. package/dist-es/files/index.js +0 -26
  98. package/dist-es/files/index.js.map +0 -1
  99. package/dist-es/graphql/index.d.ts +0 -38
  100. package/dist-es/graphql/index.js +0 -357
  101. package/dist-es/graphql/index.js.map +0 -1
  102. package/dist-es/headers/index.d.ts +0 -12
  103. package/dist-es/headers/index.js +0 -91
  104. package/dist-es/headers/index.js.map +0 -1
  105. package/dist-es/images/index.d.ts +0 -4
  106. package/dist-es/images/index.js +0 -12
  107. package/dist-es/images/index.js.map +0 -1
  108. package/dist-es/index.d.ts +0 -14
  109. package/dist-es/index.js +0 -17
  110. package/dist-es/index.js.map +0 -1
  111. package/dist-es/json/index.d.ts +0 -7
  112. package/dist-es/json/index.js +0 -144
  113. package/dist-es/json/index.js.map +0 -1
  114. package/dist-es/package.json +0 -3
  115. package/dist-es/page_context/index.js +0 -529
  116. package/dist-es/page_context/index.js.map +0 -1
  117. package/dist-es/redirect/index.d.ts +0 -2
  118. package/dist-es/redirect/index.js +0 -16
  119. package/dist-es/redirect/index.js.map +0 -1
  120. package/dist-es/renderer/index.d.ts +0 -9
  121. package/dist-es/renderer/index.js +0 -61
  122. package/dist-es/renderer/index.js.map +0 -1
  123. package/dist-es/resolvers/index.d.ts +0 -11
  124. package/dist-es/resolvers/index.js +0 -34
  125. package/dist-es/resolvers/index.js.map +0 -1
  126. package/dist-es/transform/index.d.ts +0 -2
  127. package/dist-es/transform/index.js +0 -39
  128. package/dist-es/transform/index.js.map +0 -1
  129. package/dist-es/types/index.d.ts +0 -39
  130. package/dist-es/types/index.js +0 -2
  131. package/dist-es/types/index.js.map +0 -1
  132. package/dist-es/validate/index.d.ts +0 -5
  133. package/dist-es/validate/index.js +0 -48
  134. package/dist-es/validate/index.js.map +0 -1
  135. package/dist-types/auth/index.d.ts +0 -2
  136. package/dist-types/aws/aws_lambda_helper.d.ts +0 -5
  137. package/dist-types/aws/aws_s3_helper.d.ts +0 -0
  138. package/dist-types/aws/data_models.d.ts +0 -21
  139. package/dist-types/aws/index.d.ts +0 -1
  140. package/dist-types/constants/index.d.ts +0 -6
  141. package/dist-types/contents/index.d.ts +0 -3
  142. package/dist-types/files/index.d.ts +0 -2
  143. package/dist-types/graphql/index.d.ts +0 -38
  144. package/dist-types/headers/index.d.ts +0 -12
  145. package/dist-types/images/index.d.ts +0 -4
  146. package/dist-types/index.d.ts +0 -14
  147. package/dist-types/json/index.d.ts +0 -7
  148. package/dist-types/page_context/index.d.ts +0 -248
  149. package/dist-types/redirect/index.d.ts +0 -2
  150. package/dist-types/renderer/index.d.ts +0 -9
  151. package/dist-types/resolvers/index.d.ts +0 -11
  152. package/dist-types/transform/index.d.ts +0 -2
  153. package/dist-types/types/index.d.ts +0 -39
  154. package/dist-types/validate/index.d.ts +0 -5
  155. /package/{dist-cjs → dist}/auth/index.d.ts +0 -0
  156. /package/{dist-cjs → dist}/aws/aws_lambda_helper.d.ts +0 -0
  157. /package/{dist-cjs → dist}/aws/data_models.d.ts +0 -0
  158. /package/{dist-cjs → dist}/aws/index.d.ts +0 -0
  159. /package/{dist-cjs → dist}/contents/index.d.ts +0 -0
  160. /package/{dist-cjs → dist}/files/index.d.ts +0 -0
  161. /package/{dist-cjs → dist}/graphql/index.d.ts +0 -0
  162. /package/{dist-cjs → dist}/images/index.d.ts +0 -0
  163. /package/{dist-cjs → dist}/json/index.d.ts +0 -0
  164. /package/{dist-cjs → dist}/redirect/index.d.ts +0 -0
  165. /package/{dist-cjs → dist}/resolvers/index.d.ts +0 -0
  166. /package/{dist-cjs → dist}/transform/index.d.ts +0 -0
  167. /package/{dist-cjs → dist}/types/index.d.ts +0 -0
@@ -1,12 +1,10 @@
1
+ import { Currency } from '../constants';
1
2
  export declare const defaultHeaders: any;
2
3
  export declare const getHeaders: (ctx: any) => any;
3
4
  export declare const setHeaders: (ctx: any, _headers: any) => void;
4
- export declare const getLastActivity: (ctx: any) => void;
5
- export declare const setLastActivity: (ctx: any) => void;
6
- export declare const flushLastActivity: (ctx: any) => void;
7
5
  export declare const getWorkspace: (ctx: any) => string;
8
6
  export declare const setWorkspace: (ctx: any, ws: string) => void;
9
7
  export declare const flushWorkspace: (ctx: any) => void;
10
8
  export declare const flushAll: (ctx: any) => void;
11
- export declare const setCurrency: (ctx: any, currency: JSON) => void;
9
+ export declare const setCurrency: (ctx: any, currency: Currency | JSON) => void;
12
10
  export declare const getCurrency: (ctx: any) => any;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ defaultHeaders: function() {
13
+ return defaultHeaders;
14
+ },
15
+ flushAll: function() {
16
+ return flushAll;
17
+ },
18
+ flushWorkspace: function() {
19
+ return flushWorkspace;
20
+ },
21
+ getCurrency: function() {
22
+ return getCurrency;
23
+ },
24
+ getHeaders: function() {
25
+ return getHeaders;
26
+ },
27
+ getWorkspace: function() {
28
+ return getWorkspace;
29
+ },
30
+ setCurrency: function() {
31
+ return setCurrency;
32
+ },
33
+ setHeaders: function() {
34
+ return setHeaders;
35
+ },
36
+ setWorkspace: function() {
37
+ return setWorkspace;
38
+ }
39
+ });
40
+ const _nookies = require("nookies");
41
+ function _define_property(obj, key, value) {
42
+ if (key in obj) {
43
+ Object.defineProperty(obj, key, {
44
+ value: value,
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true
48
+ });
49
+ } else {
50
+ obj[key] = value;
51
+ }
52
+ return obj;
53
+ }
54
+ function _object_spread(target) {
55
+ for(var i = 1; i < arguments.length; i++){
56
+ var source = arguments[i] != null ? arguments[i] : {};
57
+ var ownKeys = Object.keys(source);
58
+ if (typeof Object.getOwnPropertySymbols === "function") {
59
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
60
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
61
+ }));
62
+ }
63
+ ownKeys.forEach(function(key) {
64
+ _define_property(target, key, source[key]);
65
+ });
66
+ }
67
+ return target;
68
+ }
69
+ function ownKeys(object, enumerableOnly) {
70
+ var keys = Object.keys(object);
71
+ if (Object.getOwnPropertySymbols) {
72
+ var symbols = Object.getOwnPropertySymbols(object);
73
+ if (enumerableOnly) {
74
+ symbols = symbols.filter(function(sym) {
75
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
76
+ });
77
+ }
78
+ keys.push.apply(keys, symbols);
79
+ }
80
+ return keys;
81
+ }
82
+ function _object_spread_props(target, source) {
83
+ source = source != null ? source : {};
84
+ if (Object.getOwnPropertyDescriptors) {
85
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
86
+ } else {
87
+ ownKeys(Object(source)).forEach(function(key) {
88
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
89
+ });
90
+ }
91
+ return target;
92
+ }
93
+ const defaultHeaders = {
94
+ 'bundle-name': '',
95
+ cur: {
96
+ _id: '5e8c8dfdfca1360007d7b654',
97
+ value: '5e8c8dfdfca1360007d7b654',
98
+ code: 'usd',
99
+ namePlural: 'us dollars',
100
+ symbol: '$'
101
+ },
102
+ hl: 'en',
103
+ 'is-explain': true,
104
+ 'last-activity': 0
105
+ };
106
+ const getHeaders = (ctx)=>{
107
+ let _headers = (0, _nookies.parseCookies)(ctx)['fixefy:headers'];
108
+ _headers = _headers && typeof _headers === 'string' ? JSON.parse(_headers) : typeof _headers === 'object' ? _headers : {};
109
+ const headers = _object_spread_props(_object_spread({}, _headers, defaultHeaders), {
110
+ ws: getWorkspace(ctx),
111
+ // mero: getMero(ctx),
112
+ cur: getCurrency(ctx)._id
113
+ });
114
+ return headers;
115
+ };
116
+ const setHeaders = (ctx, _headers)=>{
117
+ typeof _headers === 'string' ? (0, _nookies.setCookie)(ctx, 'fixefy:headers', _object_spread({}, JSON.parse(_headers)), {
118
+ maxAge: 7 * 24 * 60 * 60,
119
+ path: '/'
120
+ }) : (0, _nookies.setCookie)(ctx, 'fixefy:headers', _object_spread({}, _headers), {
121
+ maxAge: 7 * 24 * 60 * 60,
122
+ path: '/'
123
+ });
124
+ };
125
+ const getWorkspace = (ctx)=>{
126
+ var _parseCookies_ws;
127
+ const rv = (_parseCookies_ws = (0, _nookies.parseCookies)(ctx)['ws']) !== null && _parseCookies_ws !== void 0 ? _parseCookies_ws : defaultHeaders['ws'];
128
+ return rv;
129
+ };
130
+ const setWorkspace = (ctx, ws)=>{
131
+ (0, _nookies.setCookie)(ctx, 'ws', ws, {
132
+ maxAge: 7 * 24 * 60 * 60,
133
+ path: '/'
134
+ });
135
+ };
136
+ const flushWorkspace = (ctx)=>{
137
+ (0, _nookies.destroyCookie)(ctx, 'ws', {
138
+ path: '/'
139
+ });
140
+ };
141
+ const flushAll = (ctx)=>{
142
+ // flushLastActivity(ctx)
143
+ // flushMero(ctx);
144
+ flushWorkspace(ctx);
145
+ };
146
+ const setCurrency = (ctx, currency)=>{
147
+ (0, _nookies.setCookie)(ctx, 'cur', JSON.stringify(currency), {
148
+ maxAge: 7 * 24 * 60 * 60,
149
+ path: '/'
150
+ });
151
+ };
152
+ const getCurrency = (ctx)=>{
153
+ var _parseCookies_cur;
154
+ const cur = (_parseCookies_cur = (0, _nookies.parseCookies)(ctx)['cur']) !== null && _parseCookies_cur !== void 0 ? _parseCookies_cur : defaultHeaders['cur'];
155
+ if (cur) {
156
+ if (cur === 'usd' || cur === 'eur') {
157
+ setCurrency(ctx, defaultHeaders['cur']);
158
+ }
159
+ return typeof cur === 'string' ? JSON.parse(cur) : cur;
160
+ }
161
+ };
@@ -0,0 +1,18 @@
1
+ // import React from 'react'
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "imageLoader", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return imageLoader;
10
+ }
11
+ });
12
+ const imageLoader = ({ src, root })=>{
13
+ const transformedSrc = src.split('/');
14
+ transformedSrc.splice(transformedSrc.length - 1, 1, transformedSrc[transformedSrc.length - 1].split(/(?=[A-Z])/).join('_').toLowerCase());
15
+ const url = transformedSrc.join('/');
16
+ // @ts-ignore
17
+ return `${root}${url}`;
18
+ };
@@ -2,12 +2,15 @@ export * from './auth';
2
2
  export * from './aws';
3
3
  export * from './commander';
4
4
  export * from './constants';
5
+ export * from './contents';
6
+ export * from './files';
5
7
  export * from './graphql';
6
8
  export * from './headers';
7
9
  export * from './images';
8
10
  export * from './json';
9
11
  export * from './page_context';
10
12
  export * from './redirect';
13
+ export * from './renderer';
11
14
  export * from './types';
12
15
  export * from './validate';
13
16
  import getPageContext from './page_context';
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getPageContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _page_context.default;
9
+ }
10
+ });
11
+ _export_star(require("./auth"), exports);
12
+ _export_star(require("./aws"), exports);
13
+ _export_star(require("./commander"), exports);
14
+ _export_star(require("./constants"), exports);
15
+ _export_star(require("./contents"), exports);
16
+ _export_star(require("./files"), exports);
17
+ _export_star(require("./graphql"), exports);
18
+ _export_star(require("./headers"), exports);
19
+ _export_star(require("./images"), exports);
20
+ _export_star(require("./json"), exports);
21
+ const _page_context = /*#__PURE__*/ _interop_require_default(_export_star(require("./page_context"), exports));
22
+ _export_star(require("./redirect"), exports);
23
+ _export_star(require("./renderer"), exports);
24
+ _export_star(require("./types"), exports);
25
+ _export_star(require("./validate"), exports);
26
+ function _export_star(from, to) {
27
+ Object.keys(from).forEach(function(k) {
28
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
29
+ Object.defineProperty(to, k, {
30
+ enumerable: true,
31
+ get: function() {
32
+ return from[k];
33
+ }
34
+ });
35
+ }
36
+ });
37
+ return from;
38
+ }
39
+ function _interop_require_default(obj) {
40
+ return obj && obj.__esModule ? obj : {
41
+ default: obj
42
+ };
43
+ }
@@ -1,11 +1,40 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setJToken = exports.isResultValid = exports.isNested = exports.isJson = exports.isHasKey = exports.getJPart = exports.getJToken = void 0;
4
- const __1 = require("..");
5
- const getJToken = (jToken, jsonPath, defaultValue) => {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ getJPart: function() {
13
+ return getJPart;
14
+ },
15
+ getJToken: function() {
16
+ return getJToken;
17
+ },
18
+ isHasKey: function() {
19
+ return isHasKey;
20
+ },
21
+ isJson: function() {
22
+ return isJson;
23
+ },
24
+ isNested: function() {
25
+ return isNested;
26
+ },
27
+ isResultValid: function() {
28
+ return isResultValid;
29
+ },
30
+ setJToken: function() {
31
+ return setJToken;
32
+ }
33
+ });
34
+ const _ = require("..");
35
+ const getJToken = (jToken, jsonPath, defaultValue)=>{
6
36
  // input check - if key is invalid - return error
7
- if ((0, __1.isObjectValid)(jToken) === false)
8
- return defaultValue;
37
+ if ((0, _.isObjectValid)(jToken) === false) return defaultValue;
9
38
  // convert indexes to properties
10
39
  jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
11
40
  // strip a leading dot
@@ -16,15 +45,14 @@ const getJToken = (jToken, jsonPath, defaultValue) => {
16
45
  const jsonPathParts = jsonPath.split('.');
17
46
  try {
18
47
  //for ( let i = 0, n = jsonPathParts.length && isContinueLoop; i < n; ++i ) {
19
- for (let i = 0, n = jsonPathParts.length; isContinueLoop && i < n; ++i) {
48
+ for(let i = 0, n = jsonPathParts.length; isContinueLoop && i < n; ++i){
20
49
  currentToken = jsonPathParts[i];
21
50
  if (typeof jToken === 'string') {
22
51
  jToken = JSON.parse(jToken);
23
52
  }
24
53
  if (currentToken in jToken) {
25
54
  jToken = jToken[currentToken];
26
- }
27
- else {
55
+ } else {
28
56
  // if something in the process failed:
29
57
  // 1. set the rv as the default value
30
58
  // 2. stop the loop
@@ -32,17 +60,14 @@ const getJToken = (jToken, jsonPath, defaultValue) => {
32
60
  isContinueLoop = false;
33
61
  }
34
62
  }
35
- }
36
- catch (e) {
63
+ } catch (e) {
37
64
  jToken = 'No Value Found';
38
65
  }
39
66
  return jToken;
40
67
  };
41
- exports.getJToken = getJToken;
42
- const getJPart = (j, jsonPath, defaultValue) => {
68
+ const getJPart = (j, jsonPath, defaultValue)=>{
43
69
  // if key is invalid - return error
44
- if (j == null)
45
- return defaultValue;
70
+ if (j == null) return defaultValue;
46
71
  // convert indexes to properties
47
72
  jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
48
73
  // strip a leading dot
@@ -50,33 +75,29 @@ const getJPart = (j, jsonPath, defaultValue) => {
50
75
  // split path by '.'
51
76
  let _isArrayValid = false, _isStringValid = false, currentPathPart, isLoop = true;
52
77
  const pathParts = jsonPath.split('.');
53
- for (let i = 0, n = pathParts.length; isLoop && i < n; ++i) {
78
+ for(let i = 0, n = pathParts.length; isLoop && i < n; ++i){
54
79
  currentPathPart = pathParts[i];
55
- _isStringValid = (0, __1.isStringValid)(j);
56
- _isArrayValid = (0, __1.isArrayValid)(j);
80
+ _isStringValid = (0, _.isStringValid)(j);
81
+ _isArrayValid = (0, _.isArrayValid)(j);
57
82
  if (_isStringValid === true || _isArrayValid === true) {
58
83
  if (_isStringValid === true) {
59
84
  j = JSON.parse(j);
60
- }
61
- else {
62
- j = j.reduce((acc, cur) => {
63
- const innerJ = (0, exports.getJPart)(cur, pathParts.slice(i).join('.'), defaultValue);
64
- if ((0, __1.isArrayValid)(innerJ)) {
85
+ } else {
86
+ j = j.reduce((acc, cur)=>{
87
+ const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
88
+ if ((0, _.isArrayValid)(innerJ)) {
65
89
  acc.push(...innerJ);
66
- }
67
- else {
90
+ } else {
68
91
  acc.push(innerJ);
69
92
  }
70
93
  return acc;
71
94
  }, []);
72
95
  isLoop = false;
73
96
  }
74
- }
75
- else {
97
+ } else {
76
98
  if (j[currentPathPart] != null && currentPathPart in j) {
77
99
  j = j[currentPathPart];
78
- }
79
- else {
100
+ } else {
80
101
  // if something in the process failed:
81
102
  // 1. set the rv as the default value
82
103
  // 2. stop the loop`
@@ -87,10 +108,9 @@ const getJPart = (j, jsonPath, defaultValue) => {
87
108
  }
88
109
  return j;
89
110
  };
90
- exports.getJPart = getJPart;
91
- const isHasKey = (array, key) => {
111
+ const isHasKey = (array, key)=>{
92
112
  let rv = false, isContinueLoop = true, current_keys;
93
- for (let i = 0; i < array.length && isContinueLoop; ++i) {
113
+ for(let i = 0; i < array.length && isContinueLoop; ++i){
94
114
  current_keys = Object.keys(array[i]);
95
115
  if ((current_keys || []).indexOf(key) > -1) {
96
116
  rv = true;
@@ -99,56 +119,47 @@ const isHasKey = (array, key) => {
99
119
  }
100
120
  return rv;
101
121
  };
102
- exports.isHasKey = isHasKey;
103
- const isJson = (obj) => {
122
+ const isJson = (obj)=>{
104
123
  let objAsString;
105
124
  try {
106
125
  objAsString = JSON.stringify(obj);
107
- }
108
- catch (e) {
126
+ } catch (e) {
109
127
  objAsString = null;
110
128
  }
111
- if (!objAsString || (0, __1.isStringValid)(objAsString) === false)
112
- return false;
129
+ if (!objAsString || (0, _.isStringValid)(objAsString) === false) return false;
113
130
  const rv = (objAsString === null || objAsString === void 0 ? void 0 : objAsString.indexOf('{')) === 0 && (objAsString === null || objAsString === void 0 ? void 0 : objAsString.indexOf('}')) === (objAsString === null || objAsString === void 0 ? void 0 : objAsString.length) - 1;
114
131
  return rv;
115
132
  };
116
- exports.isJson = isJson;
117
- const isNested = (obj) => {
118
- const rv = Object.keys(obj).some((key) => {
133
+ const isNested = (obj)=>{
134
+ const rv = Object.keys(obj).some((key)=>{
119
135
  return obj[key] && typeof obj[key] === 'object';
120
136
  });
121
137
  return rv;
122
138
  };
123
- exports.isNested = isNested;
124
- const isResultValid = (jResult) => {
125
- if ((0, __1.isObjectValid)(jResult) === false)
126
- return false;
127
- const rv = (0, exports.getJPart)(jResult, 'ok', 0);
139
+ const isResultValid = (jResult)=>{
140
+ if ((0, _.isObjectValid)(jResult) === false) return false;
141
+ const rv = getJPart(jResult, 'ok', 0);
128
142
  return !!rv;
129
143
  };
130
- exports.isResultValid = isResultValid;
131
- const setJToken = (jEntity, fieldPathsAndValues) => {
144
+ const setJToken = (jEntity, fieldPathsAndValues)=>{
132
145
  let jCurrentToken, currentPath, pathParts, fieldName;
133
- for (let i = 0; i < fieldPathsAndValues.length; ++i) {
146
+ for(let i = 0; i < fieldPathsAndValues.length; ++i){
134
147
  currentPath = fieldPathsAndValues[i]['json_path'];
135
- if ((0, __1.isStringValid)(currentPath)) {
148
+ if ((0, _.isStringValid)(currentPath)) {
136
149
  fieldName = currentPath;
137
150
  pathParts = currentPath.split('.');
138
- if ((0, __1.isArrayValid)(pathParts)) {
151
+ if ((0, _.isArrayValid)(pathParts)) {
139
152
  fieldName = pathParts[pathParts.length - 1];
140
153
  pathParts = pathParts.splice(0, Math.max(0, pathParts.length - 1));
141
- if ((0, __1.isArrayValid)(pathParts)) {
154
+ if ((0, _.isArrayValid)(pathParts)) {
142
155
  currentPath = pathParts.join('.');
143
156
  }
144
157
  }
145
- jCurrentToken = (0, exports.getJPart)(jEntity, currentPath, null);
146
- if ((0, __1.isObjectValid)(jCurrentToken) || (0, exports.isJson)(jCurrentToken) === false) {
158
+ jCurrentToken = getJPart(jEntity, currentPath, null);
159
+ if ((0, _.isObjectValid)(jCurrentToken) || isJson(jCurrentToken) === false) {
147
160
  jCurrentToken = jEntity;
148
161
  }
149
162
  jCurrentToken[fieldName] = fieldPathsAndValues[i]['value'];
150
163
  }
151
164
  }
152
165
  };
153
- exports.setJToken = setJToken;
154
- //# sourceMappingURL=index.js.map
@@ -45,6 +45,7 @@ declare module '@mui/material/styles' {
45
45
  score: ScorePaletteColorOptions;
46
46
  invoiceAnalysis: InvoiceAnalysisPaletteColorOptions;
47
47
  status: StatusPaletteColorOptions;
48
+ tag: TagPaletteColorOptions;
48
49
  invoiceState: InvoiceStatesPaletteColorOptions;
49
50
  reconcilationState: RecosStatesPaletteColorOptions;
50
51
  trends: TrendsPaletteColorOptions;
@@ -74,6 +75,7 @@ declare module '@mui/material/styles' {
74
75
  trends: TrendsPaletteColorOptions;
75
76
  uploader: UploaderPaletteColorOptions;
76
77
  status: StatusPaletteColorOptions;
78
+ tag: TagPaletteColorOptions;
77
79
  invoiceState: InvoiceStatesPaletteColorOptions;
78
80
  reconcilationState: RecosStatesPaletteColorOptions;
79
81
  snackbar: SnackbarPaletteColorOptions;
@@ -119,6 +121,7 @@ declare module '@mui/material/styles' {
119
121
  high: string;
120
122
  low: string;
121
123
  medium: string;
124
+ marginal: string;
122
125
  }
123
126
  interface UploaderPaletteColorOptions {
124
127
  processing: {
@@ -177,6 +180,17 @@ declare module '@mui/material/styles' {
177
180
  no_pricing: StatusColorOption;
178
181
  pending: StatusColorOption;
179
182
  }
183
+ interface TagPaletteColorOptions {
184
+ approved: StatusColorOption;
185
+ created: StatusColorOption;
186
+ declined: StatusColorOption;
187
+ in_dispute: StatusColorOption;
188
+ in_progress: StatusColorOption;
189
+ paid: StatusColorOption;
190
+ closed: StatusColorOption;
191
+ refunded: StatusColorOption;
192
+ low: StatusColorOption;
193
+ }
180
194
  interface InvoiceStatesPaletteColorOptions {
181
195
  approved: StatusColorOption;
182
196
  created: StatusColorOption;