@apia/api 3.0.1 → 3.0.6

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiaApi.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/apiaApi.js DELETED
@@ -1,458 +0,0 @@
1
- import axios from 'axios';
2
- import merge from 'lodash-es/merge';
3
- import QueryString from 'qs';
4
- import { session } from '@apia/session';
5
- import { debugDispatcher, parseXmlAsync, EventEmitter, arrayOrArray } from '@apia/util';
6
- import { notify, getNotificationMessageObj, dispatchNotifications } from '@apia/notifications';
7
- import { handle } from './ApiaApiHandler.js';
8
-
9
- debugDispatcher.on(
10
- "parseXml",
11
- async ([text]) => {
12
- const result = await parseXmlAsync(text);
13
- console.info(result);
14
- },
15
- "Acepta un par\xE1metro de tipo string y realiza un parseo como si fuera xml, convirti\xE9ndolo a objeto javascript."
16
- );
17
- const defaultConfig = {
18
- debug: false,
19
- colors: {
20
- exception: "red",
21
- alert: "yellow",
22
- message: "lightgreen"
23
- },
24
- handleLoad: false
25
- };
26
- const STORED_CONFIG = "ApiaApiConfig";
27
- let forcedConfig = {};
28
- const storedConfig = localStorage.getItem(STORED_CONFIG);
29
- if (storedConfig)
30
- forcedConfig = JSON.parse(storedConfig);
31
- function getConfig(outerBehaveConfig) {
32
- return merge({}, defaultConfig, outerBehaveConfig, forcedConfig);
33
- }
34
- function makeUrl(url, queryData, stringifyOptions) {
35
- let finalUrl = url;
36
- const questionMarkIndex = finalUrl.indexOf("?");
37
- if (questionMarkIndex === -1)
38
- finalUrl += "?";
39
- else if (questionMarkIndex !== finalUrl.length - 1 && !finalUrl.endsWith("&"))
40
- finalUrl += "&";
41
- let parsedUrl = `${finalUrl}${queryData ? QueryString.stringify(queryData, stringifyOptions) : ""}`;
42
- if (parsedUrl.endsWith("&") || parsedUrl.endsWith("?")) {
43
- parsedUrl = parsedUrl.slice(0, parsedUrl.length - 1);
44
- }
45
- return parsedUrl;
46
- }
47
- const getURLActionName = (url) => {
48
- const actionIdx = url.match(/action=(\w+)/)?.[1];
49
- return actionIdx ?? "noAction";
50
- };
51
- class ApiaActionsClass extends EventEmitter {
52
- }
53
- const ApiaActions = new ApiaActionsClass();
54
- function getColor(color, colors = defaultConfig.colors ?? {
55
- exception: "red",
56
- alert: "yellow",
57
- message: "green"
58
- }) {
59
- return colors[color];
60
- }
61
- const handleWrongResponse = (error) => {
62
- let errorMessage;
63
- if (typeof error !== "string") {
64
- if (error.message)
65
- errorMessage = error.message;
66
- else
67
- errorMessage = error.toString();
68
- } else
69
- errorMessage = error;
70
- notify({
71
- type: "danger",
72
- message: error.message.replaceAll("AxiosError", "Error")
73
- });
74
- console.log("%c ", "font-size:10vh");
75
- console.log("%cError in ApiaApi", "color:red;font-size:2em;font-weight:bold");
76
- console.log(`red/${errorMessage}`, { error });
77
- console.log("%c ", "font-size:10vh");
78
- };
79
- function isJsonResponse(response) {
80
- return response.headers["content-type"].match("application/json");
81
- }
82
- function isXmlResponse(response) {
83
- return response.headers["content-type"].match(
84
- /(?:application|text)?\/xml/
85
- );
86
- }
87
- function isHtmlResponse(response) {
88
- return response.headers["content-type"].match(
89
- /(?:application|text)?\/html/
90
- );
91
- }
92
- function handleActions(actions) {
93
- if (actions) {
94
- if (getConfig().debug)
95
- console.log(
96
- "%cHandled actions: ",
97
- `color: ${getConfig().colors?.message ?? "green"}`,
98
- { actions }
99
- );
100
- const actionsArray = arrayOrArray(actions.action);
101
- actionsArray.forEach((action) => {
102
- ApiaActions.emit("action", {
103
- ...action,
104
- param: arrayOrArray(action.param)
105
- });
106
- });
107
- }
108
- }
109
- function handleOnClose({
110
- exceptions,
111
- onClose,
112
- sysExceptions,
113
- sysMessages
114
- }) {
115
- try {
116
- import(
117
- /* webpackChunkName: "api-[request]" */
118
- `/api/onClose/${onClose}.ts`
119
- ).then(
120
- (func) => {
121
- if (exceptions || sysExceptions || sysMessages) {
122
- const notificationsObject = getNotificationMessageObj({
123
- exceptions,
124
- onClose,
125
- sysExceptions,
126
- sysMessages
127
- });
128
- if (notificationsObject)
129
- notificationsObject.forEach((notification) => {
130
- notify({
131
- ...notification,
132
- onClose: func.default
133
- });
134
- });
135
- else
136
- func.default();
137
- } else
138
- func.default();
139
- },
140
- (e) => {
141
- notify({
142
- message: `onClose action not found: ${String(e)}`,
143
- type: "danger"
144
- });
145
- }
146
- );
147
- } catch (e) {
148
- parseMessages({ exceptions, sysExceptions, sysMessages });
149
- console.error("Error while handling onClose");
150
- console.error(e);
151
- }
152
- }
153
- function parseMessages(response) {
154
- if (!response)
155
- return;
156
- const { exceptions, sysMessages, sysExceptions } = response;
157
- if (exceptions || sysExceptions || sysMessages) {
158
- try {
159
- dispatchNotifications({
160
- exceptions,
161
- sysExceptions,
162
- sysMessages
163
- });
164
- } catch (e) {
165
- handleWrongResponse(new Error(e));
166
- }
167
- }
168
- }
169
- const parseSuccessfulResponse = async (response, currentUrl, outerBehaveConfig = defaultConfig) => {
170
- const behaveConfig = getConfig(outerBehaveConfig);
171
- let parsedObj = void 0;
172
- if (isJsonResponse(response)) {
173
- if (typeof response.data === "string")
174
- parsedObj = JSON.parse(
175
- response.data.trim()
176
- );
177
- else if (typeof response.data === "object" && response.data)
178
- parsedObj = response.data;
179
- } else if (isXmlResponse(response)) {
180
- parsedObj = await parseXmlAsync(response.data).catch(
181
- (e) => {
182
- handleWrongResponse(new Error(e));
183
- }
184
- );
185
- } else if (isHtmlResponse(response)) {
186
- console.error(
187
- "El contenido devuelto es Html, no se esperaba esa respuesta"
188
- );
189
- return null;
190
- }
191
- if (behaveConfig.validateResponse) {
192
- const validateResult = await behaveConfig.validateResponse({
193
- ...response,
194
- data: parsedObj?.load ?? parsedObj
195
- });
196
- if (typeof validateResult === "string")
197
- throw new Error(`Validation error: ${validateResult}`);
198
- else if (!validateResult) {
199
- throw new Error("Error");
200
- }
201
- }
202
- if (parsedObj) {
203
- const {
204
- actions,
205
- onClose,
206
- exceptions,
207
- sysExceptions,
208
- sysMessages,
209
- load,
210
- ...rest
211
- } = parsedObj;
212
- if (rest.code === "-1" && exceptions) {
213
- session.invalidate();
214
- return null;
215
- }
216
- if (exceptions && behaveConfig.debug) {
217
- console.log(
218
- `%cparseSuccessfulResponse`,
219
- `color: ${getColor("exception", behaveConfig.colors)}`,
220
- {
221
- exceptions
222
- }
223
- );
224
- }
225
- if (sysExceptions && behaveConfig.debug) {
226
- console.log(
227
- `%cparseSuccessfulResponse`,
228
- `color: ${getColor("exception", behaveConfig.colors)}`,
229
- {
230
- sysExceptions
231
- }
232
- );
233
- }
234
- if (sysMessages && behaveConfig.debug) {
235
- console.log(
236
- `%cparseSuccessfulResponse`,
237
- `color: ${getColor("alert", behaveConfig.colors)}`,
238
- {
239
- sysMessages
240
- }
241
- );
242
- }
243
- handleActions(actions);
244
- if (behaveConfig.handleLoad && onClose)
245
- handleOnClose({
246
- exceptions,
247
- onClose,
248
- sysExceptions,
249
- sysMessages
250
- });
251
- else
252
- parseMessages({ exceptions, sysExceptions, sysMessages });
253
- if (load) {
254
- if (behaveConfig.handleLoad) {
255
- console.log(
256
- `%chandleLoad`,
257
- `color: ${getColor("message", behaveConfig.colors)}`,
258
- {
259
- load
260
- }
261
- );
262
- if (!handle(load, currentUrl, {
263
- methodsPath: outerBehaveConfig.methodsPath,
264
- modalConfiguration: {
265
- ...behaveConfig.modalConfiguration,
266
- onClose: () => {
267
- if (onClose)
268
- handleOnClose({
269
- exceptions,
270
- onClose,
271
- sysExceptions,
272
- sysMessages
273
- });
274
- if (behaveConfig.modalConfiguration?.onClose)
275
- behaveConfig.modalConfiguration?.onClose();
276
- }
277
- }
278
- })) {
279
- console.log(
280
- `%cunhandledLoad -> There is no handler defined`,
281
- `color: ${getColor("exception", behaveConfig.colors)}`,
282
- {
283
- load
284
- }
285
- );
286
- }
287
- }
288
- return { ...load, sysMessages, exceptions, sysExceptions };
289
- }
290
- return { ...rest, sysMessages, exceptions, sysExceptions };
291
- }
292
- return null;
293
- };
294
- async function handleResponse(result, currentUrl, outerBehaveConfig = defaultConfig) {
295
- const behaveConfig = getConfig(outerBehaveConfig);
296
- try {
297
- if (!result || result.data === void 0) {
298
- if (behaveConfig.debug)
299
- console.log(
300
- `%cApiaApi wrong response`,
301
- `color: ${getColor("alert", behaveConfig.colors)}`
302
- );
303
- } else {
304
- const parsedResponse = await parseSuccessfulResponse(
305
- result,
306
- currentUrl,
307
- behaveConfig
308
- );
309
- const action = getURLActionName(currentUrl);
310
- if (behaveConfig.debug)
311
- console.log(
312
- `%c <- ApiaApi.${result.config.method ?? ""} ${action} `,
313
- `color: ${getColor("message", behaveConfig.colors)}`,
314
- {
315
- data: parsedResponse
316
- }
317
- );
318
- return {
319
- ...result,
320
- data: parsedResponse,
321
- hasError: !!parsedResponse?.exceptions || !!parsedResponse?.sysExceptions,
322
- hasMessages: !!parsedResponse?.sysMessages
323
- };
324
- }
325
- } catch (e) {
326
- handleWrongResponse(new Error(e));
327
- return null;
328
- }
329
- return null;
330
- }
331
- async function post(par1, par2) {
332
- const actualUrl = typeof par1 !== "string" ? makeApiaUrl() : par1;
333
- const configParameter = typeof par1 === "string" ? par2 ?? defaultConfig : par1;
334
- const behaveConfig = {
335
- ...getConfig(configParameter),
336
- postData: configParameter.postDataTreatement === "stringify" ? QueryString.stringify(
337
- configParameter.postData,
338
- configParameter.stringifyOptions
339
- ) : configParameter.postData
340
- };
341
- const parsedUrl = makeUrl(
342
- actualUrl,
343
- behaveConfig.queryData,
344
- behaveConfig.stringifyOptions
345
- );
346
- if (behaveConfig.debug) {
347
- const queryString = actualUrl.split("&");
348
- const action = getURLActionName(actualUrl);
349
- console.log(
350
- `%cApiaApi.post ${action}`,
351
- `color: ${getColor("message", behaveConfig.colors)}`,
352
- {
353
- url: parsedUrl,
354
- queryDataInURL: [...queryString],
355
- queryData: behaveConfig.queryData,
356
- formData: behaveConfig.postData,
357
- stringifyOptiopns: behaveConfig.stringifyOptions
358
- }
359
- );
360
- }
361
- const response = await axios.post(parsedUrl, behaveConfig.postData, behaveConfig.axiosConfig).catch((e) => {
362
- handleWrongResponse(new Error(e));
363
- });
364
- if (response) {
365
- const result = handleResponse(response, actualUrl, behaveConfig);
366
- return result;
367
- }
368
- return null;
369
- }
370
- async function get(par1, par2) {
371
- const actualUrl = typeof par1 !== "string" ? makeApiaUrl() : par1;
372
- const behaveConfig = getConfig(
373
- typeof par1 === "string" ? par2 ?? defaultConfig : par1
374
- );
375
- const parsedUrl = makeUrl(
376
- actualUrl,
377
- behaveConfig.queryData,
378
- behaveConfig.stringifyOptions
379
- );
380
- if (behaveConfig.debug)
381
- console.log(
382
- `%cApiaApi.get`,
383
- `color: ${getColor("message", behaveConfig.colors)}`,
384
- {
385
- url: parsedUrl
386
- }
387
- );
388
- const response = await axios.get(parsedUrl, behaveConfig.axiosConfig).catch((e) => {
389
- handleWrongResponse(new Error(e));
390
- });
391
- if (response) {
392
- const result = await handleResponse(
393
- response,
394
- actualUrl,
395
- behaveConfig
396
- );
397
- return result;
398
- }
399
- return null;
400
- }
401
- const ApiaApi = {
402
- get,
403
- getConfig,
404
- post
405
- };
406
- function makeApiaUrl(props) {
407
- let actualQueryData = {};
408
- if (props) {
409
- const {
410
- ajaxUrl,
411
- queryString: queryString2,
412
- stringifyOptions,
413
- shouldAvoidTabId,
414
- preventAsXmlParameter,
415
- avoidTabId,
416
- tabId: outerTabId,
417
- ...rest
418
- } = props;
419
- actualQueryData = { ...rest };
420
- }
421
- const queryString = QueryString.stringify(
422
- actualQueryData,
423
- props?.stringifyOptions ?? {
424
- arrayFormat: "repeat",
425
- encodeValuesOnly: false
426
- }
427
- );
428
- let actualAjaxUrl = props?.ajaxUrl ?? window.URL_REQUEST_AJAX;
429
- if (actualAjaxUrl.indexOf("?") === actualAjaxUrl.length - 1) {
430
- actualAjaxUrl = actualAjaxUrl.slice(0, actualAjaxUrl.length - 1);
431
- }
432
- if (!actualAjaxUrl.startsWith("/")) {
433
- actualAjaxUrl = `/${actualAjaxUrl}`;
434
- }
435
- const match = window.TAB_ID_REQUEST.match(/tokenId=(\w+)/);
436
- const currentTokenId = (match ?? [])[1];
437
- let tabId = (props?.tabId ? `&tabId=${props.tabId}&tokenId=${currentTokenId}` : window.TAB_ID_REQUEST).slice(1);
438
- if (props?.avoidTabId) {
439
- tabId = "";
440
- }
441
- let { CONTEXT } = window;
442
- if (CONTEXT?.endsWith("/")) {
443
- CONTEXT += CONTEXT.slice(0, CONTEXT.length - 1);
444
- }
445
- let timestamp = `timestamp=${Date.now()}&`;
446
- if (props?.queryString && props.queryString.includes("timestamp=") || queryString?.includes("timestamp=")) {
447
- timestamp = "";
448
- }
449
- const contextWord = CONTEXT.replaceAll("/", "");
450
- actualAjaxUrl = actualAjaxUrl.match(
451
- new RegExp(`^(?:(?:/?${contextWord})?/)?(.+)$`)
452
- )?.[1];
453
- return `${contextWord ? "/" : ""}${contextWord}/${actualAjaxUrl}?${timestamp}${!props?.preventAsXmlParameter ? "asXml=true&" : ""}${props?.queryString ? `${props.queryString}&` : ""}${queryString ? `${queryString}&` : ""}${tabId}`;
454
- }
455
- var ApiaApi$1 = ApiaApi;
456
-
457
- export { ApiaActions, ApiaApi$1 as default, isHtmlResponse, isJsonResponse, isXmlResponse, makeApiaUrl, parseMessages, parseSuccessfulResponse };
458
- //# sourceMappingURL=apiaApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiaApi.js","sources":["../src/apiaApi.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-invalid-void-type */\nimport axios, { AxiosResponse } from 'axios';\nimport merge from 'lodash-es/merge';\nimport QueryString from 'qs';\nimport { session } from '@apia/session';\nimport {\n arrayOrArray,\n parseXmlAsync,\n EventEmitter,\n TModify,\n TApiaAction,\n TApiaSystemMessageObj,\n debugDispatcher,\n TNotificationMessage,\n} from '@apia/util';\nimport {\n dispatchNotifications,\n getNotificationMessageObj,\n notify,\n} from '@apia/notifications';\nimport { handle } from './ApiaApiHandler';\nimport {\n IApiaApiRequestConfig,\n TApiaApiConfigurator,\n TApiaApiResult,\n TColors,\n} from './types';\n\ndebugDispatcher.on(\n 'parseXml',\n async ([text]) => {\n const result = await parseXmlAsync<unknown>(text as string);\n console.info(result);\n },\n 'Acepta un parámetro de tipo string y realiza un parseo como si fuera xml, convirtiéndolo a objeto javascript.',\n);\n\nconst defaultConfig: IApiaApiRequestConfig<unknown> = {\n debug: false,\n colors: {\n exception: 'red',\n alert: 'yellow',\n message: 'lightgreen',\n },\n handleLoad: false,\n};\n\nconst STORED_CONFIG = 'ApiaApiConfig';\n\nlet forcedConfig: Partial<IApiaApiRequestConfig<unknown>> = {};\nconst storedConfig = localStorage.getItem(STORED_CONFIG);\nif (storedConfig)\n forcedConfig = JSON.parse(storedConfig) as Partial<\n IApiaApiRequestConfig<unknown>\n >;\n\nexport function getApiaApiConfigurator(): TApiaApiConfigurator {\n return {\n reset() {\n forcedConfig = {};\n localStorage.removeItem(STORED_CONFIG);\n },\n config(newConfig) {\n if (\n newConfig.notificationsCategory ||\n newConfig.axiosConfig ||\n newConfig.modalConfiguration ||\n newConfig.handleLoad ||\n newConfig.queryData ||\n newConfig.stringifyOptions ||\n newConfig.validateResponse\n )\n throw new Error('Operación ilegal');\n\n const toStoreConfig = merge(forcedConfig, newConfig);\n localStorage.setItem(STORED_CONFIG, JSON.stringify(toStoreConfig));\n forcedConfig = toStoreConfig;\n console.log('Se guardó la configuración correctamente', {\n config: toStoreConfig,\n });\n },\n shout() {\n console.log({ config: getConfig({}) });\n },\n theme(theme) {\n if (theme.toLowerCase() === 'dark') {\n getApiaApiConfigurator().config({\n colors: {\n exception: 'red',\n alert: 'yellow',\n message: 'lightgreen',\n },\n });\n } else if (theme.toLowerCase() === 'light') {\n getApiaApiConfigurator().config({\n colors: {\n exception: 'red',\n alert: '#e0e006',\n message: 'darkgreen',\n },\n });\n } else {\n console.log(`Tema ${theme} desconocido, prueba 'light' o 'dark'.`);\n return;\n }\n\n console.log(`Tema ${theme} establecido correctamente.`);\n },\n };\n}\n\nfunction getConfig<LoadType>(\n outerBehaveConfig?: IApiaApiRequestConfig<LoadType>,\n) {\n return merge({}, defaultConfig, outerBehaveConfig, forcedConfig);\n}\n\nfunction makeUrl(\n url: string,\n queryData: IApiaApiRequestConfig<unknown>['queryData'],\n stringifyOptions: IApiaApiRequestConfig<unknown>['stringifyOptions'],\n) {\n let finalUrl = url;\n const questionMarkIndex = finalUrl.indexOf('?');\n\n if (questionMarkIndex === -1) finalUrl += '?';\n else if (questionMarkIndex !== finalUrl.length - 1 && !finalUrl.endsWith('&'))\n finalUrl += '&';\n let parsedUrl = `${finalUrl}${\n queryData ? QueryString.stringify(queryData, stringifyOptions) : ''\n }`;\n if (parsedUrl.endsWith('&') || parsedUrl.endsWith('?')) {\n parsedUrl = parsedUrl.slice(0, parsedUrl.length - 1);\n }\n return parsedUrl;\n}\n\nconst getURLActionName = (url: string): string => {\n const actionIdx = url.match(/action=(\\w+)/)?.[1];\n return actionIdx ?? 'noAction';\n};\n\nclass ApiaActionsClass extends EventEmitter<{\n action: TModify<TApiaAction, { param: string[] }>;\n}> {}\n\nexport const ApiaActions = new ApiaActionsClass();\n\nfunction getColor(\n color: keyof TColors,\n colors: TColors = defaultConfig.colors ?? {\n exception: 'red',\n alert: 'yellow',\n message: 'green',\n },\n) {\n return colors[color] as string;\n}\n\nconst handleWrongResponse = (error: Error) => {\n let errorMessage: string;\n if (typeof error !== 'string') {\n if (error.message) errorMessage = error.message;\n else errorMessage = error.toString();\n } else errorMessage = error;\n\n notify({\n type: 'danger',\n message: error.message.replaceAll('AxiosError', 'Error'),\n });\n console.log('%c ', 'font-size:10vh');\n console.log('%cError in ApiaApi', 'color:red;font-size:2em;font-weight:bold');\n console.log(`red/${errorMessage}`, { error });\n console.log('%c ', 'font-size:10vh');\n};\n\nexport function isJsonResponse(response: AxiosResponse<unknown>) {\n return (response.headers['content-type'] as string).match('application/json');\n}\nexport function isXmlResponse(response: AxiosResponse<unknown>) {\n return (response.headers['content-type'] as string).match(\n /(?:application|text)?\\/xml/,\n );\n}\nexport function isHtmlResponse(response: AxiosResponse<unknown>) {\n return (response.headers['content-type'] as string).match(\n /(?:application|text)?\\/html/,\n );\n}\n\nfunction handleActions(actions: TApiaSystemMessageObj['actions']) {\n if (actions) {\n if (getConfig().debug)\n console.log(\n '%cHandled actions: ',\n `color: ${getConfig().colors?.message ?? 'green'}`,\n { actions },\n );\n const actionsArray = arrayOrArray(actions.action);\n actionsArray.forEach((action) => {\n ApiaActions.emit('action', {\n ...action,\n param: arrayOrArray(action.param),\n });\n });\n }\n}\nfunction handleOnClose({\n exceptions,\n onClose,\n sysExceptions,\n sysMessages,\n}: TModify<TNotificationMessage, { onClose: string }>) {\n try {\n import(\n /* webpackChunkName: \"api-[request]\" */ `/api/onClose/${onClose}.ts`\n ).then(\n (func: { default: () => void }) => {\n if (exceptions || sysExceptions || sysMessages) {\n const notificationsObject = getNotificationMessageObj({\n exceptions,\n onClose,\n sysExceptions,\n sysMessages,\n });\n if (notificationsObject)\n notificationsObject.forEach((notification) => {\n notify({\n ...notification,\n onClose: func.default,\n });\n });\n else func.default();\n } else func.default();\n },\n (e) => {\n notify({\n message: `onClose action not found: ${String(e)}`,\n type: 'danger',\n });\n },\n );\n } catch (e) {\n parseMessages({ exceptions, sysExceptions, sysMessages });\n console.error('Error while handling onClose');\n console.error(e);\n }\n}\n\nexport function parseMessages(response: Record<string, unknown>) {\n if (!response) return;\n const { exceptions, sysMessages, sysExceptions } = response;\n if (exceptions || sysExceptions || sysMessages) {\n try {\n dispatchNotifications({\n exceptions,\n sysExceptions,\n sysMessages,\n } as TNotificationMessage);\n } catch (e: unknown) {\n handleWrongResponse(new Error(e as string));\n }\n }\n}\n\nexport const parseSuccessfulResponse = async <\n LoadType extends Record<string, unknown>,\n>(\n response: AxiosResponse<string>,\n currentUrl: string,\n outerBehaveConfig: IApiaApiRequestConfig<LoadType> = defaultConfig,\n) => {\n const behaveConfig = getConfig(outerBehaveConfig);\n\n let parsedObj: TApiaSystemMessageObj<LoadType> | void | undefined = undefined;\n if (isJsonResponse(response)) {\n if (typeof response.data === 'string')\n parsedObj = JSON.parse(\n response.data.trim(),\n ) as TApiaSystemMessageObj<LoadType> | void;\n else if (typeof response.data === 'object' && response.data)\n parsedObj = response.data;\n } else if (isXmlResponse(response)) {\n parsedObj = await parseXmlAsync<LoadType>(response.data).catch(\n (e: unknown) => {\n handleWrongResponse(new Error(e as string));\n },\n );\n } else if (isHtmlResponse(response)) {\n console.error(\n 'El contenido devuelto es Html, no se esperaba esa respuesta',\n );\n return null;\n }\n\n if (behaveConfig.validateResponse) {\n const validateResult = await behaveConfig.validateResponse({\n ...response,\n data: parsedObj?.load ?? parsedObj,\n });\n if (typeof validateResult === 'string')\n throw new Error(`Validation error: ${validateResult}`);\n else if (!validateResult) {\n throw new Error('Error');\n }\n }\n\n if (parsedObj) {\n const {\n actions,\n onClose,\n exceptions,\n sysExceptions,\n sysMessages,\n load,\n ...rest\n } = parsedObj; // Session handling\n if (rest.code === '-1' && exceptions) {\n session.invalidate();\n return null;\n }\n\n if (exceptions && behaveConfig.debug) {\n console.log(\n `%cparseSuccessfulResponse`,\n `color: ${getColor('exception', behaveConfig.colors)}`,\n {\n exceptions,\n },\n );\n }\n if (sysExceptions && behaveConfig.debug) {\n console.log(\n `%cparseSuccessfulResponse`,\n `color: ${getColor('exception', behaveConfig.colors)}`,\n {\n sysExceptions,\n },\n );\n }\n if (sysMessages && behaveConfig.debug) {\n console.log(\n `%cparseSuccessfulResponse`,\n `color: ${getColor('alert', behaveConfig.colors)}`,\n {\n sysMessages,\n },\n );\n }\n\n handleActions(actions);\n\n if (behaveConfig.handleLoad && onClose)\n handleOnClose({\n exceptions,\n onClose,\n sysExceptions,\n sysMessages,\n });\n else parseMessages({ exceptions, sysExceptions, sysMessages });\n\n if (load) {\n if (behaveConfig.handleLoad) {\n console.log(\n `%chandleLoad`,\n `color: ${getColor('message', behaveConfig.colors)}`,\n {\n load,\n },\n );\n if (\n !handle(load, currentUrl, {\n methodsPath: outerBehaveConfig.methodsPath,\n modalConfiguration: {\n ...behaveConfig.modalConfiguration,\n onClose: () => {\n if (onClose)\n handleOnClose({\n exceptions,\n onClose,\n sysExceptions,\n sysMessages,\n });\n if (behaveConfig.modalConfiguration?.onClose)\n behaveConfig.modalConfiguration?.onClose();\n },\n },\n })\n ) {\n console.log(\n `%cunhandledLoad -> There is no handler defined`,\n `color: ${getColor('exception', behaveConfig.colors)}`,\n {\n load,\n },\n );\n }\n }\n return { ...load, sysMessages, exceptions, sysExceptions };\n }\n return { ...(rest as LoadType), sysMessages, exceptions, sysExceptions };\n }\n\n return null;\n};\n\nexport type TApiaApiAxiosResponse<LoadType> = AxiosResponse<LoadType | null> & {\n hasError: boolean;\n hasMessages: boolean;\n};\n\nasync function handleResponse<LoadType extends Record<string, unknown>>(\n result: AxiosResponse<string> | void,\n currentUrl: string,\n outerBehaveConfig: IApiaApiRequestConfig<LoadType> = defaultConfig,\n): Promise<TApiaApiAxiosResponse<LoadType> | null> {\n const behaveConfig = getConfig(outerBehaveConfig);\n try {\n if (!result || result.data === undefined) {\n if (behaveConfig.debug)\n console.log(\n `%cApiaApi wrong response`,\n `color: ${getColor('alert', behaveConfig.colors)}`,\n );\n } else {\n const parsedResponse = await parseSuccessfulResponse<LoadType>(\n result,\n currentUrl,\n behaveConfig,\n );\n\n const action = getURLActionName(currentUrl);\n if (behaveConfig.debug)\n console.log(\n `%c <- ApiaApi.${result.config.method ?? ''} ${action} `,\n `color: ${getColor('message', behaveConfig.colors)}`,\n {\n data: parsedResponse,\n },\n );\n\n return {\n ...result,\n data: parsedResponse,\n hasError:\n !!parsedResponse?.exceptions || !!parsedResponse?.sysExceptions,\n hasMessages: !!parsedResponse?.sysMessages,\n };\n }\n } catch (e: unknown) {\n handleWrongResponse(new Error(e as string));\n return null;\n }\n\n return null;\n}\n\n/**\n* IMPORTANT!! The ApiaApi is programmed under the slogan that\n * **should never throw an exception**. **Errors** coming from\n * connectivity or exceptions on the server **will be handled\n * automatically** by ApiaApi, using the notification system\n * of the application. It is possible to determine in what context they should\n * be thrown those exceptions (global, main, modal) using the\n * alertsCategory configuration properties **(see errorsHandling.md)**.\n *\n * @param url String, the url you want to call\n * @param config interface IApiaApiRequestConfig<DataType>;\n *\n * @throws Nothing\n *\n * @example\n *\n * ApiaApi.post<ResponseType>('url...', {\n axiosConfig?: AxiosRequestConfig;\n\n // Configuración de postData\n postData? unknown;\n postDataTreatement?: 'stringify' | undefined;\n\n // Configuración de queryString\n queryData?: string | Record<string, unknown>;\n stringifyOptions?: QueryString.IStringifyOptions;\n\n // Response validator,\n // If it returns true, everything continues correctly\n // If it returns false, the ApiaApi throws a standard error.\n // If it returns string, ApiaApi throws the error returned in the string.\n validateResponse?: (\n response: AxiosResponse<DataType | null>,\n ) => boolean | string;\n\n // Configuración de alertas\n alertsImportance?: TAlertImportance;\n\n // Configuración de ApiaApiHandler, falta documentar\n handleLoad?: boolean;\n eventsHandler?: IEventsHandler;\n\n // other configuration\n colors?: TColors;\n debug?: boolean;\n }\n * @returns The type of the return value depends on the type passed when calling the function. If there was an error it returns null.\n */\nasync function post<\n LoadType extends Record<string, unknown> = Record<string, unknown>,\n DataType = unknown,\n>(\n url:\n | string\n | TModify<\n IApiaApiRequestConfig<LoadType>,\n { postData?: DataType; postDataTreatement?: 'stringify' }\n >,\n config?: TModify<\n IApiaApiRequestConfig<LoadType>,\n {\n postData?: DataType;\n postDataTreatement?: 'stringify';\n }\n >,\n): TApiaApiResult<LoadType>;\nasync function post<\n LoadType extends Record<string, unknown> = Record<string, unknown>,\n DataType = unknown,\n>(\n config: TModify<\n IApiaApiRequestConfig<LoadType>,\n {\n postData?: DataType;\n postDataTreatement?: 'stringify';\n }\n >,\n): TApiaApiResult<LoadType>;\nasync function post<\n LoadType extends Record<string, unknown> = Record<string, unknown>,\n DataType = unknown,\n T = unknown,\n>(\n par1:\n | string\n | TModify<\n IApiaApiRequestConfig<LoadType>,\n { postData?: DataType; postDataTreatement?: 'stringify' }\n >,\n par2?: TModify<\n IApiaApiRequestConfig<LoadType>,\n { postData?: DataType; postDataTreatement?: 'stringify' }\n >,\n): TApiaApiResult<LoadType> {\n const actualUrl = typeof par1 !== 'string' ? makeApiaUrl() : par1;\n\n const configParameter = (\n typeof par1 === 'string' ? par2 ?? defaultConfig : par1\n ) as TModify<\n IApiaApiRequestConfig<LoadType>,\n { postData?: DataType; postDataTreatement?: 'stringify' }\n >;\n\n const behaveConfig = {\n ...getConfig(configParameter),\n postData:\n configParameter.postDataTreatement === 'stringify'\n ? QueryString.stringify(\n configParameter.postData,\n configParameter.stringifyOptions,\n )\n : configParameter.postData,\n };\n\n const parsedUrl = makeUrl(\n actualUrl,\n behaveConfig.queryData,\n behaveConfig.stringifyOptions,\n );\n\n if (behaveConfig.debug) {\n const queryString = actualUrl.split('&');\n const action = getURLActionName(actualUrl);\n\n console.log(\n `%cApiaApi.post ${action}`,\n `color: ${getColor('message', behaveConfig.colors)}`,\n {\n url: parsedUrl,\n queryDataInURL: [...queryString],\n queryData: behaveConfig.queryData,\n formData: behaveConfig.postData,\n stringifyOptiopns: behaveConfig.stringifyOptions,\n },\n );\n }\n\n const response = await axios\n .post<\n T,\n AxiosResponse<string>,\n DataType | string\n >(parsedUrl, behaveConfig.postData, behaveConfig.axiosConfig)\n .catch((e: unknown) => {\n handleWrongResponse(new Error(e as string));\n });\n\n if (response) {\n const result = handleResponse<LoadType>(response, actualUrl, behaveConfig);\n return result;\n }\n return null;\n}\n\n/**\n * IMPORTANTE!! El ApiaApi está programado bajo la consigna de que\n * **no debe tirar núnca una excepción**. **Los errores** provenientes\n * de la conectividad o de excepciones en el servidor **serán manejados\n * automáticamente** por el ApiaApi utilizando el sistema de notificaciones\n * de la aplicación. Es posible determinar en qué contexto deben\n * ser lanzadas esas excepciones (global, main, modal) utilizando las\n * propiedades de configuración alertsCategory **(ver errorsHandling.md)**.\n *\n * @param url String, el url al que se desea llamar\n * @param config interface IApiaApiRequestConfig<DataType>;\n *\n * @throws Nothing\n *\n * @example\n *\n * ApiaApi.get<TipoDeRespuesta>('url...', {\n axiosConfig?: AxiosRequestConfig;\n\n // Configuración de queryString\n queryData?: string | Record<string, unknown>;\n stringifyOptions?: QueryString.IStringifyOptions;\n\n // Validador de respuesta,\n // Si devuelve true, todo sigue correctamente\n // Si devuelve false, el ApiaApi tira un error estándar.\n // Si devuelve string, el ApiaApi tira el error devuelto en el string.\n validateResponse?: (\n response: AxiosResponse<DataType | null>,\n ) => boolean | string;\n\n // Configuración de alertas\n alertsImportance?: TAlertImportance;\n\n // Configuración de ApiaApiHandler, falta documentar\n handleLoad?: boolean;\n eventsHandler?: IEventsHandler;\n\n // Otra configuración\n colors?: TColors;\n debug?: boolean;\n }\n * @returns El tipo del valor devuelto depende del tipo pasado al llamar a la función. Si hubo un error devuelve null\n */\nasync function get<\n LoadType extends Record<string, unknown> = Record<string, unknown>,\n>(\n url: string | IApiaApiRequestConfig<LoadType>,\n config?: IApiaApiRequestConfig<LoadType>,\n): TApiaApiResult<LoadType>;\nasync function get<\n LoadType extends Record<string, unknown> = Record<string, unknown>,\n>(config: IApiaApiRequestConfig<LoadType>): TApiaApiResult<LoadType>;\nasync function get<\n LoadType extends Record<string, unknown> = Record<string, unknown>,\n T = unknown,\n D = unknown,\n>(\n par1: string | IApiaApiRequestConfig<LoadType>,\n par2?: IApiaApiRequestConfig<LoadType>,\n): TApiaApiResult<LoadType> {\n const actualUrl = typeof par1 !== 'string' ? makeApiaUrl() : par1;\n\n const behaveConfig = getConfig<LoadType>(\n typeof par1 === 'string' ? par2 ?? defaultConfig : par1,\n );\n\n const parsedUrl = makeUrl(\n actualUrl,\n behaveConfig.queryData,\n behaveConfig.stringifyOptions,\n );\n\n if (behaveConfig.debug)\n console.log(\n `%cApiaApi.get`,\n `color: ${getColor('message', behaveConfig.colors)}`,\n {\n url: parsedUrl,\n },\n );\n const response = await axios\n .get<T, AxiosResponse<string>, D>(parsedUrl, behaveConfig.axiosConfig)\n .catch((e: unknown) => {\n handleWrongResponse(new Error(e as string));\n });\n if (response) {\n const result = await handleResponse<LoadType>(\n response,\n actualUrl,\n behaveConfig,\n );\n return result;\n }\n return null;\n}\n\nconst ApiaApi = {\n get,\n getConfig,\n post,\n};\n/**\n * Creates an url based on the general requirements of Apia.\n * If the ajaxUrl property is not passed, it will use the\n * window.URL_REQUEST_AJAX. Its use is very simple, just pass the objects you\n * want to appear in the query string.\n *\n * @example makeApiaUrl({\n * ajaxUrl: 'the.endpoint.you.want',\n * queryString: 'an=existent&query=string',\n * action: 'theAction',\n * anotherProp: 15\n * })\n *\n * @returns the well formed url, in the example, the response url is:\n * /context/the.endpoint.you.want?an=existent&query=string&anotherProp=15&tabId=...&tokenId=...&action=theAction\n */\nexport function makeApiaUrl(props?: {\n action?: string;\n ajaxUrl?: string;\n queryString?: string;\n stringifyOptions?: QueryString.IStringifyOptions;\n tabId?: string | number;\n preventAsXmlParameter?: boolean;\n avoidTabId?: boolean;\n [key: string]: unknown;\n}) {\n let actualQueryData: Record<string, unknown> | unknown = {};\n\n if (props) {\n const {\n ajaxUrl,\n queryString,\n stringifyOptions,\n shouldAvoidTabId,\n preventAsXmlParameter,\n avoidTabId,\n tabId: outerTabId,\n ...rest\n } = props;\n actualQueryData = { ...rest };\n }\n\n const queryString = QueryString.stringify(\n actualQueryData,\n props?.stringifyOptions ?? {\n arrayFormat: 'repeat',\n encodeValuesOnly: false,\n },\n );\n\n let actualAjaxUrl = props?.ajaxUrl ?? window.URL_REQUEST_AJAX;\n if (actualAjaxUrl.indexOf('?') === actualAjaxUrl.length - 1) {\n actualAjaxUrl = actualAjaxUrl.slice(0, actualAjaxUrl.length - 1);\n }\n if (!actualAjaxUrl.startsWith('/')) {\n actualAjaxUrl = `/${actualAjaxUrl}`;\n }\n\n const match = window.TAB_ID_REQUEST.match(/tokenId=(\\w+)/);\n const currentTokenId = (match ?? [])[1];\n\n let tabId = (\n props?.tabId\n ? `&tabId=${props.tabId}&tokenId=${currentTokenId}`\n : window.TAB_ID_REQUEST\n ).slice(1);\n if (props?.avoidTabId) {\n tabId = '';\n }\n\n let { CONTEXT } = window;\n if (CONTEXT?.endsWith('/')) {\n CONTEXT += CONTEXT.slice(0, CONTEXT.length - 1);\n }\n\n let timestamp = `timestamp=${Date.now()}&`;\n if (\n (props?.queryString && props.queryString.includes('timestamp=')) ||\n queryString?.includes('timestamp=')\n ) {\n timestamp = '';\n }\n\n const contextWord = CONTEXT.replaceAll('/', '');\n actualAjaxUrl = actualAjaxUrl.match(\n new RegExp(`^(?:(?:/?${contextWord})?/)?(.+)$`),\n )?.[1] as string;\n\n return `${\n contextWord ? '/' : ''\n }${contextWord}/${actualAjaxUrl}?${timestamp}${\n !props?.preventAsXmlParameter ? 'asXml=true&' : ''\n }${props?.queryString ? `${props.queryString}&` : ''}${\n queryString ? `${queryString}&` : ''\n }${tabId}`;\n}\n\ndeclare global {\n interface Window {\n TAB_ID_REQUEST: string;\n CONTEXT: string;\n URL_REQUEST_AJAX: string;\n }\n}\n\nexport default ApiaApi;\n"],"names":["queryString"],"mappings":";;;;;;;;AA4BA,eAAgB,CAAA,EAAA;AAAA,EACd,UAAA;AAAA,EACA,OAAO,CAAC,IAAI,CAAM,KAAA;AAChB,IAAM,MAAA,MAAA,GAAS,MAAM,aAAA,CAAuB,IAAc,CAAA,CAAA;AAC1D,IAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AAAA,GACrB;AAAA,EACA,qHAAA;AACF,CAAA,CAAA;AAEA,MAAM,aAAgD,GAAA;AAAA,EACpD,KAAO,EAAA,KAAA;AAAA,EACP,MAAQ,EAAA;AAAA,IACN,SAAW,EAAA,KAAA;AAAA,IACX,KAAO,EAAA,QAAA;AAAA,IACP,OAAS,EAAA,YAAA;AAAA,GACX;AAAA,EACA,UAAY,EAAA,KAAA;AACd,CAAA,CAAA;AAEA,MAAM,aAAgB,GAAA,eAAA,CAAA;AAEtB,IAAI,eAAwD,EAAC,CAAA;AAC7D,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AAA,CAAA,UAAA,EAAa,IAAK,CAAA,GAAA,EAAK,CAAA,CAAA,CAAA,CAAA;AACvC,EACG,IAAA,KAAA,EAAO,WAAe,IAAA,KAAA,CAAM,WAAY,CAAA,QAAA,CAAS,YAAY,CAC9D,IAAA,WAAA,EAAa,QAAS,CAAA,YAAY,CAClC,EAAA;AACA,IAAY,SAAA,GAAA,EAAA,CAAA;AAAA,GACd;AAEA,EAAA,MAAM,WAAc,GAAA,OAAA,CAAQ,UAAW,CAAA,GAAA,EAAK,EAAE,CAAA,CAAA;AAC9C,EAAA,aAAA,GAAgB,aAAc,CAAA,KAAA;AAAA,IAC5B,IAAI,MAAA,CAAO,CAAY,SAAA,EAAA,WAAW,CAAY,UAAA,CAAA,CAAA;AAAA,MAC5C,CAAC,CAAA,CAAA;AAEL,EAAA,OAAO,CACL,EAAA,WAAA,GAAc,GAAM,GAAA,EACtB,CAAG,EAAA,WAAW,CAAI,CAAA,EAAA,aAAa,CAAI,CAAA,EAAA,SAAS,CAC1C,EAAA,CAAC,OAAO,qBAAwB,GAAA,aAAA,GAAgB,EAClD,CAAA,EAAG,KAAO,EAAA,WAAA,GAAc,CAAG,EAAA,KAAA,CAAM,WAAW,CAAM,CAAA,CAAA,GAAA,EAAE,CAClD,EAAA,WAAA,GAAc,CAAG,EAAA,WAAW,CAAM,CAAA,CAAA,GAAA,EACpC,GAAG,KAAK,CAAA,CAAA,CAAA;AACV,CAAA;AAUA,gBAAe,OAAA;;;;"}
@@ -1,129 +0,0 @@
1
- import { jsx } from '@apia/theme/jsx-runtime';
2
- import { arrayOrArray } from '@apia/util';
3
- import uniqueId from 'lodash-es/uniqueId';
4
- import QueryString from 'qs';
5
- import React__default from 'react';
6
- import { Box } from '@apia/theme';
7
- import { useFormContext, validationsStore, hasSucceedFormValidation } from '@apia/validations';
8
- import { SimpleButton } from '@apia/components';
9
- import { getFunction } from '../ApiaApiHandler.js';
10
- import ApiaApi from '../apiaApi.js';
11
-
12
- const parseButtons = (buttons) => {
13
- return buttons.map((currentButton) => ({
14
- ...currentButton,
15
- buttonKey: uniqueId(),
16
- type: ["submitAjax", "submit"].includes(currentButton.type) ? "submit" : "button"
17
- }));
18
- };
19
- const NonMemoizedApiaApiButtonsContainer = (props) => {
20
- const buttonElements = React__default.useMemo(
21
- () => arrayOrArray(props.definition?.form.buttons?.button ?? []),
22
- [props.definition?.form.buttons?.button]
23
- );
24
- const buttons = React__default.useMemo(
25
- () => parseButtons(buttonElements),
26
- [buttonElements]
27
- );
28
- const modalConfiguration = React__default.useMemo(
29
- () => props.configuration?.modalConfiguration,
30
- [props.configuration?.modalConfiguration]
31
- );
32
- const methodsPath = React__default.useMemo(
33
- () => props.configuration?.methodsPath,
34
- [props.configuration?.methodsPath]
35
- );
36
- const { name: apiaApiForm } = useFormContext();
37
- const renderButton = React__default.useCallback(
38
- (currentButton) => {
39
- const key = currentButton.buttonKey;
40
- const className = `handler__${currentButton.type ?? ""}`;
41
- const onClick = () => {
42
- void async function submitForm() {
43
- const validationResult = await validationsStore.validateForm(apiaApiForm);
44
- if (!hasSucceedFormValidation(validationResult)) {
45
- return;
46
- }
47
- const { submitValues } = validationResult;
48
- function runButtonMethod() {
49
- void (async () => {
50
- if (currentButton.onclick) {
51
- const actions = currentButton.onclick.split(";");
52
- for await (const action of actions) {
53
- const method = await getFunction(action, {
54
- ...props
55
- });
56
- if (method) {
57
- method({
58
- currentUrl: props.definition?.form.action ?? "noUrl"
59
- });
60
- } else {
61
- throw new Error(
62
- `The requested action is not defined: "${props.definition?.form.action ?? ""}"`
63
- );
64
- }
65
- }
66
- }
67
- })();
68
- }
69
- if (props?.definition && currentButton.type === "submit") {
70
- const formData = new FormData();
71
- Object.entries(submitValues).forEach(([name, value]) => {
72
- formData.append(name, value ?? "");
73
- });
74
- const hasContext = props?.definition.form.action.match(
75
- new RegExp(`^${window.CONTEXT}/`)
76
- );
77
- const url = `${hasContext ? "" : window.CONTEXT}${!props?.definition.form.action.startsWith("/") ? "/" : ""}${props?.definition.form.action}`;
78
- props.setState((current) => ({
79
- ...current,
80
- isLoading: true
81
- }));
82
- void ApiaApi.post(url, {
83
- postData: props.state.isMultipart ? formData : QueryString.stringify(
84
- [...formData.entries(), ["isAjax", true]].reduce((accumulated, [name, value]) => {
85
- const retValue = { ...accumulated };
86
- retValue[name.toString()] = value.toString();
87
- return retValue;
88
- }, {})
89
- ),
90
- handleLoad: true,
91
- notificationsCategory: "apiaApiHandler",
92
- modalConfiguration,
93
- methodsPath
94
- }).finally(() => {
95
- runButtonMethod();
96
- if (props?.definition?.form.closeOnSubmit) {
97
- props.close();
98
- }
99
- });
100
- } else {
101
- runButtonMethod();
102
- }
103
- }();
104
- };
105
- return /* @__PURE__ */ jsx(
106
- SimpleButton,
107
- {
108
- className,
109
- disabled: props.state.disabled,
110
- id: currentButton.id || currentButton.text,
111
- isLoading: props.state.isLoading,
112
- title: currentButton.text,
113
- type: currentButton.type,
114
- onClick,
115
- children: currentButton.text
116
- },
117
- key
118
- );
119
- },
120
- [apiaApiForm, methodsPath, modalConfiguration, props]
121
- );
122
- return /* @__PURE__ */ jsx(Box, { className: "handler__form__buttons", children: buttons.map((currentButton) => renderButton(currentButton)) });
123
- };
124
- const ApiaApiButtonsContainer = React__default.memo(
125
- NonMemoizedApiaApiButtonsContainer
126
- );
127
-
128
- export { ApiaApiButtonsContainer };
129
- //# sourceMappingURL=ApiaApiButtonsContainer.js.map