@sankhyalabs/sankhyablocks 1.2.0 → 1.3.2
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/index-4720dab8.js +735 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/sankhyablocks.cjs.js +19 -0
- package/dist/cjs/snk-application.cjs.entry.js +7065 -0
- package/dist/collection/collection-manifest.json +18 -0
- package/dist/collection/components/snk-application/snk-application.css +5 -0
- package/dist/collection/components/snk-application/snk-application.js +492 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +158 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/application-config-fetcher.js +23 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +188 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +25 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +2 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +59 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +30 -0
- package/dist/collection/lib/http/data-fetcher/state/LoadStateManager.js +66 -0
- package/dist/collection/lib/utils/pesquisa.js +16 -0
- package/dist/collection/lib/utils/urlutils.js +23 -0
- package/dist/collection/lib/workspace/workspace.js +7 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/snk-application.d.ts +11 -0
- package/dist/components/snk-application.js +7094 -0
- package/dist/esm/index-72d4e2e0.js +709 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/sankhyablocks.js +17 -0
- package/dist/esm/snk-application.entry.js +7061 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/sankhyablocks/index.esm.js +0 -0
- package/dist/sankhyablocks/p-76b95007.entry.js +57 -0
- package/dist/sankhyablocks/p-a33afc3b.js +2 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +44 -0
- package/dist/types/components.d.ts +66 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +15 -0
- package/dist/types/lib/http/data-fetcher/fetchers/application-config-fetcher.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +12 -0
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +5 -0
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +13 -0
- package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/state/LoadStateManager.d.ts +23 -0
- package/dist/types/lib/utils/pesquisa.d.ts +2 -0
- package/dist/types/lib/utils/urlutils.d.ts +4 -0
- package/dist/types/lib/workspace/workspace.d.ts +4 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +9 -36
- package/react/components.d.ts +3 -0
- package/react/components.js +6 -0
- package/react/components.js.map +1 -0
- package/react/react-component-lib/createComponent.d.ts +10 -0
- package/react/react-component-lib/createComponent.js +59 -0
- package/react/react-component-lib/createComponent.js.map +1 -0
- package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
- package/react/react-component-lib/createOverlayComponent.js +89 -0
- package/react/react-component-lib/createOverlayComponent.js.map +1 -0
- package/react/react-component-lib/index.d.ts +2 -0
- package/react/react-component-lib/index.js +3 -0
- package/react/react-component-lib/index.js.map +1 -0
- package/react/react-component-lib/interfaces.d.ts +29 -0
- package/react/react-component-lib/interfaces.js +1 -0
- package/react/react-component-lib/interfaces.js.map +1 -0
- package/react/react-component-lib/utils/attachProps.d.ts +12 -0
- package/react/react-component-lib/utils/attachProps.js +96 -0
- package/react/react-component-lib/utils/attachProps.js.map +1 -0
- package/react/react-component-lib/utils/case.d.ts +2 -0
- package/react/react-component-lib/utils/case.js +7 -0
- package/react/react-component-lib/utils/case.js.map +1 -0
- package/react/react-component-lib/utils/dev.d.ts +2 -0
- package/react/react-component-lib/utils/dev.js +13 -0
- package/react/react-component-lib/utils/dev.js.map +1 -0
- package/react/react-component-lib/utils/index.d.ts +7 -0
- package/react/react-component-lib/utils/index.js +21 -0
- package/react/react-component-lib/utils/index.js.map +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entries": [
|
|
3
|
+
"./components/snk-application/snk-application.js"
|
|
4
|
+
],
|
|
5
|
+
"compiler": {
|
|
6
|
+
"name": "@stencil/core",
|
|
7
|
+
"version": "2.16.1",
|
|
8
|
+
"typescriptVersion": "4.5.4"
|
|
9
|
+
},
|
|
10
|
+
"collections": [],
|
|
11
|
+
"bundles": [
|
|
12
|
+
{
|
|
13
|
+
"components": [
|
|
14
|
+
"snk-application"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import { Component, h, Method, Event } from "@stencil/core";
|
|
2
|
+
import DataUnitFetcher from "../../lib/http/data-fetcher/fetchers/dataunit-fetcher";
|
|
3
|
+
import UrlUtils from "../../lib/utils/urlutils";
|
|
4
|
+
import Workspace from "../../lib/workspace/workspace";
|
|
5
|
+
import ParametersFetcher from "../../lib/http/data-fetcher/fetchers/parameters-fecher";
|
|
6
|
+
import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
|
|
7
|
+
import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
|
|
8
|
+
import { ApplicationContext } from "@sankhyalabs/core";
|
|
9
|
+
import { pesquisaLoadOptions } from "../../lib/utils/pesquisa";
|
|
10
|
+
export class SnkApplication {
|
|
11
|
+
get parameters() {
|
|
12
|
+
if (!this._parameters) {
|
|
13
|
+
this._parameters = new ParametersFetcher();
|
|
14
|
+
}
|
|
15
|
+
return this._parameters;
|
|
16
|
+
}
|
|
17
|
+
get resourceID() {
|
|
18
|
+
if (!this._resourceID) {
|
|
19
|
+
this._resourceID = this.urlParams.get("workspaceResourceID") ||
|
|
20
|
+
this.urlParams.get("resourceID") ||
|
|
21
|
+
Workspace.resourceID ||
|
|
22
|
+
"unknown.resource.id";
|
|
23
|
+
}
|
|
24
|
+
return this._resourceID;
|
|
25
|
+
}
|
|
26
|
+
async getStringParam(name) {
|
|
27
|
+
return this.parameters.asString(name, this.resourceID);
|
|
28
|
+
}
|
|
29
|
+
async getIntParam(name) {
|
|
30
|
+
return this.parameters.asInteger(name, this.resourceID);
|
|
31
|
+
}
|
|
32
|
+
async getFloatParam(name) {
|
|
33
|
+
return this.parameters.asFloat(name, this.resourceID);
|
|
34
|
+
}
|
|
35
|
+
async getBooleanParam(name) {
|
|
36
|
+
return this.parameters.asBoolean(name, this.resourceID);
|
|
37
|
+
}
|
|
38
|
+
async getDateParam(name) {
|
|
39
|
+
return this.parameters.asDate(name, this.resourceID);
|
|
40
|
+
}
|
|
41
|
+
async temOpcional(opcional) {
|
|
42
|
+
const opts = opcional.split(",");
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
this.getAttributeFromHTMLWrapper("opc0009")
|
|
45
|
+
.then(value => {
|
|
46
|
+
if (value === "1") {
|
|
47
|
+
resolve(true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
|
|
51
|
+
.then(result => {
|
|
52
|
+
resolve(result.includes("1"));
|
|
53
|
+
})
|
|
54
|
+
.catch(error => {
|
|
55
|
+
reject(error);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.catch(error => {
|
|
60
|
+
reject(error);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async getAttributeFromHTMLWrapper(attribName) {
|
|
65
|
+
return Promise.resolve(window[attribName]);
|
|
66
|
+
}
|
|
67
|
+
async openApp(resourceId, pkObject) {
|
|
68
|
+
Workspace.openAppActivity(resourceId, pkObject);
|
|
69
|
+
}
|
|
70
|
+
async createDataunit(entityName) {
|
|
71
|
+
return new Promise(resolve => {
|
|
72
|
+
const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
|
|
73
|
+
dataUnit.loadMetadata();
|
|
74
|
+
resolve(dataUnit);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async getResourceID() {
|
|
78
|
+
return Promise.resolve(this.resourceID);
|
|
79
|
+
}
|
|
80
|
+
async alert(title, message, icon) {
|
|
81
|
+
return ApplicationUtils.alert(title, message, icon);
|
|
82
|
+
}
|
|
83
|
+
async error(title, message, icon) {
|
|
84
|
+
return ApplicationUtils.error(title, message, icon);
|
|
85
|
+
}
|
|
86
|
+
async confirm(title, message, icon, critical) {
|
|
87
|
+
return ApplicationUtils.confirm(title, message, icon, critical);
|
|
88
|
+
}
|
|
89
|
+
async info(message, options = undefined) {
|
|
90
|
+
return ApplicationUtils.info(message, options);
|
|
91
|
+
}
|
|
92
|
+
async loadFormConfig(name) {
|
|
93
|
+
return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
|
|
94
|
+
}
|
|
95
|
+
get urlParams() {
|
|
96
|
+
if (!this._urlParams) {
|
|
97
|
+
this._urlParams = UrlUtils.getQueryParams(location.search);
|
|
98
|
+
}
|
|
99
|
+
return this._urlParams;
|
|
100
|
+
}
|
|
101
|
+
get dataUnitFetcher() {
|
|
102
|
+
if (!this._dataUnitFetcher) {
|
|
103
|
+
this._dataUnitFetcher = new DataUnitFetcher();
|
|
104
|
+
}
|
|
105
|
+
return this._dataUnitFetcher;
|
|
106
|
+
}
|
|
107
|
+
get formConfigFetcher() {
|
|
108
|
+
if (!this._formConfigFetcher) {
|
|
109
|
+
this._formConfigFetcher = new FormConfigFetcher();
|
|
110
|
+
}
|
|
111
|
+
return this._formConfigFetcher;
|
|
112
|
+
}
|
|
113
|
+
componentWillLoad() {
|
|
114
|
+
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
|
|
115
|
+
}
|
|
116
|
+
componentDidLoad() {
|
|
117
|
+
this.applicationLoading.emit(true);
|
|
118
|
+
window.requestAnimationFrame(() => {
|
|
119
|
+
this.applicationLoaded.emit(true);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
return (h("div", null));
|
|
124
|
+
}
|
|
125
|
+
static get is() { return "snk-application"; }
|
|
126
|
+
static get encapsulation() { return "scoped"; }
|
|
127
|
+
static get originalStyleUrls() { return {
|
|
128
|
+
"$": ["snk-application.css"]
|
|
129
|
+
}; }
|
|
130
|
+
static get styleUrls() { return {
|
|
131
|
+
"$": ["snk-application.css"]
|
|
132
|
+
}; }
|
|
133
|
+
static get events() { return [{
|
|
134
|
+
"method": "applicationLoaded",
|
|
135
|
+
"name": "applicationLoaded",
|
|
136
|
+
"bubbles": true,
|
|
137
|
+
"cancelable": true,
|
|
138
|
+
"composed": true,
|
|
139
|
+
"docs": {
|
|
140
|
+
"tags": [],
|
|
141
|
+
"text": "Evento disparado quando a aplica\u00E7\u00E3o for carregada."
|
|
142
|
+
},
|
|
143
|
+
"complexType": {
|
|
144
|
+
"original": "boolean",
|
|
145
|
+
"resolved": "boolean",
|
|
146
|
+
"references": {}
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
"method": "applicationLoading",
|
|
150
|
+
"name": "applicationLoading",
|
|
151
|
+
"bubbles": true,
|
|
152
|
+
"cancelable": true,
|
|
153
|
+
"composed": true,
|
|
154
|
+
"docs": {
|
|
155
|
+
"tags": [],
|
|
156
|
+
"text": "Evento"
|
|
157
|
+
},
|
|
158
|
+
"complexType": {
|
|
159
|
+
"original": "boolean",
|
|
160
|
+
"resolved": "boolean",
|
|
161
|
+
"references": {}
|
|
162
|
+
}
|
|
163
|
+
}]; }
|
|
164
|
+
static get methods() { return {
|
|
165
|
+
"getStringParam": {
|
|
166
|
+
"complexType": {
|
|
167
|
+
"signature": "(name: string) => Promise<string>",
|
|
168
|
+
"parameters": [{
|
|
169
|
+
"tags": [],
|
|
170
|
+
"text": ""
|
|
171
|
+
}],
|
|
172
|
+
"references": {
|
|
173
|
+
"Promise": {
|
|
174
|
+
"location": "global"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"return": "Promise<string>"
|
|
178
|
+
},
|
|
179
|
+
"docs": {
|
|
180
|
+
"text": "",
|
|
181
|
+
"tags": []
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"getIntParam": {
|
|
185
|
+
"complexType": {
|
|
186
|
+
"signature": "(name: string) => Promise<number>",
|
|
187
|
+
"parameters": [{
|
|
188
|
+
"tags": [],
|
|
189
|
+
"text": ""
|
|
190
|
+
}],
|
|
191
|
+
"references": {
|
|
192
|
+
"Promise": {
|
|
193
|
+
"location": "global"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"return": "Promise<number>"
|
|
197
|
+
},
|
|
198
|
+
"docs": {
|
|
199
|
+
"text": "",
|
|
200
|
+
"tags": []
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"getFloatParam": {
|
|
204
|
+
"complexType": {
|
|
205
|
+
"signature": "(name: string) => Promise<number>",
|
|
206
|
+
"parameters": [{
|
|
207
|
+
"tags": [],
|
|
208
|
+
"text": ""
|
|
209
|
+
}],
|
|
210
|
+
"references": {
|
|
211
|
+
"Promise": {
|
|
212
|
+
"location": "global"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"return": "Promise<number>"
|
|
216
|
+
},
|
|
217
|
+
"docs": {
|
|
218
|
+
"text": "",
|
|
219
|
+
"tags": []
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"getBooleanParam": {
|
|
223
|
+
"complexType": {
|
|
224
|
+
"signature": "(name: string) => Promise<boolean>",
|
|
225
|
+
"parameters": [{
|
|
226
|
+
"tags": [],
|
|
227
|
+
"text": ""
|
|
228
|
+
}],
|
|
229
|
+
"references": {
|
|
230
|
+
"Promise": {
|
|
231
|
+
"location": "global"
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"return": "Promise<boolean>"
|
|
235
|
+
},
|
|
236
|
+
"docs": {
|
|
237
|
+
"text": "",
|
|
238
|
+
"tags": []
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"getDateParam": {
|
|
242
|
+
"complexType": {
|
|
243
|
+
"signature": "(name: string) => Promise<Date>",
|
|
244
|
+
"parameters": [{
|
|
245
|
+
"tags": [],
|
|
246
|
+
"text": ""
|
|
247
|
+
}],
|
|
248
|
+
"references": {
|
|
249
|
+
"Promise": {
|
|
250
|
+
"location": "global"
|
|
251
|
+
},
|
|
252
|
+
"Date": {
|
|
253
|
+
"location": "global"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"return": "Promise<Date>"
|
|
257
|
+
},
|
|
258
|
+
"docs": {
|
|
259
|
+
"text": "",
|
|
260
|
+
"tags": []
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"temOpcional": {
|
|
264
|
+
"complexType": {
|
|
265
|
+
"signature": "(opcional: string) => Promise<boolean>",
|
|
266
|
+
"parameters": [{
|
|
267
|
+
"tags": [],
|
|
268
|
+
"text": ""
|
|
269
|
+
}],
|
|
270
|
+
"references": {
|
|
271
|
+
"Promise": {
|
|
272
|
+
"location": "global"
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"return": "Promise<boolean>"
|
|
276
|
+
},
|
|
277
|
+
"docs": {
|
|
278
|
+
"text": "",
|
|
279
|
+
"tags": []
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"getAttributeFromHTMLWrapper": {
|
|
283
|
+
"complexType": {
|
|
284
|
+
"signature": "(attribName: string) => Promise<string>",
|
|
285
|
+
"parameters": [{
|
|
286
|
+
"tags": [],
|
|
287
|
+
"text": ""
|
|
288
|
+
}],
|
|
289
|
+
"references": {
|
|
290
|
+
"Promise": {
|
|
291
|
+
"location": "global"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"return": "Promise<string>"
|
|
295
|
+
},
|
|
296
|
+
"docs": {
|
|
297
|
+
"text": "",
|
|
298
|
+
"tags": []
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"openApp": {
|
|
302
|
+
"complexType": {
|
|
303
|
+
"signature": "(resourceId: string, pkObject: Object) => Promise<void>",
|
|
304
|
+
"parameters": [{
|
|
305
|
+
"tags": [],
|
|
306
|
+
"text": ""
|
|
307
|
+
}, {
|
|
308
|
+
"tags": [],
|
|
309
|
+
"text": ""
|
|
310
|
+
}],
|
|
311
|
+
"references": {
|
|
312
|
+
"Promise": {
|
|
313
|
+
"location": "global"
|
|
314
|
+
},
|
|
315
|
+
"Object": {
|
|
316
|
+
"location": "global"
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
"return": "Promise<void>"
|
|
320
|
+
},
|
|
321
|
+
"docs": {
|
|
322
|
+
"text": "",
|
|
323
|
+
"tags": []
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"createDataunit": {
|
|
327
|
+
"complexType": {
|
|
328
|
+
"signature": "(entityName: string) => Promise<DataUnit>",
|
|
329
|
+
"parameters": [{
|
|
330
|
+
"tags": [],
|
|
331
|
+
"text": ""
|
|
332
|
+
}],
|
|
333
|
+
"references": {
|
|
334
|
+
"Promise": {
|
|
335
|
+
"location": "global"
|
|
336
|
+
},
|
|
337
|
+
"DataUnit": {
|
|
338
|
+
"location": "import",
|
|
339
|
+
"path": "@sankhyalabs/core"
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
"return": "Promise<DataUnit>"
|
|
343
|
+
},
|
|
344
|
+
"docs": {
|
|
345
|
+
"text": "",
|
|
346
|
+
"tags": []
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
"getResourceID": {
|
|
350
|
+
"complexType": {
|
|
351
|
+
"signature": "() => Promise<string>",
|
|
352
|
+
"parameters": [],
|
|
353
|
+
"references": {
|
|
354
|
+
"Promise": {
|
|
355
|
+
"location": "global"
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"return": "Promise<string>"
|
|
359
|
+
},
|
|
360
|
+
"docs": {
|
|
361
|
+
"text": "",
|
|
362
|
+
"tags": []
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
"alert": {
|
|
366
|
+
"complexType": {
|
|
367
|
+
"signature": "(title: string, message: string, icon?: string) => Promise<boolean>",
|
|
368
|
+
"parameters": [{
|
|
369
|
+
"tags": [],
|
|
370
|
+
"text": ""
|
|
371
|
+
}, {
|
|
372
|
+
"tags": [],
|
|
373
|
+
"text": ""
|
|
374
|
+
}, {
|
|
375
|
+
"tags": [],
|
|
376
|
+
"text": ""
|
|
377
|
+
}],
|
|
378
|
+
"references": {
|
|
379
|
+
"Promise": {
|
|
380
|
+
"location": "global"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
"return": "Promise<boolean>"
|
|
384
|
+
},
|
|
385
|
+
"docs": {
|
|
386
|
+
"text": "",
|
|
387
|
+
"tags": []
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
"error": {
|
|
391
|
+
"complexType": {
|
|
392
|
+
"signature": "(title: string, message: string, icon?: string) => Promise<boolean>",
|
|
393
|
+
"parameters": [{
|
|
394
|
+
"tags": [],
|
|
395
|
+
"text": ""
|
|
396
|
+
}, {
|
|
397
|
+
"tags": [],
|
|
398
|
+
"text": ""
|
|
399
|
+
}, {
|
|
400
|
+
"tags": [],
|
|
401
|
+
"text": ""
|
|
402
|
+
}],
|
|
403
|
+
"references": {
|
|
404
|
+
"Promise": {
|
|
405
|
+
"location": "global"
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
"return": "Promise<boolean>"
|
|
409
|
+
},
|
|
410
|
+
"docs": {
|
|
411
|
+
"text": "",
|
|
412
|
+
"tags": []
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
"confirm": {
|
|
416
|
+
"complexType": {
|
|
417
|
+
"signature": "(title: string, message: string, icon?: string, critical?: boolean) => Promise<boolean>",
|
|
418
|
+
"parameters": [{
|
|
419
|
+
"tags": [],
|
|
420
|
+
"text": ""
|
|
421
|
+
}, {
|
|
422
|
+
"tags": [],
|
|
423
|
+
"text": ""
|
|
424
|
+
}, {
|
|
425
|
+
"tags": [],
|
|
426
|
+
"text": ""
|
|
427
|
+
}, {
|
|
428
|
+
"tags": [],
|
|
429
|
+
"text": ""
|
|
430
|
+
}],
|
|
431
|
+
"references": {
|
|
432
|
+
"Promise": {
|
|
433
|
+
"location": "global"
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
"return": "Promise<boolean>"
|
|
437
|
+
},
|
|
438
|
+
"docs": {
|
|
439
|
+
"text": "",
|
|
440
|
+
"tags": []
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
"info": {
|
|
444
|
+
"complexType": {
|
|
445
|
+
"signature": "(message: string, options?: any) => Promise<void>",
|
|
446
|
+
"parameters": [{
|
|
447
|
+
"tags": [],
|
|
448
|
+
"text": ""
|
|
449
|
+
}, {
|
|
450
|
+
"tags": [],
|
|
451
|
+
"text": ""
|
|
452
|
+
}],
|
|
453
|
+
"references": {
|
|
454
|
+
"Promise": {
|
|
455
|
+
"location": "global"
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
"return": "Promise<void>"
|
|
459
|
+
},
|
|
460
|
+
"docs": {
|
|
461
|
+
"text": "",
|
|
462
|
+
"tags": []
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
"loadFormConfig": {
|
|
466
|
+
"complexType": {
|
|
467
|
+
"signature": "(name: string) => Promise<Array<FieldConfig>>",
|
|
468
|
+
"parameters": [{
|
|
469
|
+
"tags": [],
|
|
470
|
+
"text": ""
|
|
471
|
+
}],
|
|
472
|
+
"references": {
|
|
473
|
+
"Promise": {
|
|
474
|
+
"location": "global"
|
|
475
|
+
},
|
|
476
|
+
"FieldConfig": {
|
|
477
|
+
"location": "import",
|
|
478
|
+
"path": "@sankhyalabs/ezui/dist/types/components/ez-form/ez-form"
|
|
479
|
+
},
|
|
480
|
+
"Array": {
|
|
481
|
+
"location": "global"
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
"return": "Promise<FieldConfig[]>"
|
|
485
|
+
},
|
|
486
|
+
"docs": {
|
|
487
|
+
"text": "",
|
|
488
|
+
"tags": []
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}; }
|
|
492
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { batchRequests } from 'graphql-request';
|
|
2
|
+
export class HttpFetcher {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.watingRequestsById = new Map();
|
|
5
|
+
}
|
|
6
|
+
static get() {
|
|
7
|
+
if (!HttpFetcher.instance) {
|
|
8
|
+
HttpFetcher.instance = new HttpFetcher();
|
|
9
|
+
const application = document.querySelector(this.appTagName);
|
|
10
|
+
if (application === null) {
|
|
11
|
+
HttpFetcher.instance.resume();
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
|
|
15
|
+
application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return this.instance;
|
|
19
|
+
}
|
|
20
|
+
async callGraphQL(req) {
|
|
21
|
+
var _a;
|
|
22
|
+
const reqKey = this.getReqKey(req);
|
|
23
|
+
req.queryID = reqKey;
|
|
24
|
+
req.values.queryID = reqKey;
|
|
25
|
+
if (this.ready) {
|
|
26
|
+
return new Promise(async (resolve, reject) => {
|
|
27
|
+
let query = this.getQueryTemplate(req);
|
|
28
|
+
const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
|
|
29
|
+
if (res.errors.length > 0) {
|
|
30
|
+
reject(res);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
//resolve(res);
|
|
34
|
+
//FIXME: Precisamos trabalhar melhor a resposta, quem chamou
|
|
35
|
+
//a API não pode ficar responsavel por desempacotar... fiz uma
|
|
36
|
+
//gambiarra aqui...
|
|
37
|
+
resolve(res.data[0][reqKey]);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (!this.watingRequestsById.has(reqKey)) {
|
|
43
|
+
this.watingRequestsById.set(reqKey, new WaitingRequest(req));
|
|
44
|
+
}
|
|
45
|
+
return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getReqKey(req) {
|
|
49
|
+
return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
|
|
50
|
+
}
|
|
51
|
+
getQueryTemplate(re) {
|
|
52
|
+
return (re.query || "").replaceAll("$queryAlias$", re.queryID);
|
|
53
|
+
}
|
|
54
|
+
getWatingRequest(reqID) {
|
|
55
|
+
return this.watingRequestsById.get(reqID);
|
|
56
|
+
}
|
|
57
|
+
pause() {
|
|
58
|
+
this.ready = false;
|
|
59
|
+
}
|
|
60
|
+
async resume() {
|
|
61
|
+
this.ready = true;
|
|
62
|
+
if (this.watingRequestsById.size > 0) {
|
|
63
|
+
const requestsBatch = [];
|
|
64
|
+
this.watingRequestsById.forEach(async (waitingReq) => {
|
|
65
|
+
let query = this.getQueryTemplate(waitingReq.request);
|
|
66
|
+
requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
|
|
67
|
+
});
|
|
68
|
+
let res = undefined;
|
|
69
|
+
let dataResponse = [];
|
|
70
|
+
let errorsResponse = [];
|
|
71
|
+
res = await this.fecthGrapql(requestsBatch);
|
|
72
|
+
dataResponse = res.data;
|
|
73
|
+
errorsResponse = res.errors;
|
|
74
|
+
//Reject promises with errors from query
|
|
75
|
+
errorsResponse.forEach((errorResponse) => {
|
|
76
|
+
Object.entries(errorResponse).forEach(([_key, val]) => {
|
|
77
|
+
var _a;
|
|
78
|
+
(((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
//Resolve promises with data from query
|
|
82
|
+
dataResponse.forEach((data) => {
|
|
83
|
+
Object.entries(data).forEach(([key, val]) => {
|
|
84
|
+
var _a;
|
|
85
|
+
(((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
this.watingRequestsById.clear();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async fecthGrapql(request) {
|
|
92
|
+
let res = undefined;
|
|
93
|
+
let dataResponse = [];
|
|
94
|
+
let errorsResponse = [];
|
|
95
|
+
try {
|
|
96
|
+
res = await batchRequests('http://localhost:8082/', request);
|
|
97
|
+
res.forEach((resItem) => {
|
|
98
|
+
dataResponse.push(resItem.data);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
//TODO: Tratar erro quando não existir err.response
|
|
103
|
+
res = err.response;
|
|
104
|
+
const req = err.request;
|
|
105
|
+
Object.entries(res).forEach(([key, val]) => {
|
|
106
|
+
if (val.errors) {
|
|
107
|
+
errorsResponse.push(val.errors.map((item) => {
|
|
108
|
+
item.request = req;
|
|
109
|
+
item.index = Number(key);
|
|
110
|
+
return item;
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
else if (val.data) {
|
|
114
|
+
dataResponse.push(val.data);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return { data: dataResponse, errors: errorsResponse };
|
|
119
|
+
}
|
|
120
|
+
//TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
|
|
121
|
+
hashCode(txt) {
|
|
122
|
+
var hash = 0, i, chr;
|
|
123
|
+
if (txt.length === 0)
|
|
124
|
+
return hash.toString();
|
|
125
|
+
for (i = 0; i < txt.length; i++) {
|
|
126
|
+
chr = txt.charCodeAt(i);
|
|
127
|
+
hash = ((hash << 5) - hash) + chr;
|
|
128
|
+
hash |= 0; // Convert to 32bit integer
|
|
129
|
+
}
|
|
130
|
+
return hash.toString();
|
|
131
|
+
}
|
|
132
|
+
;
|
|
133
|
+
}
|
|
134
|
+
HttpFetcher.appTagName = "snk-application";
|
|
135
|
+
class WaitingRequest {
|
|
136
|
+
constructor(req) {
|
|
137
|
+
this._resolve = () => { };
|
|
138
|
+
this._reject = () => { };
|
|
139
|
+
this._request = undefined;
|
|
140
|
+
this._request = req;
|
|
141
|
+
this._promisse = new Promise((resolve, reject) => {
|
|
142
|
+
this._resolve = resolve;
|
|
143
|
+
this._reject = reject;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
get resolve() {
|
|
147
|
+
return this._resolve;
|
|
148
|
+
}
|
|
149
|
+
get reject() {
|
|
150
|
+
return this._reject;
|
|
151
|
+
}
|
|
152
|
+
get promise() {
|
|
153
|
+
return this._promisse;
|
|
154
|
+
}
|
|
155
|
+
get request() {
|
|
156
|
+
return this._request;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { gql } from "graphql-request";
|
|
2
|
+
import { HttpFetcher } from "../DataFetcher";
|
|
3
|
+
export default class ApplicationConfigFetcher {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.templateByQuery = new Map();
|
|
6
|
+
this.buldTemplates();
|
|
7
|
+
}
|
|
8
|
+
buldTemplates() {
|
|
9
|
+
this.templateByQuery.set("getResource", gql `query($name: String!) {
|
|
10
|
+
$queryAlias$: getResource(name: $name){
|
|
11
|
+
name
|
|
12
|
+
resource
|
|
13
|
+
}
|
|
14
|
+
}`);
|
|
15
|
+
}
|
|
16
|
+
getResource(name, resourceID) {
|
|
17
|
+
const completPath = `cfg://app/${resourceID}/${name}`;
|
|
18
|
+
return HttpFetcher.get().callGraphQL({
|
|
19
|
+
values: { name: completPath },
|
|
20
|
+
query: this.templateByQuery.get("getResource"),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|