@sankhyalabs/sankhyablocks 8.1.0 → 8.2.0-dev.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.
- package/dist/cjs/{ConfigStorage-73e7afff.js → ConfigStorage-12397f18.js} +163 -51
- package/dist/cjs/{DataFetcher-004811c6.js → DataFetcher-f2da1f79.js} +68 -30
- package/dist/cjs/ISave-d68ce3cd.js +8 -0
- package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
- package/dist/cjs/{SnkFormConfigManager-d1f1a222.js → SnkFormConfigManager-13f79e37.js} +19 -21
- package/dist/cjs/auth-fetcher-319a4cb2.js +34 -0
- package/dist/cjs/{dataunit-fetcher-029eafbd.js → dataunit-fetcher-e72068c1.js} +1 -1
- package/dist/cjs/{form-config-fetcher-181767c9.js → form-config-fetcher-5d62ab62.js} +66 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-9a97994a.js → pesquisa-fetcher-8c363096.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +18 -11
- package/dist/cjs/snk-application.cjs.entry.js +51 -73
- package/dist/cjs/snk-attach.cjs.entry.js +7 -13
- package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
- package/dist/cjs/snk-crud.cjs.entry.js +28 -9
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-d5109a08.js → snk-data-unit-80a00ae4.js} +8 -6
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +18 -25
- package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
- package/dist/cjs/snk-filter-bar.cjs.entry.js +14 -17
- package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -15
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -19
- package/dist/cjs/snk-form-config.cjs.entry.js +6 -17
- package/dist/cjs/snk-form-view.cjs.entry.js +6 -1
- package/dist/cjs/snk-form.cjs.entry.js +12 -8
- package/dist/cjs/snk-grid-config.cjs.entry.js +5 -6
- package/dist/cjs/snk-grid.cjs.entry.js +20 -20
- package/dist/cjs/{snk-guides-viewer-aa3e3bfa.js → snk-guides-viewer-a7cd6fda.js} +18 -9
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +13 -16
- package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +22 -80
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
- package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
- package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
- package/dist/collection/components/snk-application/snk-application.js +60 -65
- package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
- package/dist/collection/components/snk-crud/snk-crud.js +63 -8
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +65 -15
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +27 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +66 -30
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +42 -7
- package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +2 -12
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +28 -12
- package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
- package/dist/collection/components/snk-form/snk-form.js +46 -2
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
- package/dist/collection/components/snk-grid/snk-grid.js +110 -16
- package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +43 -9
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +19 -1
- package/dist/collection/lib/configs/ConfigStorage.js +33 -44
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -59
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +39 -30
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
- package/dist/collection/lib/index.js +10 -0
- package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
- package/dist/collection/lib/utils/urlutils.js +29 -0
- package/dist/components/ConfigStorage.js +161 -48
- package/dist/components/DataFetcher.js +68 -30
- package/dist/components/ResourceIDUtils.js +10 -0
- package/dist/components/SnkFormConfigManager.js +17 -19
- package/dist/components/auth-fetcher.js +32 -0
- package/dist/components/form-config-fetcher.js +64 -2
- package/dist/components/snk-actions-button2.js +23 -9
- package/dist/components/snk-application2.js +132 -154
- package/dist/components/snk-attach2.js +1 -8
- package/dist/components/snk-configurator2.js +3 -1
- package/dist/components/snk-crud.js +29 -7
- package/dist/components/snk-data-unit2.js +10 -6
- package/dist/components/snk-detail-view2.js +28 -23
- package/dist/components/snk-entity-list.js +0 -4
- package/dist/components/snk-filter-bar2.js +12 -12
- package/dist/components/snk-filter-detail2.js +2 -12
- package/dist/components/snk-filter-modal-item2.js +5 -16
- package/dist/components/snk-form-config2.js +5 -15
- package/dist/components/snk-form-view2.js +6 -1
- package/dist/components/snk-form.js +9 -2
- package/dist/components/snk-grid-config2.js +4 -2
- package/dist/components/snk-grid2.js +23 -16
- package/dist/components/snk-personalized-filter2.js +11 -11
- package/dist/components/snk-simple-crud2.js +12 -69
- package/dist/components/snk-taskbar2.js +3 -1
- package/dist/esm/{ConfigStorage-19a7260b.js → ConfigStorage-932ab366.js} +162 -49
- package/dist/esm/{DataFetcher-e0fc5549.js → DataFetcher-7e18aa30.js} +68 -30
- package/dist/esm/ISave-4412b20c.js +8 -0
- package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
- package/dist/esm/{SnkFormConfigManager-1a42eb02.js → SnkFormConfigManager-bb9afc3f.js} +19 -21
- package/dist/esm/auth-fetcher-6d9664b7.js +32 -0
- package/dist/esm/{dataunit-fetcher-6a695723.js → dataunit-fetcher-91a4eb82.js} +1 -1
- package/dist/esm/{form-config-fetcher-9e167008.js → form-config-fetcher-aaaa79a6.js} +65 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-9118eb7a.js → pesquisa-fetcher-56b30fb4.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button.entry.js +18 -11
- package/dist/esm/snk-application.entry.js +49 -71
- package/dist/esm/snk-attach.entry.js +3 -9
- package/dist/esm/snk-configurator.entry.js +2 -1
- package/dist/esm/snk-crud.entry.js +28 -9
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-3a0bbfcb.js → snk-data-unit-3ab57d1a.js} +8 -6
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +18 -25
- package/dist/esm/snk-entity-list.entry.js +0 -4
- package/dist/esm/snk-filter-bar.entry.js +14 -17
- package/dist/esm/snk-filter-detail.entry.js +2 -16
- package/dist/esm/snk-filter-modal-item.entry.js +6 -20
- package/dist/esm/snk-form-config.entry.js +7 -18
- package/dist/esm/snk-form-view.entry.js +6 -1
- package/dist/esm/snk-form.entry.js +12 -8
- package/dist/esm/snk-grid-config.entry.js +5 -6
- package/dist/esm/snk-grid.entry.js +20 -20
- package/dist/esm/{snk-guides-viewer-aa386f6e.js → snk-guides-viewer-cc709b5f.js} +18 -9
- package/dist/esm/snk-guides-viewer.entry.js +8 -8
- package/dist/esm/snk-personalized-filter.entry.js +13 -16
- package/dist/esm/snk-print-selector.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +13 -71
- package/dist/esm/snk-taskbar.entry.js +2 -1
- package/dist/sankhyablocks/p-01739b21.entry.js +1 -0
- package/dist/sankhyablocks/{p-e7e54737.entry.js → p-03bb1aea.entry.js} +1 -1
- package/dist/sankhyablocks/p-05dbc70e.entry.js +1 -0
- package/dist/sankhyablocks/{p-0a4c753d.js → p-14eac6fe.js} +1 -1
- package/dist/sankhyablocks/{p-2ac9c585.js → p-2d333d22.js} +1 -1
- package/dist/sankhyablocks/p-41e897f1.js +56 -0
- package/dist/sankhyablocks/p-48a40939.js +1 -0
- package/dist/sankhyablocks/p-611aa624.entry.js +1 -0
- package/dist/sankhyablocks/p-66bb8c20.entry.js +1 -0
- package/dist/sankhyablocks/p-688dcb4c.js +1 -0
- package/dist/sankhyablocks/p-6f154396.entry.js +1 -0
- package/dist/sankhyablocks/p-787071a8.js +1 -0
- package/dist/sankhyablocks/p-8481bb59.entry.js +1 -0
- package/dist/sankhyablocks/p-8818d8f6.entry.js +1 -0
- package/dist/sankhyablocks/p-93f6ca04.entry.js +1 -0
- package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
- package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
- package/dist/sankhyablocks/p-a52a6c9d.js +26 -0
- package/dist/sankhyablocks/p-b6003974.entry.js +1 -0
- package/dist/sankhyablocks/p-c555075c.entry.js +1 -0
- package/dist/sankhyablocks/{p-7c7764bf.entry.js → p-d13c00b6.entry.js} +1 -1
- package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
- package/dist/sankhyablocks/p-d53a9169.entry.js +1 -0
- package/dist/sankhyablocks/p-d7638f45.entry.js +11 -0
- package/dist/sankhyablocks/p-e086cc2a.entry.js +1 -0
- package/dist/sankhyablocks/p-e64f3e17.entry.js +1 -0
- package/dist/sankhyablocks/p-ed41b38c.js +1 -0
- package/dist/sankhyablocks/p-ed705cbb.entry.js +1 -0
- package/dist/sankhyablocks/p-efc10705.entry.js +1 -0
- package/dist/sankhyablocks/p-f74fe358.js +1 -0
- package/dist/sankhyablocks/{p-df8621b4.js → p-f8e6b97e.js} +1 -1
- package/dist/sankhyablocks/p-f91e0c5d.entry.js +1 -0
- package/dist/sankhyablocks/p-fa523d6b.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
- package/dist/types/components/snk-application/snk-application.d.ts +8 -13
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +10 -0
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +13 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +5 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -2
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +8 -0
- package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
- package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
- package/dist/types/components/snk-form/snk-form.d.ts +9 -1
- package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +18 -1
- package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
- package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +8 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +4 -0
- package/dist/types/components.d.ts +189 -21
- package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +0 -7
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
- package/dist/types/lib/index.d.ts +11 -0
- package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
- package/dist/types/lib/utils/urlutils.d.ts +14 -0
- package/package.json +2 -2
- package/dist/cjs/filter-bar-config-fetcher-2b8ed9d0.js +0 -155
- package/dist/cjs/resource-fetcher-c0332609.js +0 -68
- package/dist/components/filter-bar-config-fetcher.js +0 -153
- package/dist/components/resource-fetcher.js +0 -66
- package/dist/esm/filter-bar-config-fetcher-06e02851.js +0 -153
- package/dist/esm/resource-fetcher-768d5556.js +0 -66
- package/dist/sankhyablocks/p-0a94fdbd.entry.js +0 -1
- package/dist/sankhyablocks/p-0ed0fc02.entry.js +0 -1
- package/dist/sankhyablocks/p-1e0189ff.entry.js +0 -1
- package/dist/sankhyablocks/p-216f081a.entry.js +0 -1
- package/dist/sankhyablocks/p-50d72261.entry.js +0 -1
- package/dist/sankhyablocks/p-6759adae.entry.js +0 -1
- package/dist/sankhyablocks/p-7b8b8ae9.js +0 -10
- package/dist/sankhyablocks/p-815a42c0.entry.js +0 -1
- package/dist/sankhyablocks/p-8a41172a.entry.js +0 -1
- package/dist/sankhyablocks/p-8f8184ff.js +0 -56
- package/dist/sankhyablocks/p-8fdc3108.js +0 -1
- package/dist/sankhyablocks/p-976e56e9.js +0 -1
- package/dist/sankhyablocks/p-98f9d076.js +0 -17
- package/dist/sankhyablocks/p-9edad923.js +0 -1
- package/dist/sankhyablocks/p-abdcac04.entry.js +0 -1
- package/dist/sankhyablocks/p-b0847056.entry.js +0 -1
- package/dist/sankhyablocks/p-bc735728.entry.js +0 -1
- package/dist/sankhyablocks/p-be684b38.entry.js +0 -1
- package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
- package/dist/sankhyablocks/p-c0f656af.entry.js +0 -1
- package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
- package/dist/sankhyablocks/p-ccbfb1cf.entry.js +0 -1
- package/dist/sankhyablocks/p-d1b89765.js +0 -1
- package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
- package/dist/sankhyablocks/p-e28129aa.entry.js +0 -1
- package/dist/sankhyablocks/p-f31bfdee.entry.js +0 -1
- package/dist/sankhyablocks/p-f92fda53.entry.js +0 -11
@@ -1,12 +1,10 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
const
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const filterBarConfigFetcher = require('./filter-bar-config-fetcher-2b8ed9d0.js');
|
7
|
-
const DataFetcher = require('./DataFetcher-004811c6.js');
|
3
|
+
const formConfigFetcher = require('./form-config-fetcher-5d62ab62.js');
|
4
|
+
const filterItemType_enum = require('./filter-item-type.enum-aa823a00.js');
|
5
|
+
const DataFetcher = require('./DataFetcher-f2da1f79.js');
|
8
6
|
|
9
|
-
class GridConfigFetcher extends
|
7
|
+
class GridConfigFetcher extends formConfigFetcher.ResourceFetcher {
|
10
8
|
constructor() {
|
11
9
|
super(...arguments);
|
12
10
|
this.GRID_CONFIG_VERSION = "V3:";
|
@@ -46,6 +44,131 @@ class GridConfigFetcher extends resourceFetcher.ResourceFetcher {
|
|
46
44
|
}
|
47
45
|
}
|
48
46
|
|
47
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
48
|
+
var t = {};
|
49
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
50
|
+
t[p] = s[p];
|
51
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
52
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
53
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
54
|
+
t[p[i]] = s[p[i]];
|
55
|
+
}
|
56
|
+
return t;
|
57
|
+
};
|
58
|
+
function normalizeValue(value, type) {
|
59
|
+
if (value == undefined) {
|
60
|
+
return value;
|
61
|
+
}
|
62
|
+
if (value instanceof Date) {
|
63
|
+
return value.toISOString();
|
64
|
+
}
|
65
|
+
if (typeof value === "object") {
|
66
|
+
if (value instanceof Array) {
|
67
|
+
return value.map(item => {
|
68
|
+
if (filterItemType_enum.FilterItemType.MULTI_LIST === type) {
|
69
|
+
const values = __rest(item, ["label"]);
|
70
|
+
return normalizeValue(values);
|
71
|
+
}
|
72
|
+
return normalizeValue(item);
|
73
|
+
});
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
const normalized = Object.assign({}, value);
|
77
|
+
Object.keys(value).forEach(prop => {
|
78
|
+
if (value[prop] !== undefined) {
|
79
|
+
normalized[prop] = normalizeValue(value[prop], type);
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
delete normalized[prop];
|
83
|
+
}
|
84
|
+
});
|
85
|
+
return normalized;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
return value;
|
89
|
+
}
|
90
|
+
class FilterBarConfigFetcher extends formConfigFetcher.ResourceFetcher {
|
91
|
+
normalize(items) {
|
92
|
+
return items.map(item => {
|
93
|
+
const { id, value, fixed, visible, type, groupedItems } = item;
|
94
|
+
const stateItem = { id };
|
95
|
+
if (value) {
|
96
|
+
stateItem["value"] = normalizeValue(value, type);
|
97
|
+
}
|
98
|
+
if (fixed) {
|
99
|
+
stateItem["fixed"] = fixed;
|
100
|
+
}
|
101
|
+
if (groupedItems) {
|
102
|
+
if (groupedItems.length === 0) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
if (groupedItems.filter(item => item.visible).length > 0) {
|
106
|
+
stateItem["visible"] = true;
|
107
|
+
}
|
108
|
+
stateItem["groupedItems"] = this.normalize(groupedItems);
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
if (visible) {
|
112
|
+
stateItem["visible"] = true;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
return stateItem;
|
116
|
+
}).filter(item => item != undefined);
|
117
|
+
}
|
118
|
+
saveConfig(items, resourceID, configName) {
|
119
|
+
return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
|
120
|
+
}
|
121
|
+
getConfig(resourceID, configName, urlParams) {
|
122
|
+
return new Promise((accept, reject) => {
|
123
|
+
this.loadResource(this.getPath(resourceID, configName, urlParams))
|
124
|
+
.then((configAsString) => {
|
125
|
+
let fieldsList;
|
126
|
+
if (configAsString) {
|
127
|
+
const filterBarConfig = JSON.parse(configAsString);
|
128
|
+
fieldsList = this.buildFieldList(filterBarConfig.items);
|
129
|
+
}
|
130
|
+
accept(fieldsList || []);
|
131
|
+
})
|
132
|
+
.catch((error) => {
|
133
|
+
reject(error);
|
134
|
+
});
|
135
|
+
});
|
136
|
+
}
|
137
|
+
buildFieldList(items) {
|
138
|
+
return items.map(item => {
|
139
|
+
var _a, _b;
|
140
|
+
if (item.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
|
141
|
+
const multiListValue = item.value;
|
142
|
+
item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
|
143
|
+
}
|
144
|
+
return item;
|
145
|
+
});
|
146
|
+
}
|
147
|
+
getPath(resourceID, name, urlParams) {
|
148
|
+
let path = `cfg://filter/FilterBarState:${resourceID}`;
|
149
|
+
if (name) {
|
150
|
+
path += `.${name}`;
|
151
|
+
}
|
152
|
+
if (urlParams) {
|
153
|
+
path += this.buildQueryString(urlParams);
|
154
|
+
}
|
155
|
+
return path;
|
156
|
+
}
|
157
|
+
buildQueryString(urlParams) {
|
158
|
+
let queryString = '?';
|
159
|
+
for (let key in urlParams) {
|
160
|
+
if (!urlParams.hasOwnProperty(key)) {
|
161
|
+
continue;
|
162
|
+
}
|
163
|
+
if (queryString.length > 1) {
|
164
|
+
queryString += '&';
|
165
|
+
}
|
166
|
+
queryString += key + '=' + urlParams[key];
|
167
|
+
}
|
168
|
+
return queryString;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
49
172
|
class PersonalizedFilterFetcher {
|
50
173
|
constructor() {
|
51
174
|
this.templateByQuery = new Map();
|
@@ -220,91 +343,80 @@ const CONFIG_SOURCE = {
|
|
220
343
|
filterBar: "filterBar"
|
221
344
|
};
|
222
345
|
class ConfigStorage {
|
223
|
-
static
|
224
|
-
|
225
|
-
|
226
|
-
if (application != undefined) {
|
227
|
-
const configName = application.configName;
|
228
|
-
const resourceID = await application.getResourceID();
|
229
|
-
ConfigStorage.instance = new ConfigStorage();
|
230
|
-
ConfigStorage.resourceID = resourceID;
|
231
|
-
ConfigStorage.instance.loadFormConfig(configName);
|
232
|
-
ConfigStorage.instance.loadGridConfig(configName);
|
233
|
-
}
|
234
|
-
}
|
235
|
-
return this.instance;
|
346
|
+
static preload(resourceID, configName) {
|
347
|
+
ConfigStorage.loadFormConfig(configName, resourceID);
|
348
|
+
ConfigStorage.loadGridConfig(configName, resourceID);
|
236
349
|
}
|
237
|
-
async loadFilterBarConfig(name, urlParams) {
|
238
|
-
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar);
|
350
|
+
static async loadFilterBarConfig(name, resourceID, urlParams) {
|
351
|
+
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
|
239
352
|
if (!ConfigStorage.configById.has(cacheID)) {
|
240
|
-
ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(
|
353
|
+
ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
|
241
354
|
}
|
242
355
|
return ConfigStorage.configById.get(cacheID);
|
243
356
|
}
|
244
|
-
async loadFormConfig(name) {
|
245
|
-
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form);
|
357
|
+
static async loadFormConfig(name, resourceID) {
|
358
|
+
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
|
246
359
|
if (!ConfigStorage.configById.has(cacheID)) {
|
247
|
-
ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name,
|
360
|
+
ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
|
248
361
|
}
|
249
362
|
return ConfigStorage.configById.get(cacheID);
|
250
363
|
}
|
251
|
-
async loadGridConfig(name) {
|
252
|
-
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid);
|
364
|
+
static async loadGridConfig(name, resourceID) {
|
365
|
+
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
|
253
366
|
if (!ConfigStorage.configById.has(cacheID)) {
|
254
|
-
ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name,
|
367
|
+
ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
|
255
368
|
}
|
256
369
|
return ConfigStorage.configById.get(cacheID);
|
257
370
|
}
|
258
|
-
static async saveFilterBarConfig(config, name) {
|
259
|
-
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar);
|
371
|
+
static async saveFilterBarConfig(config, name, resourceID) {
|
372
|
+
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
|
260
373
|
this.configById.delete(cacheID);
|
261
|
-
return this.filterBarConfigFetcher.saveConfig(config,
|
374
|
+
return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
|
262
375
|
}
|
263
|
-
static async saveFormConfig(config, name) {
|
264
|
-
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form);
|
376
|
+
static async saveFormConfig(config, name, resourceID) {
|
377
|
+
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
|
265
378
|
this.configById.delete(cacheID);
|
266
|
-
return this.formConfigFetcher.saveConfig(config, name,
|
379
|
+
return this.formConfigFetcher.saveConfig(config, name, resourceID);
|
267
380
|
}
|
268
|
-
static async saveCardState(config, name) {
|
269
|
-
return this.formConfigFetcher.saveCardState(config, name,
|
381
|
+
static async saveCardState(config, name, resourceID) {
|
382
|
+
return this.formConfigFetcher.saveCardState(config, name, resourceID);
|
270
383
|
}
|
271
|
-
static async saveGridConfig(config, name) {
|
384
|
+
static async saveGridConfig(config, name, resourceID) {
|
272
385
|
if (config == undefined) {
|
273
386
|
return;
|
274
387
|
}
|
275
|
-
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid);
|
388
|
+
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
|
276
389
|
this.configById.delete(cacheID);
|
277
|
-
return this.gridConfigFetcher.saveConfig(config, name,
|
390
|
+
return this.gridConfigFetcher.saveConfig(config, name, resourceID);
|
278
391
|
}
|
279
|
-
static async loadPersonalizedFilter(filterId, configName) {
|
280
|
-
return this.personalizedFilterFetcher.loadPersonalizedFilter(
|
392
|
+
static async loadPersonalizedFilter(filterId, resourceID, configName) {
|
393
|
+
return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName);
|
281
394
|
}
|
282
|
-
static async savePersonalizedFilter(personalizedFilter, configName) {
|
395
|
+
static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
|
283
396
|
//Ao criar ou alterar um filtro personalizado,
|
284
397
|
//precisamos remover o cache do status da filterbar.
|
285
|
-
const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar);
|
398
|
+
const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar, resourceID);
|
286
399
|
this.configById.delete(cacheID);
|
287
|
-
return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter,
|
400
|
+
return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, resourceID, configName);
|
288
401
|
}
|
289
|
-
static async removePersonalizedFilter(personalizedFilter, configName) {
|
290
|
-
return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter,
|
402
|
+
static async removePersonalizedFilter(personalizedFilter, resourceID, configName) {
|
403
|
+
return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, resourceID, configName);
|
291
404
|
}
|
292
405
|
static async validatePersonalizedFilter(dataUnitName, expression) {
|
293
406
|
return this.personalizedFilterFetcher.validatePersonalizedFilter(dataUnitName, expression);
|
294
407
|
}
|
295
|
-
static buildCacheID(name, source) {
|
408
|
+
static buildCacheID(name, source, resourceID) {
|
296
409
|
if (name == undefined) {
|
297
|
-
return `req_${source}_${
|
410
|
+
return `req_${source}_${resourceID}`;
|
298
411
|
}
|
299
|
-
return `req_${source}_${name}_${
|
412
|
+
return `req_${source}_${name}_${resourceID}`;
|
300
413
|
}
|
301
414
|
}
|
302
415
|
ConfigStorage.configById = new Map();
|
303
|
-
ConfigStorage.filterBarConfigFetcher = new
|
416
|
+
ConfigStorage.filterBarConfigFetcher = new FilterBarConfigFetcher();
|
304
417
|
ConfigStorage.formConfigFetcher = new formConfigFetcher.FormConfigFetcher();
|
305
418
|
ConfigStorage.gridConfigFetcher = new GridConfigFetcher();
|
306
419
|
ConfigStorage.personalizedFilterFetcher = new PersonalizedFilterFetcher();
|
307
420
|
|
308
421
|
exports.ConfigStorage = ConfigStorage;
|
309
|
-
exports.GridConfigFetcher = GridConfigFetcher;
|
310
422
|
exports.PersonalizedFilterFetcher = PersonalizedFilterFetcher;
|
@@ -6436,6 +6436,35 @@ class UrlUtils {
|
|
6436
6436
|
return window['mock_url'];
|
6437
6437
|
return `${location.protocol}//${location.hostname}${location.port ? ":" + location.port : ""}`;
|
6438
6438
|
}
|
6439
|
+
/**
|
6440
|
+
* Extrai da URL o parâmetro que contém o resourceId da tela desejada.
|
6441
|
+
*
|
6442
|
+
*/
|
6443
|
+
static getResourceIdFromUrlToken(url) {
|
6444
|
+
try {
|
6445
|
+
const parts = url.split('/');
|
6446
|
+
const encodedValue = parts[1];
|
6447
|
+
return atob(encodedValue);
|
6448
|
+
}
|
6449
|
+
catch (error) {
|
6450
|
+
throw new Error('Erro ao obter resourceId:' + error);
|
6451
|
+
}
|
6452
|
+
}
|
6453
|
+
/**
|
6454
|
+
* Extrai da URL o parâmetro que contém o o objeto com a PK do registro específico.
|
6455
|
+
*
|
6456
|
+
*/
|
6457
|
+
static getPkObjectFromUrlToken(url) {
|
6458
|
+
try {
|
6459
|
+
const parts = url.split('/');
|
6460
|
+
const encodedObjectPart = parts[parts.length - 2];
|
6461
|
+
const decodedObjectPart = atob(encodedObjectPart);
|
6462
|
+
return JSON.parse(decodedObjectPart);
|
6463
|
+
}
|
6464
|
+
catch (error) {
|
6465
|
+
throw new Error('Erro ao obter a PK do objeto:' + error);
|
6466
|
+
}
|
6467
|
+
}
|
6439
6468
|
}
|
6440
6469
|
|
6441
6470
|
class ServiceBrokerRecaller {
|
@@ -6681,7 +6710,8 @@ class AppletImpressao {
|
|
6681
6710
|
|
6682
6711
|
class DataFetcher {
|
6683
6712
|
constructor() {
|
6684
|
-
this.GRAPHQL_PATH =
|
6713
|
+
this.GRAPHQL_PATH = `/${window.MGE_MODULE_NAME || 'mgefin-bff'}/graphql`;
|
6714
|
+
this.ready = true;
|
6685
6715
|
this.watingRequestsById = new Map();
|
6686
6716
|
}
|
6687
6717
|
static get() {
|
@@ -6692,6 +6722,9 @@ class DataFetcher {
|
|
6692
6722
|
DataFetcher.instance.resume();
|
6693
6723
|
}
|
6694
6724
|
else {
|
6725
|
+
if (core.ApplicationContext.getContextValue("__SNK__APPLICATION__LOADING__") === true) {
|
6726
|
+
DataFetcher.instance.pause();
|
6727
|
+
}
|
6695
6728
|
application.addEventListener('applicationLoading', () => DataFetcher.instance.pause());
|
6696
6729
|
application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
|
6697
6730
|
}
|
@@ -6750,6 +6783,10 @@ class DataFetcher {
|
|
6750
6783
|
}
|
6751
6784
|
async callGraphQL(req) {
|
6752
6785
|
var _a;
|
6786
|
+
if (this.ready) {
|
6787
|
+
this.pause();
|
6788
|
+
window.requestAnimationFrame(() => this.resume());
|
6789
|
+
}
|
6753
6790
|
const reqKey = this.getReqKey(req);
|
6754
6791
|
req.queryID = reqKey;
|
6755
6792
|
req.values.queryID = reqKey;
|
@@ -6779,7 +6816,7 @@ class DataFetcher {
|
|
6779
6816
|
if (!this.watingRequestsById.has(reqKey)) {
|
6780
6817
|
this.watingRequestsById.set(reqKey, new WaitingRequest(req));
|
6781
6818
|
}
|
6782
|
-
return (_a = this.
|
6819
|
+
return (_a = this.watingRequestsById.get(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
|
6783
6820
|
}
|
6784
6821
|
}
|
6785
6822
|
resolveURL() {
|
@@ -6927,42 +6964,43 @@ class DataFetcher {
|
|
6927
6964
|
getQueryTemplate(re) {
|
6928
6965
|
return (re.query || "").replaceAll("$queryAlias$", re.queryID);
|
6929
6966
|
}
|
6930
|
-
getWatingRequest(reqID) {
|
6931
|
-
return this.watingRequestsById.get(reqID);
|
6932
|
-
}
|
6933
6967
|
pause() {
|
6934
6968
|
this.ready = false;
|
6935
6969
|
}
|
6936
6970
|
async resume() {
|
6937
6971
|
this.ready = true;
|
6938
6972
|
if (this.watingRequestsById.size > 0) {
|
6939
|
-
const
|
6940
|
-
this.watingRequestsById
|
6941
|
-
|
6942
|
-
|
6943
|
-
|
6944
|
-
|
6945
|
-
|
6946
|
-
|
6947
|
-
|
6948
|
-
|
6949
|
-
|
6950
|
-
|
6951
|
-
|
6952
|
-
|
6953
|
-
|
6954
|
-
|
6955
|
-
|
6973
|
+
const waitinRequests = this.watingRequestsById;
|
6974
|
+
this.watingRequestsById = new Map();
|
6975
|
+
this.executePendingRequest(waitinRequests);
|
6976
|
+
}
|
6977
|
+
}
|
6978
|
+
async executePendingRequest(watingRequestsById) {
|
6979
|
+
const requestsBatch = [];
|
6980
|
+
watingRequestsById.forEach(async (waitingReq) => {
|
6981
|
+
let query = this.getQueryTemplate(waitingReq.request);
|
6982
|
+
requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
|
6983
|
+
});
|
6984
|
+
let res = undefined;
|
6985
|
+
let dataResponse = [];
|
6986
|
+
let errorsResponse = [];
|
6987
|
+
res = await this.fecthGrapql(requestsBatch);
|
6988
|
+
dataResponse = res.data;
|
6989
|
+
errorsResponse = res.errors;
|
6990
|
+
//Reject promises with errors from query
|
6991
|
+
errorsResponse.forEach((errorResponse) => {
|
6992
|
+
Object.entries(errorResponse).forEach(([_key, val]) => {
|
6993
|
+
var _a;
|
6994
|
+
(((_a = watingRequestsById.get(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new core.ErrorException("Falha detectada", val.message));
|
6956
6995
|
});
|
6957
|
-
|
6958
|
-
|
6959
|
-
|
6960
|
-
|
6961
|
-
|
6962
|
-
|
6996
|
+
});
|
6997
|
+
//Resolve promises with data from query
|
6998
|
+
dataResponse.forEach((data) => {
|
6999
|
+
Object.entries(data).forEach(([key, val]) => {
|
7000
|
+
var _a;
|
7001
|
+
(((_a = watingRequestsById.get(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
|
6963
7002
|
});
|
6964
|
-
|
6965
|
-
}
|
7003
|
+
});
|
6966
7004
|
}
|
6967
7005
|
async fecthGrapql(request) {
|
6968
7006
|
let res = undefined;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
exports.SaveErrorsEnum = void 0;
|
4
|
+
(function (SaveErrorsEnum) {
|
5
|
+
SaveErrorsEnum["LINK_AND_FILE_AT_THE_SAME_TIME"] = "LINK_AND_FILE_AT_THE_SAME_TIME";
|
6
|
+
SaveErrorsEnum["ANY_LINK_OR_FILE_FILLED"] = "ANY_LINK_OR_FILE_FILLED";
|
7
|
+
SaveErrorsEnum["UNKNOWN"] = "UNKNOWN";
|
8
|
+
})(exports.SaveErrorsEnum || (exports.SaveErrorsEnum = {}));
|
@@ -0,0 +1,12 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const core = require('@sankhyalabs/core');
|
4
|
+
|
5
|
+
class ResourceIDUtils {
|
6
|
+
static async getResourceID() {
|
7
|
+
const application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
8
|
+
return application.getResourceID();
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
exports.ResourceIDUtils = ResourceIDUtils;
|
@@ -1,33 +1,31 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
const ConfigStorage = require('./ConfigStorage-
|
3
|
+
const ConfigStorage = require('./ConfigStorage-12397f18.js');
|
4
4
|
const core = require('@sankhyalabs/core');
|
5
|
-
const formConfigFetcher = require('./form-config-fetcher-
|
5
|
+
const formConfigFetcher = require('./form-config-fetcher-5d62ab62.js');
|
6
6
|
|
7
7
|
class SnkFormConfigManager {
|
8
|
-
constructor(configName, onConfigChange) {
|
8
|
+
constructor(configName, resourceID, onConfigChange) {
|
9
|
+
this._resourceID = resourceID;
|
9
10
|
this._configName = configName;
|
10
11
|
this._onConfigChange = onConfigChange;
|
11
12
|
}
|
12
13
|
async loadConfig() {
|
13
14
|
return new Promise(resolve => {
|
14
|
-
ConfigStorage.ConfigStorage.
|
15
|
-
.then((
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
.catch((error) => {
|
22
|
-
console.warn(error);
|
23
|
-
});
|
15
|
+
ConfigStorage.ConfigStorage.loadFormConfig(this._configName, this._resourceID)
|
16
|
+
.then((config) => {
|
17
|
+
this.setConfig(config);
|
18
|
+
resolve(config);
|
19
|
+
})
|
20
|
+
.catch((error) => {
|
21
|
+
console.warn(error);
|
24
22
|
});
|
25
23
|
});
|
26
24
|
}
|
27
25
|
saveConfig(config) {
|
28
26
|
const configToSave = core.ObjectUtils.copy(config);
|
29
27
|
return new Promise(accept => {
|
30
|
-
ConfigStorage.ConfigStorage.saveFormConfig(config, this._configName)
|
28
|
+
ConfigStorage.ConfigStorage.saveFormConfig(config, this._configName, this._resourceID)
|
31
29
|
.then((response) => {
|
32
30
|
this.setConfig(Object.assign(Object.assign({}, configToSave), response));
|
33
31
|
accept(Object.assign(Object.assign({}, configToSave), response));
|
@@ -42,7 +40,7 @@ class SnkFormConfigManager {
|
|
42
40
|
cardsState.set(cardId, propertyChanged === "fixed" ?
|
43
41
|
this.updateFixSequence(Object.assign(Object.assign({}, currentConfig), { fixed: cardConfig.fixed }), cardsState)
|
44
42
|
: Object.assign(Object.assign({}, currentConfig), { [propertyChanged]: cardConfig[propertyChanged] }));
|
45
|
-
ConfigStorage.ConfigStorage.saveCardState(cardsState, this._configName)
|
43
|
+
ConfigStorage.ConfigStorage.saveCardState(cardsState, this._configName, this._resourceID)
|
46
44
|
.then(savedCardConfig => {
|
47
45
|
this._config = Object.assign(Object.assign({}, this._config), { cardsState });
|
48
46
|
resolve(savedCardConfig);
|
@@ -118,18 +116,18 @@ class SnkFormConfigManager {
|
|
118
116
|
}
|
119
117
|
return this._formConfigFetcher;
|
120
118
|
}
|
121
|
-
async fetchUserAvailableConfigs(
|
119
|
+
async fetchUserAvailableConfigs() {
|
122
120
|
if (this._configName != undefined) {
|
123
121
|
//FIXME: Precisamos preparar o backend para retornar as configurações disponíveis para details;
|
124
122
|
return Promise.resolve(undefined);
|
125
123
|
}
|
126
|
-
return this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,
|
124
|
+
return this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName, this._resourceID);
|
127
125
|
}
|
128
|
-
async fetchLegacyConfig(
|
129
|
-
return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,
|
126
|
+
async fetchLegacyConfig() {
|
127
|
+
return this.getFormConfigFetcher().fetchLegacyConfig(this._configName, this._resourceID);
|
130
128
|
}
|
131
|
-
async fetchDefaultConfig(
|
132
|
-
return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,
|
129
|
+
async fetchDefaultConfig() {
|
130
|
+
return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
|
133
131
|
}
|
134
132
|
}
|
135
133
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const core = require('@sankhyalabs/core');
|
4
|
+
const formConfigFetcher = require('./form-config-fetcher-5d62ab62.js');
|
5
|
+
|
6
|
+
class AuthFetcher extends formConfigFetcher.ResourceFetcher {
|
7
|
+
getData(resourceID) {
|
8
|
+
const completePath = `cfg://auth/${resourceID}`;
|
9
|
+
return new Promise((resolve, reject) => {
|
10
|
+
this.loadResource(completePath)
|
11
|
+
.then((loadedResource) => {
|
12
|
+
let auth = core.ObjectUtils.stringToObject(loadedResource);
|
13
|
+
if (auth && typeof (auth) === 'object') {
|
14
|
+
resolve(auth);
|
15
|
+
}
|
16
|
+
}).catch((error) => {
|
17
|
+
reject(error);
|
18
|
+
});
|
19
|
+
});
|
20
|
+
}
|
21
|
+
}
|
22
|
+
exports.AutorizationType = void 0;
|
23
|
+
(function (AutorizationType) {
|
24
|
+
AutorizationType["INSERT"] = "I";
|
25
|
+
AutorizationType["UPDATE"] = "A";
|
26
|
+
AutorizationType["REMOVE"] = "E";
|
27
|
+
AutorizationType["SHOW"] = "C";
|
28
|
+
AutorizationType["CONFIG"] = "F";
|
29
|
+
AutorizationType["CONFIG_NUMBER"] = "N";
|
30
|
+
AutorizationType["CLONE"] = "D";
|
31
|
+
AutorizationType["CONFIG_GRID"] = "G";
|
32
|
+
})(exports.AutorizationType || (exports.AutorizationType = {}));
|
33
|
+
|
34
|
+
exports.AuthFetcher = AuthFetcher;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
const core = require('@sankhyalabs/core');
|
4
|
-
const DataFetcher = require('./DataFetcher-
|
4
|
+
const DataFetcher = require('./DataFetcher-f2da1f79.js');
|
5
5
|
const constants = require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
6
6
|
const UnitMetadata = require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
7
7
|
|
@@ -1,10 +1,72 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
const DataFetcher = require('./DataFetcher-
|
3
|
+
const DataFetcher = require('./DataFetcher-f2da1f79.js');
|
4
4
|
const core = require('@sankhyalabs/core');
|
5
|
-
const resourceFetcher = require('./resource-fetcher-c0332609.js');
|
6
5
|
|
7
|
-
class
|
6
|
+
class ResourceFetcher {
|
7
|
+
constructor() {
|
8
|
+
this.templateByQuery = new Map();
|
9
|
+
this.buldTemplates();
|
10
|
+
}
|
11
|
+
buldTemplates() {
|
12
|
+
this.templateByQuery.set("fetchResource", DataFetcher.dist.gql `query($name: String!) {
|
13
|
+
$queryAlias$: fetchResource(name: $name){
|
14
|
+
resource
|
15
|
+
}
|
16
|
+
}`);
|
17
|
+
this.templateByQuery.set("saveResource", DataFetcher.dist.gql `mutation($resource: InputResource!) {
|
18
|
+
$queryAlias$: saveResource(resource: $resource){
|
19
|
+
name
|
20
|
+
resource
|
21
|
+
}
|
22
|
+
}`);
|
23
|
+
}
|
24
|
+
loadResource(name) {
|
25
|
+
if (ResourceFetcher._loadingResource.has(name)) {
|
26
|
+
return ResourceFetcher._loadingResource.get(name);
|
27
|
+
}
|
28
|
+
const promiseLoadResource = new Promise((resolve, reject) => {
|
29
|
+
DataFetcher.DataFetcher.get()
|
30
|
+
.callGraphQL({
|
31
|
+
values: { name },
|
32
|
+
query: this.templateByQuery.get("fetchResource"),
|
33
|
+
})
|
34
|
+
.then((result) => {
|
35
|
+
resolve(result === null || result === void 0 ? void 0 : result.resource);
|
36
|
+
ResourceFetcher._loadingResource.delete(name);
|
37
|
+
})
|
38
|
+
.catch((error) => {
|
39
|
+
reject(error);
|
40
|
+
ResourceFetcher._loadingResource.delete(name);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
ResourceFetcher._loadingResource.set(name, promiseLoadResource);
|
44
|
+
return promiseLoadResource;
|
45
|
+
}
|
46
|
+
saveResource(resource, name) {
|
47
|
+
return new Promise((resolve, reject) => {
|
48
|
+
DataFetcher.DataFetcher.get()
|
49
|
+
.callGraphQL({
|
50
|
+
values: {
|
51
|
+
resource: {
|
52
|
+
name: name,
|
53
|
+
resource: JSON.stringify(resource)
|
54
|
+
}
|
55
|
+
},
|
56
|
+
query: this.templateByQuery.get("saveResource")
|
57
|
+
})
|
58
|
+
.then((resp) => {
|
59
|
+
resolve(resp);
|
60
|
+
})
|
61
|
+
.catch((error) => {
|
62
|
+
reject(error);
|
63
|
+
});
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
ResourceFetcher._loadingResource = new Map();
|
68
|
+
|
69
|
+
class FormConfigFetcher extends ResourceFetcher {
|
8
70
|
constructor() {
|
9
71
|
super();
|
10
72
|
this.queryConfig = new Map();
|
@@ -179,3 +241,4 @@ exports.UserConfigType = void 0;
|
|
179
241
|
})(exports.UserConfigType || (exports.UserConfigType = {}));
|
180
242
|
|
181
243
|
exports.FormConfigFetcher = FormConfigFetcher;
|
244
|
+
exports.ResourceFetcher = ResourceFetcher;
|