@fixefy/fixefy-ui-utils 0.2.2 → 0.2.3
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.
- package/package.json +1 -1
- package/dist/auth/index.js +0 -89
- package/dist/aws/aws_lambda_helper.js +0 -184
- package/dist/aws/data_models.js +0 -4
- package/dist/aws/index.js +0 -18
- package/dist/commander/index.js +0 -390
- package/dist/constants/index.js +0 -115
- package/dist/contents/index.js +0 -154
- package/dist/files/index.js +0 -41
- package/dist/graphql/index.js +0 -382
- package/dist/headers/index.js +0 -161
- package/dist/images/index.js +0 -18
- package/dist/index.js +0 -44
- package/dist/json/index.js +0 -165
- package/dist/page_context/index.js +0 -764
- package/dist/redirect/index.js +0 -31
- package/dist/renderer/index.js +0 -125
- package/dist/resolvers/index.js +0 -51
- package/dist/transform/index.js +0 -96
- package/dist/types/index.js +0 -4
- package/dist/validate/index.js +0 -68
package/dist/headers/index.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/images/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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("./transform"), exports);
|
|
25
|
-
_export_star(require("./types"), exports);
|
|
26
|
-
_export_star(require("./validate"), exports);
|
|
27
|
-
function _export_star(from, to) {
|
|
28
|
-
Object.keys(from).forEach(function(k) {
|
|
29
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
30
|
-
Object.defineProperty(to, k, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function() {
|
|
33
|
-
return from[k];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return from;
|
|
39
|
-
}
|
|
40
|
-
function _interop_require_default(obj) {
|
|
41
|
-
return obj && obj.__esModule ? obj : {
|
|
42
|
-
default: obj
|
|
43
|
-
};
|
|
44
|
-
}
|
package/dist/json/index.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
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
|
-
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)=>{
|
|
36
|
-
// input check - if key is invalid - return error
|
|
37
|
-
if ((0, _.isObjectValid)(jToken) === false) return defaultValue;
|
|
38
|
-
// convert indexes to properties
|
|
39
|
-
jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
|
|
40
|
-
// strip a leading dot
|
|
41
|
-
jsonPath = jsonPath.replace(/^\./, '');
|
|
42
|
-
// split path by '.'
|
|
43
|
-
let isContinueLoop = true;
|
|
44
|
-
let currentToken;
|
|
45
|
-
const jsonPathParts = jsonPath.split('.');
|
|
46
|
-
try {
|
|
47
|
-
//for ( let i = 0, n = jsonPathParts.length && isContinueLoop; i < n; ++i ) {
|
|
48
|
-
for(let i = 0, n = jsonPathParts.length; isContinueLoop && i < n; ++i){
|
|
49
|
-
currentToken = jsonPathParts[i];
|
|
50
|
-
if (typeof jToken === 'string') {
|
|
51
|
-
jToken = JSON.parse(jToken);
|
|
52
|
-
}
|
|
53
|
-
if (currentToken in jToken) {
|
|
54
|
-
jToken = jToken[currentToken];
|
|
55
|
-
} else {
|
|
56
|
-
// if something in the process failed:
|
|
57
|
-
// 1. set the rv as the default value
|
|
58
|
-
// 2. stop the loop
|
|
59
|
-
jToken = defaultValue;
|
|
60
|
-
isContinueLoop = false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} catch (e) {
|
|
64
|
-
jToken = 'No Value Found';
|
|
65
|
-
}
|
|
66
|
-
return jToken;
|
|
67
|
-
};
|
|
68
|
-
const getJPart = (j, jsonPath, defaultValue)=>{
|
|
69
|
-
// if key is invalid - return error
|
|
70
|
-
if (j == null) return defaultValue;
|
|
71
|
-
// convert indexes to properties
|
|
72
|
-
jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
|
|
73
|
-
// strip a leading dot
|
|
74
|
-
jsonPath = jsonPath.replace(/^\./, '');
|
|
75
|
-
// split path by '.'
|
|
76
|
-
let _isArrayValid = false, _isStringValid = false, currentPathPart, isLoop = true;
|
|
77
|
-
const pathParts = jsonPath.split('.');
|
|
78
|
-
for(let i = 0, n = pathParts.length; isLoop && i < n; ++i){
|
|
79
|
-
currentPathPart = pathParts[i];
|
|
80
|
-
_isStringValid = (0, _.isStringValid)(j);
|
|
81
|
-
_isArrayValid = (0, _.isArrayValid)(j);
|
|
82
|
-
if (_isStringValid === true || _isArrayValid === true) {
|
|
83
|
-
if (_isStringValid === true) {
|
|
84
|
-
j = JSON.parse(j);
|
|
85
|
-
} else {
|
|
86
|
-
j = j.reduce((acc, cur)=>{
|
|
87
|
-
const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
|
|
88
|
-
if ((0, _.isArrayValid)(innerJ)) {
|
|
89
|
-
acc.push(...innerJ);
|
|
90
|
-
} else {
|
|
91
|
-
acc.push(innerJ);
|
|
92
|
-
}
|
|
93
|
-
return acc;
|
|
94
|
-
}, []);
|
|
95
|
-
isLoop = false;
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
if (j[currentPathPart] != null && currentPathPart in j) {
|
|
99
|
-
j = j[currentPathPart];
|
|
100
|
-
} else {
|
|
101
|
-
// if something in the process failed:
|
|
102
|
-
// 1. set the rv as the default value
|
|
103
|
-
// 2. stop the loop`
|
|
104
|
-
j = defaultValue;
|
|
105
|
-
isLoop = false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return j;
|
|
110
|
-
};
|
|
111
|
-
const isHasKey = (array, key)=>{
|
|
112
|
-
let rv = false, isContinueLoop = true, current_keys;
|
|
113
|
-
for(let i = 0; i < array.length && isContinueLoop; ++i){
|
|
114
|
-
current_keys = Object.keys(array[i]);
|
|
115
|
-
if ((current_keys || []).indexOf(key) > -1) {
|
|
116
|
-
rv = true;
|
|
117
|
-
isContinueLoop = false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return rv;
|
|
121
|
-
};
|
|
122
|
-
const isJson = (obj)=>{
|
|
123
|
-
let objAsString;
|
|
124
|
-
try {
|
|
125
|
-
objAsString = JSON.stringify(obj);
|
|
126
|
-
} catch (e) {
|
|
127
|
-
objAsString = null;
|
|
128
|
-
}
|
|
129
|
-
if (!objAsString || (0, _.isStringValid)(objAsString) === false) return false;
|
|
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;
|
|
131
|
-
return rv;
|
|
132
|
-
};
|
|
133
|
-
const isNested = (obj)=>{
|
|
134
|
-
const rv = Object.keys(obj).some((key)=>{
|
|
135
|
-
return obj[key] && typeof obj[key] === 'object';
|
|
136
|
-
});
|
|
137
|
-
return rv;
|
|
138
|
-
};
|
|
139
|
-
const isResultValid = (jResult)=>{
|
|
140
|
-
if ((0, _.isObjectValid)(jResult) === false) return false;
|
|
141
|
-
const rv = getJPart(jResult, 'ok', 0);
|
|
142
|
-
return !!rv;
|
|
143
|
-
};
|
|
144
|
-
const setJToken = (jEntity, fieldPathsAndValues)=>{
|
|
145
|
-
let jCurrentToken, currentPath, pathParts, fieldName;
|
|
146
|
-
for(let i = 0; i < fieldPathsAndValues.length; ++i){
|
|
147
|
-
currentPath = fieldPathsAndValues[i]['json_path'];
|
|
148
|
-
if ((0, _.isStringValid)(currentPath)) {
|
|
149
|
-
fieldName = currentPath;
|
|
150
|
-
pathParts = currentPath.split('.');
|
|
151
|
-
if ((0, _.isArrayValid)(pathParts)) {
|
|
152
|
-
fieldName = pathParts[pathParts.length - 1];
|
|
153
|
-
pathParts = pathParts.splice(0, Math.max(0, pathParts.length - 1));
|
|
154
|
-
if ((0, _.isArrayValid)(pathParts)) {
|
|
155
|
-
currentPath = pathParts.join('.');
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
jCurrentToken = getJPart(jEntity, currentPath, null);
|
|
159
|
-
if ((0, _.isObjectValid)(jCurrentToken) || isJson(jCurrentToken) === false) {
|
|
160
|
-
jCurrentToken = jEntity;
|
|
161
|
-
}
|
|
162
|
-
jCurrentToken[fieldName] = fieldPathsAndValues[i]['value'];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|