@fixefy/fixefy-ui-utils 0.2.70 → 0.2.72
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/dist/auth/index.d.ts +1 -1
- package/dist/headers/index.d.ts +1 -1
- package/dist/page_context/index.js +14 -14
- package/package.json +3 -2
- package/dist/fixefy-ui-utils/src/auth/index.js +0 -80
- package/dist/fixefy-ui-utils/src/commander/index.js +0 -391
- package/dist/fixefy-ui-utils/src/constants/index.js +0 -177
- package/dist/fixefy-ui-utils/src/files/index.js +0 -41
- package/dist/fixefy-ui-utils/src/graphql/index.js +0 -375
- package/dist/fixefy-ui-utils/src/headers/index.js +0 -148
- package/dist/fixefy-ui-utils/src/images/index.js +0 -34
- package/dist/fixefy-ui-utils/src/index.js +0 -41
- package/dist/fixefy-ui-utils/src/json/index.js +0 -170
- package/dist/fixefy-ui-utils/src/makeStyles/index.js +0 -23
- package/dist/fixefy-ui-utils/src/page_context/index.js +0 -1000
- package/dist/fixefy-ui-utils/src/redirect/index.js +0 -31
- package/dist/fixefy-ui-utils/src/resolvers/index.js +0 -51
- package/dist/fixefy-ui-utils/src/transform/index.js +0 -96
- package/dist/fixefy-ui-utils/src/types/index.js +0 -4
|
@@ -1,177 +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
|
-
BUCKET_ADDRESS_NAME: function() {
|
|
13
|
-
return BUCKET_ADDRESS_NAME;
|
|
14
|
-
},
|
|
15
|
-
CONSTANT_TEXTS_ADMIN: function() {
|
|
16
|
-
return CONSTANT_TEXTS_ADMIN;
|
|
17
|
-
},
|
|
18
|
-
CONSTANT_TEXTS_APP: function() {
|
|
19
|
-
return CONSTANT_TEXTS_APP;
|
|
20
|
-
},
|
|
21
|
-
ColumnInputTypes: function() {
|
|
22
|
-
return ColumnInputTypes;
|
|
23
|
-
},
|
|
24
|
-
ComponentTypes: function() {
|
|
25
|
-
return ComponentTypes;
|
|
26
|
-
},
|
|
27
|
-
DataTypes: function() {
|
|
28
|
-
return DataTypes;
|
|
29
|
-
},
|
|
30
|
-
EntityTypes: function() {
|
|
31
|
-
return EntityTypes;
|
|
32
|
-
},
|
|
33
|
-
FilterOperatorType: function() {
|
|
34
|
-
return FilterOperatorType;
|
|
35
|
-
},
|
|
36
|
-
HEADERS: function() {
|
|
37
|
-
return HEADERS;
|
|
38
|
-
},
|
|
39
|
-
InputTypes: function() {
|
|
40
|
-
return InputTypes;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const ColumnInputTypes = {
|
|
44
|
-
Array: 'array',
|
|
45
|
-
Avatar: 'avatar',
|
|
46
|
-
Country: 'country',
|
|
47
|
-
Currency: 'currency',
|
|
48
|
-
Date: 'date',
|
|
49
|
-
Done: 'done',
|
|
50
|
-
ID: 'id',
|
|
51
|
-
IncoTerm: 'incoterm',
|
|
52
|
-
Link: 'link',
|
|
53
|
-
Measure: 'measure',
|
|
54
|
-
Number: 'number',
|
|
55
|
-
Percentage: 'percentage',
|
|
56
|
-
Price: 'price',
|
|
57
|
-
Progress: 'progress',
|
|
58
|
-
Score: 'score',
|
|
59
|
-
Status: 'status',
|
|
60
|
-
String: 'string'
|
|
61
|
-
};
|
|
62
|
-
const ComponentTypes = {
|
|
63
|
-
ActionTrey: 'action_trey',
|
|
64
|
-
AsyncDropdown: 'async_dropdown',
|
|
65
|
-
Chip: 'chip',
|
|
66
|
-
clear: 'clear',
|
|
67
|
-
ClickableLabel: 'clickable_label',
|
|
68
|
-
CollapsableDropdown: 'collapsable_dropdown',
|
|
69
|
-
Container: 'container',
|
|
70
|
-
DateRange: 'date_range',
|
|
71
|
-
Dropdown: 'dropdown',
|
|
72
|
-
dropdownOptions: 'dropdownOptions',
|
|
73
|
-
Label: 'label',
|
|
74
|
-
Modal: 'modal',
|
|
75
|
-
RangeSlider: 'range_slider',
|
|
76
|
-
StaticDropdown: 'static_dropdown',
|
|
77
|
-
TableColumn: 'table_column',
|
|
78
|
-
Textfield: 'textfield'
|
|
79
|
-
};
|
|
80
|
-
const DataTypes = {
|
|
81
|
-
// XLSX: "xlsx",
|
|
82
|
-
CSV: 'csv',
|
|
83
|
-
EDI: 'edi',
|
|
84
|
-
JSON: 'json',
|
|
85
|
-
PDF: 'pdf',
|
|
86
|
-
XLS: 'xls',
|
|
87
|
-
XML: 'xml'
|
|
88
|
-
};
|
|
89
|
-
const EntityTypes = {
|
|
90
|
-
Block: 'block',
|
|
91
|
-
Charge: 'charge',
|
|
92
|
-
Contract: 'contract',
|
|
93
|
-
Event: 'event',
|
|
94
|
-
Metadata: 'metadata',
|
|
95
|
-
Notification: 'notification',
|
|
96
|
-
Pricing: 'pricing',
|
|
97
|
-
Service: 'service',
|
|
98
|
-
Structure: 'structure',
|
|
99
|
-
Transaction: 'transaction',
|
|
100
|
-
Transmission: 'transmission',
|
|
101
|
-
User: 'user',
|
|
102
|
-
Workspace: 'workspace'
|
|
103
|
-
};
|
|
104
|
-
const FilterOperatorType = {
|
|
105
|
-
Contains: 'contains',
|
|
106
|
-
EndsWith: 'endsWith',
|
|
107
|
-
Equals: 'equals',
|
|
108
|
-
GreaterThan: '>',
|
|
109
|
-
GreaterThanEqual: '>=',
|
|
110
|
-
In: 'in',
|
|
111
|
-
Is: 'is',
|
|
112
|
-
IsAfter: 'after',
|
|
113
|
-
IsBefore: 'before',
|
|
114
|
-
IsNot: 'not',
|
|
115
|
-
LessThan: '<',
|
|
116
|
-
LessThanEqual: '<=',
|
|
117
|
-
NotContains: 'NotContains',
|
|
118
|
-
NotIn: 'notIn',
|
|
119
|
-
StartsWith: 'startsWith'
|
|
120
|
-
};
|
|
121
|
-
const InputTypes = {
|
|
122
|
-
Currency: 'currency',
|
|
123
|
-
Date: 'date',
|
|
124
|
-
Link: 'link',
|
|
125
|
-
Password: 'password',
|
|
126
|
-
Percent: 'percent',
|
|
127
|
-
Text: 'text'
|
|
128
|
-
};
|
|
129
|
-
var HEADERS;
|
|
130
|
-
(function(HEADERS) {
|
|
131
|
-
HEADERS["OPERATION"] = "operation";
|
|
132
|
-
HEADERS["IS_SINGLE_REQUEST"] = "is-single-request";
|
|
133
|
-
HEADERS["END_OPERATION"] = "end-operation";
|
|
134
|
-
HEADERS["START_OPERATION"] = "start-operation";
|
|
135
|
-
HEADERS["IS_USE_CACHE_FOR_RULES"] = "is-use-cache-for-rules";
|
|
136
|
-
HEADERS["INVOICE_CREATE"] = "invoice-create";
|
|
137
|
-
HEADERS["INVOICE_CALC"] = "invoice-calc";
|
|
138
|
-
HEADERS["IN_MEMORY"] = "in-memory";
|
|
139
|
-
HEADERS["IS_SANDBOX"] = "is-sandbox";
|
|
140
|
-
HEADERS["MERO"] = "mero";
|
|
141
|
-
HEADERS["PRE_PROC"] = "pre-proc";
|
|
142
|
-
})(HEADERS || (HEADERS = {}));
|
|
143
|
-
var CONSTANT_TEXTS_APP;
|
|
144
|
-
(function(CONSTANT_TEXTS_APP) {
|
|
145
|
-
CONSTANT_TEXTS_APP["NOT_RESULT_SEARCH"] = "Sorry, we couldn’t find any results";
|
|
146
|
-
CONSTANT_TEXTS_APP["NO_ORIGINAL_DOCUMENT"] = "Sorry, there is no original document available for preview.";
|
|
147
|
-
CONSTANT_TEXTS_APP["NO_SUPPORTING_DOCUMENT"] = "Apologies, but there are no supporting documents available for preview for this invoice.";
|
|
148
|
-
CONSTANT_TEXTS_APP["INFO"] = "info";
|
|
149
|
-
CONSTANT_TEXTS_APP["INVOICE"] = "Invoice";
|
|
150
|
-
CONSTANT_TEXTS_APP["CHARGE"] = "Charge";
|
|
151
|
-
CONSTANT_TEXTS_APP["GO_BACK"] = "Go Back";
|
|
152
|
-
})(CONSTANT_TEXTS_APP || (CONSTANT_TEXTS_APP = {}));
|
|
153
|
-
var BUCKET_ADDRESS_NAME;
|
|
154
|
-
(function(BUCKET_ADDRESS_NAME) {
|
|
155
|
-
BUCKET_ADDRESS_NAME["EVIDENCE"] = "evidence";
|
|
156
|
-
BUCKET_ADDRESS_NAME["SELLER_EVIDENCE"] = "seller-evidence";
|
|
157
|
-
BUCKET_ADDRESS_NAME["INVOICE"] = "inv-org";
|
|
158
|
-
BUCKET_ADDRESS_NAME["REF_TABLE"] = "reftbl-org";
|
|
159
|
-
BUCKET_ADDRESS_NAME["CREDIT_NOTE"] = "creditnote-org";
|
|
160
|
-
BUCKET_ADDRESS_NAME["REPORT"] = "reports";
|
|
161
|
-
BUCKET_ADDRESS_NAME["REBILL"] = "inv-rebill";
|
|
162
|
-
})(BUCKET_ADDRESS_NAME || (BUCKET_ADDRESS_NAME = {}));
|
|
163
|
-
var CONSTANT_TEXTS_ADMIN;
|
|
164
|
-
(function(CONSTANT_TEXTS_ADMIN) {
|
|
165
|
-
CONSTANT_TEXTS_ADMIN["PROCESSING"] = "Processing ... ";
|
|
166
|
-
CONSTANT_TEXTS_ADMIN["INFO"] = "info";
|
|
167
|
-
CONSTANT_TEXTS_ADMIN["SUCCESS"] = "success";
|
|
168
|
-
CONSTANT_TEXTS_ADMIN["ERROR"] = "error";
|
|
169
|
-
CONSTANT_TEXTS_ADMIN["WE_DELETED_YOUR_DATA_SUCCESSFULLY"] = "We deleted your Data successfully because your last job was a miserable failure and a complete disgrace. At least we know how to do our job.";
|
|
170
|
-
CONSTANT_TEXTS_ADMIN["FINALLY_SOMETHING_IS_MOVING_HERE"] = "Finally, something is moving here. We have executed your job now. A thank you would be nice.";
|
|
171
|
-
CONSTANT_TEXTS_ADMIN["TABLE_CREATED"] = "Table Created, Great Success!!";
|
|
172
|
-
CONSTANT_TEXTS_ADMIN["GREAT_SUCCESS"] = "Great Success!";
|
|
173
|
-
CONSTANT_TEXTS_ADMIN["CANT_STOP_DOING_THOSE_ERRORS"] = "Can't stop doing those errors ah? shit!";
|
|
174
|
-
CONSTANT_TEXTS_ADMIN["GREAT_FAILURE"] = "Great Failure - ze germanz are coming!";
|
|
175
|
-
CONSTANT_TEXTS_ADMIN["NO_FILE_TYPE_FOUND"] = "No File Type Found";
|
|
176
|
-
CONSTANT_TEXTS_ADMIN["INVALID_FILE_TYPE"] = "Unknown File Type";
|
|
177
|
-
})(CONSTANT_TEXTS_ADMIN || (CONSTANT_TEXTS_ADMIN = {}));
|
|
@@ -1,41 +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
|
-
convertFileSize: function() {
|
|
13
|
-
return convertFileSize;
|
|
14
|
-
},
|
|
15
|
-
convertFileTypeToIcon: function() {
|
|
16
|
-
return convertFileTypeToIcon;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const convertFileSize = (fileSize)=>{
|
|
20
|
-
if (fileSize < 10000) {
|
|
21
|
-
return `${(fileSize / 1000).toFixed(1)} KB`;
|
|
22
|
-
} else if (fileSize < 10000000) {
|
|
23
|
-
return `${(fileSize / 1000000).toFixed(1)} MB`;
|
|
24
|
-
} else {
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const convertFileTypeToIcon = (fileType)=>{
|
|
29
|
-
switch(fileType){
|
|
30
|
-
case 'text/csv':
|
|
31
|
-
return 'uploader/file_type_csv.svg';
|
|
32
|
-
case 'text/xml':
|
|
33
|
-
return 'uploader/file_type_xml.svg';
|
|
34
|
-
case 'text/json':
|
|
35
|
-
return 'uploader/file_type_json.svg';
|
|
36
|
-
case 'text/xls':
|
|
37
|
-
return 'uploader/file_type_xls.svg';
|
|
38
|
-
default:
|
|
39
|
-
return 'uploader/file_type_csv.svg';
|
|
40
|
-
}
|
|
41
|
-
};
|
|
@@ -1,375 +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
|
-
draggableTypes: function() {
|
|
13
|
-
return draggableTypes;
|
|
14
|
-
},
|
|
15
|
-
getFields: function() {
|
|
16
|
-
return getFields;
|
|
17
|
-
},
|
|
18
|
-
getFieldsStringified: function() {
|
|
19
|
-
return getFieldsStringified;
|
|
20
|
-
},
|
|
21
|
-
getOperationObjectFromSchema: function() {
|
|
22
|
-
return getOperationObjectFromSchema;
|
|
23
|
-
},
|
|
24
|
-
getOperationTypeForMutation: function() {
|
|
25
|
-
return getOperationTypeForMutation;
|
|
26
|
-
},
|
|
27
|
-
getTypeKind: function() {
|
|
28
|
-
return getTypeKind;
|
|
29
|
-
},
|
|
30
|
-
getTypeName: function() {
|
|
31
|
-
return getTypeName;
|
|
32
|
-
},
|
|
33
|
-
getVariablesKeys: function() {
|
|
34
|
-
return getVariablesKeys;
|
|
35
|
-
},
|
|
36
|
-
insertNewVariable: function() {
|
|
37
|
-
return insertNewVariable;
|
|
38
|
-
},
|
|
39
|
-
operationTypes: function() {
|
|
40
|
-
return operationTypes;
|
|
41
|
-
},
|
|
42
|
-
parseInputDataToDataObject: function() {
|
|
43
|
-
return parseInputDataToDataObject;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const _pluralize = /*#__PURE__*/ _interop_require_default(require("pluralize"));
|
|
47
|
-
function _define_property(obj, key, value) {
|
|
48
|
-
if (key in obj) {
|
|
49
|
-
Object.defineProperty(obj, key, {
|
|
50
|
-
value: value,
|
|
51
|
-
enumerable: true,
|
|
52
|
-
configurable: true,
|
|
53
|
-
writable: true
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
obj[key] = value;
|
|
57
|
-
}
|
|
58
|
-
return obj;
|
|
59
|
-
}
|
|
60
|
-
function _interop_require_default(obj) {
|
|
61
|
-
return obj && obj.__esModule ? obj : {
|
|
62
|
-
default: obj
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function _object_spread(target) {
|
|
66
|
-
for(var i = 1; i < arguments.length; i++){
|
|
67
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
68
|
-
var ownKeys = Object.keys(source);
|
|
69
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
70
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
71
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
ownKeys.forEach(function(key) {
|
|
75
|
-
_define_property(target, key, source[key]);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return target;
|
|
79
|
-
}
|
|
80
|
-
function ownKeys(object, enumerableOnly) {
|
|
81
|
-
var keys = Object.keys(object);
|
|
82
|
-
if (Object.getOwnPropertySymbols) {
|
|
83
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
84
|
-
if (enumerableOnly) {
|
|
85
|
-
symbols = symbols.filter(function(sym) {
|
|
86
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
keys.push.apply(keys, symbols);
|
|
90
|
-
}
|
|
91
|
-
return keys;
|
|
92
|
-
}
|
|
93
|
-
function _object_spread_props(target, source) {
|
|
94
|
-
source = source != null ? source : {};
|
|
95
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
96
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
97
|
-
} else {
|
|
98
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
99
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return target;
|
|
103
|
-
}
|
|
104
|
-
const operationTypes = {
|
|
105
|
-
MUTATIONS: {
|
|
106
|
-
CREATE: 'mutations.create',
|
|
107
|
-
DELETE: 'mutations.delete',
|
|
108
|
-
UPDATE: 'mutations.update',
|
|
109
|
-
ACTION: 'mutations.action'
|
|
110
|
-
},
|
|
111
|
-
QUERIES: 'queries',
|
|
112
|
-
SUBSCRIPTIONS: 'subscriptions'
|
|
113
|
-
};
|
|
114
|
-
const draggableTypes = {
|
|
115
|
-
ACTION: 'action',
|
|
116
|
-
ENTITY: 'entity',
|
|
117
|
-
FRAGMENT: 'fragment',
|
|
118
|
-
VARIABLES: 'variables'
|
|
119
|
-
};
|
|
120
|
-
const getFields = ({ arg })=>arg.type.getFields ? arg.type.getFields() : arg.type._nameLookup ? arg.type._nameLookup : arg.type.ofType && arg.type.ofType.getFields ? arg.type.ofType.getFields() : arg.type.ofType && arg.type.ofType.ofType && arg.type.ofType.ofType.getFields ? arg.type.ofType.ofType.getFields() : {};
|
|
121
|
-
const getFieldsStringified = ({ arg })=>arg.type.getFields ? Object.keys(arg.type.getFields()) : arg.type.getValues ? Object.keys(arg.type.getValues()) : arg.type.ofType && arg.type.ofType.getFields ? Object.keys(arg.type.ofType.getFields()) : [];
|
|
122
|
-
const getTypeKind = (object)=>{
|
|
123
|
-
return object && object.astNode && object.astNode.type && object.astNode.type.kind ? object.astNode.type.kind : object && object.astNode && object.astNode.kind ? object.astNode.kind : undefined;
|
|
124
|
-
};
|
|
125
|
-
const getTypeName = (object)=>{
|
|
126
|
-
return object && object.type ? object.type.ofType ? object.type.ofType.name : object && object.type.name && object.type.name : object.astNode && object.astNode.name;
|
|
127
|
-
};
|
|
128
|
-
const getOperationObjectFromSchema = ({ operationName, schema })=>{
|
|
129
|
-
const queries = schema.getQueryType().getFields();
|
|
130
|
-
const mutations = schema.getMutationType().getFields();
|
|
131
|
-
const subscriptions = schema.getSubscriptionType().getFields();
|
|
132
|
-
let operationType;
|
|
133
|
-
let rv;
|
|
134
|
-
if (operationName in mutations) {
|
|
135
|
-
operationType = getOperationTypeForMutation({
|
|
136
|
-
operationName
|
|
137
|
-
});
|
|
138
|
-
rv = mutations[operationName];
|
|
139
|
-
} else if (operationName in queries) {
|
|
140
|
-
operationType = operationTypes.QUERIES;
|
|
141
|
-
rv = queries[operationName];
|
|
142
|
-
} else if (operationName in subscriptions) {
|
|
143
|
-
operationType = operationTypes.SUBSCRIPTIONS;
|
|
144
|
-
rv = subscriptions[operationName];
|
|
145
|
-
}
|
|
146
|
-
return [
|
|
147
|
-
rv,
|
|
148
|
-
operationType
|
|
149
|
-
];
|
|
150
|
-
};
|
|
151
|
-
const getOperationTypeForMutation = ({ operationName })=>{
|
|
152
|
-
let operationType;
|
|
153
|
-
if (operationName.includes('create')) {
|
|
154
|
-
operationType = operationTypes.MUTATIONS.CREATE;
|
|
155
|
-
} else if (operationName.includes('update')) {
|
|
156
|
-
operationType = operationTypes.MUTATIONS.UPDATE;
|
|
157
|
-
} else if (operationName.includes('delete')) {
|
|
158
|
-
operationType = operationTypes.MUTATIONS.DELETE;
|
|
159
|
-
} else {
|
|
160
|
-
operationType = operationTypes.MUTATIONS.ACTION;
|
|
161
|
-
}
|
|
162
|
-
return operationType;
|
|
163
|
-
};
|
|
164
|
-
const getVariablesKeys = ({ variables, operationType })=>{
|
|
165
|
-
let obj;
|
|
166
|
-
let data;
|
|
167
|
-
let where;
|
|
168
|
-
if (variables && variables != '') {
|
|
169
|
-
variables = JSON.parse(variables);
|
|
170
|
-
switch(operationType){
|
|
171
|
-
case operationTypes.QUERIES:
|
|
172
|
-
where = variables && variables.where;
|
|
173
|
-
return where && typeof where === 'object' ? Object.keys(where) : undefined;
|
|
174
|
-
case operationTypes.MUTATIONS.CREATE:
|
|
175
|
-
data = variables && variables['data'];
|
|
176
|
-
return data && Array.isArray(data) ? Object.keys(data[0]) : typeof data === 'object' ? Object.keys(data) : undefined;
|
|
177
|
-
default:
|
|
178
|
-
obj = variables && variables['data'] || variables.where;
|
|
179
|
-
return obj && Array.isArray(obj) && obj.length > 0 ? Object.keys(obj[0]) : typeof obj === 'object' ? Object.keys(obj) : undefined;
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
return {};
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const insertNewVariable = ({ operationName, schema, key, value, _variables, action })=>{
|
|
186
|
-
// get raw action from schema
|
|
187
|
-
const [raw] = getOperationObjectFromSchema({
|
|
188
|
-
operationName,
|
|
189
|
-
schema
|
|
190
|
-
});
|
|
191
|
-
// loop through the _variables keys
|
|
192
|
-
Object.keys(_variables).forEach((upper_key)=>{
|
|
193
|
-
// get the args and loop through the arguments
|
|
194
|
-
if (raw) {
|
|
195
|
-
parseArgs({
|
|
196
|
-
raw,
|
|
197
|
-
_variables,
|
|
198
|
-
upper_key,
|
|
199
|
-
key,
|
|
200
|
-
action,
|
|
201
|
-
value
|
|
202
|
-
});
|
|
203
|
-
} else {
|
|
204
|
-
throw `No Schema Action - '${operationName} - Go check the schema again'`;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
const parseInputDataToDataObject = ({ key, value, parent, method, list, state })=>{
|
|
209
|
-
let rv = state;
|
|
210
|
-
const type = typeof value;
|
|
211
|
-
switch(type){
|
|
212
|
-
case 'string':
|
|
213
|
-
case 'number':
|
|
214
|
-
case 'boolean':
|
|
215
|
-
case 'bigint':
|
|
216
|
-
rv = parent ? _object_spread_props(_object_spread({}, rv), {
|
|
217
|
-
[parent]: _object_spread_props(_object_spread({}, rv[parent]), {
|
|
218
|
-
[method]: _object_spread_props(_object_spread({}, rv[parent][method]), {
|
|
219
|
-
[key]: value
|
|
220
|
-
})
|
|
221
|
-
})
|
|
222
|
-
}) : _object_spread_props(_object_spread({}, rv), {
|
|
223
|
-
[key]: value
|
|
224
|
-
});
|
|
225
|
-
break;
|
|
226
|
-
case 'object':
|
|
227
|
-
rv = parent ? {
|
|
228
|
-
[parent]: _object_spread_props(_object_spread({}, rv[parent]), {
|
|
229
|
-
[method]: _object_spread({}, rv[parent][method])
|
|
230
|
-
})
|
|
231
|
-
} : _object_spread_props(_object_spread({}, rv), {
|
|
232
|
-
[key]: {
|
|
233
|
-
[method]: list ? value.map(({ id })=>({
|
|
234
|
-
id
|
|
235
|
-
})) : {
|
|
236
|
-
id: value.id
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
return rv;
|
|
243
|
-
};
|
|
244
|
-
/// ================================================================= ///
|
|
245
|
-
/// ============================= LOCAL ============================= ///
|
|
246
|
-
// returns a value of type according to the field
|
|
247
|
-
const buildValue = ({ name, value })=>{
|
|
248
|
-
let rv;
|
|
249
|
-
switch(name){
|
|
250
|
-
case 'Float':
|
|
251
|
-
rv = value || 0.0;
|
|
252
|
-
break;
|
|
253
|
-
case 'Int':
|
|
254
|
-
rv = value || 0;
|
|
255
|
-
break;
|
|
256
|
-
case 'ID':
|
|
257
|
-
rv = value || '000000000000000000000000';
|
|
258
|
-
break;
|
|
259
|
-
case 'String':
|
|
260
|
-
rv = value || '';
|
|
261
|
-
break;
|
|
262
|
-
default:
|
|
263
|
-
rv = name.includes('many') ? {
|
|
264
|
-
connect: [
|
|
265
|
-
{
|
|
266
|
-
id: value || ''
|
|
267
|
-
}
|
|
268
|
-
]
|
|
269
|
-
} : {
|
|
270
|
-
connect: {
|
|
271
|
-
id: value || ''
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
return rv;
|
|
277
|
-
};
|
|
278
|
-
/// the first step in adding new variable from entity draggable
|
|
279
|
-
const parseArgs = ({ raw, _variables, upper_key, key, action, value })=>{
|
|
280
|
-
raw.args.forEach((arg)=>{
|
|
281
|
-
// check if arg.name is equal to the _variables key
|
|
282
|
-
if (upper_key === arg.name) {
|
|
283
|
-
// get all fields keys
|
|
284
|
-
const fields = getFieldsStringified({
|
|
285
|
-
arg
|
|
286
|
-
});
|
|
287
|
-
const fields_obj = getFields({
|
|
288
|
-
arg
|
|
289
|
-
});
|
|
290
|
-
// check if fields exists
|
|
291
|
-
// loop through the fields
|
|
292
|
-
if (fields.length > 0) {
|
|
293
|
-
parseFields({
|
|
294
|
-
fields,
|
|
295
|
-
fields_obj,
|
|
296
|
-
_variables,
|
|
297
|
-
upper_key,
|
|
298
|
-
key,
|
|
299
|
-
action,
|
|
300
|
-
value
|
|
301
|
-
});
|
|
302
|
-
} else {
|
|
303
|
-
// throw `Schema Object/Action Does Not Have Any Fields - '${operationName} - ${getFlower()}'`;
|
|
304
|
-
throw 'Schema Object/Action Does Not Have Any Fields';
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
// if (_exists && raw.args.length > 0 && _exists === false) throw `Schema Object/Action Does Not Support - '${key}'`;
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
/// the second step in adding new variable from entity draggable - take the fields and checks if this key is available / exists than set the entity according the operationType
|
|
311
|
-
const parseFields = ({ fields, fields_obj, key, _variables, upper_key, value, action })=>{
|
|
312
|
-
let _existsInFields = false;
|
|
313
|
-
fields.forEach((field)=>{
|
|
314
|
-
// create a pluralized entity_type value
|
|
315
|
-
const _key = (0, _pluralize.default)(key);
|
|
316
|
-
// check if either the single or the pluralized value exists in the key
|
|
317
|
-
const exists = field.includes(_key.toLowerCase()) || field.includes(key.toLowerCase());
|
|
318
|
-
// if indeed it exists
|
|
319
|
-
if (exists === true) {
|
|
320
|
-
_existsInFields = true;
|
|
321
|
-
// get kind
|
|
322
|
-
const kind = getTypeName(fields_obj[field]);
|
|
323
|
-
// check if mutation or query
|
|
324
|
-
if (action === 'mutation') {
|
|
325
|
-
// check if the value is of type array
|
|
326
|
-
setMutationEntityVariables({
|
|
327
|
-
field,
|
|
328
|
-
kind,
|
|
329
|
-
_variables,
|
|
330
|
-
upper_key,
|
|
331
|
-
value
|
|
332
|
-
});
|
|
333
|
-
} else {
|
|
334
|
-
// check if the string "some" exists 4in the field - meaning it is an array and format it accordingly
|
|
335
|
-
setQueryEntityVariables({
|
|
336
|
-
field,
|
|
337
|
-
kind,
|
|
338
|
-
_variables,
|
|
339
|
-
upper_key,
|
|
340
|
-
value
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
if (_existsInFields === false) // throw `Schema Object/Action Does Not Support - '${key} - ${getFlower()}'`;
|
|
346
|
-
throw `Schema Object/Action Does Not Support - '${key}'`;
|
|
347
|
-
};
|
|
348
|
-
const setMutationEntityVariables = ({ field, kind, _variables, upper_key, value })=>{
|
|
349
|
-
// why to make such tricky code??? better to remove any and set types
|
|
350
|
-
Array.isArray(_variables[upper_key]) ? _variables[upper_key] = _variables[upper_key].map((item)=>_object_spread_props(_object_spread({}, item), {
|
|
351
|
-
[field.toLowerCase()]: buildValue({
|
|
352
|
-
name: kind,
|
|
353
|
-
value
|
|
354
|
-
})
|
|
355
|
-
})) : _variables[upper_key] = _object_spread_props(_object_spread({}, _variables[upper_key]), {
|
|
356
|
-
[field.toLowerCase()]: buildValue({
|
|
357
|
-
name: kind,
|
|
358
|
-
value
|
|
359
|
-
})
|
|
360
|
-
});
|
|
361
|
-
};
|
|
362
|
-
const setQueryEntityVariables = ({ field, _variables, upper_key, value })=>{
|
|
363
|
-
// why to make such tricky code??? better to remove 'any' and set types
|
|
364
|
-
field.includes('some') ? _variables[upper_key] = _object_spread_props(_object_spread({}, _variables[upper_key]), {
|
|
365
|
-
[field]: {
|
|
366
|
-
id_in: [
|
|
367
|
-
value
|
|
368
|
-
]
|
|
369
|
-
}
|
|
370
|
-
}) : _variables[upper_key] = _object_spread_props(_object_spread({}, _variables[upper_key]), {
|
|
371
|
-
[field]: value
|
|
372
|
-
});
|
|
373
|
-
} /// ================================================================= ///
|
|
374
|
-
/// ============================= To Be Built ========================= ///
|
|
375
|
-
;
|