@apia/api 2.0.7 → 2.0.9
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/index.d.ts +297 -4
- package/dist/index.js +3212 -3
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/ApiaApiContext.js +0 -15
- package/dist/ApiaApiContext.js.map +0 -1
- package/dist/ApiaApiHandler.d.ts +0 -62
- package/dist/ApiaApiHandler.d.ts.map +0 -1
- package/dist/ApiaApiHandler.js +0 -374
- package/dist/ApiaApiHandler.js.map +0 -1
- package/dist/apiaApi.d.ts +0 -156
- package/dist/apiaApi.d.ts.map +0 -1
- package/dist/apiaApi.js +0 -458
- package/dist/apiaApi.js.map +0 -1
- package/dist/buttons/ApiaApiButtonsContainer.js +0 -129
- package/dist/buttons/ApiaApiButtonsContainer.js.map +0 -1
- package/dist/fields/ApiaApiCheckbox.js +0 -39
- package/dist/fields/ApiaApiCheckbox.js.map +0 -1
- package/dist/fields/ApiaApiFieldsContainer.js +0 -213
- package/dist/fields/ApiaApiFieldsContainer.js.map +0 -1
- package/dist/fields/ApiaApiFileInput.js +0 -34
- package/dist/fields/ApiaApiFileInput.js.map +0 -1
- package/dist/fields/ApiaApiInput.d.ts +0 -20
- package/dist/fields/ApiaApiInput.d.ts.map +0 -1
- package/dist/fields/ApiaApiInput.js +0 -110
- package/dist/fields/ApiaApiInput.js.map +0 -1
- package/dist/fields/ApiaApiRadio.js +0 -43
- package/dist/fields/ApiaApiRadio.js.map +0 -1
- package/dist/fields/ApiaApiSelect.js +0 -64
- package/dist/fields/ApiaApiSelect.js.map +0 -1
- package/dist/fields/ApiaApiTextArea.js +0 -50
- package/dist/fields/ApiaApiTextArea.js.map +0 -1
- package/dist/types.d.ts +0 -39
- package/dist/types.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,298 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
4
|
+
import { TApiaFilter, TModify, TApiaLoad, TApiaFormElement } from '@apia/util';
|
|
5
|
+
import { TNotificationMessage, notify } from '@apia/notifications';
|
|
6
|
+
import { TModal } from '@apia/components';
|
|
7
|
+
import QueryString from 'qs';
|
|
8
|
+
import { TResponsiveTableColumn } from '@apia/table';
|
|
9
|
+
|
|
10
|
+
declare function getConfig<LoadType>(outerBehaveConfig?: IApiaApiRequestConfig<LoadType>): IApiaApiRequestConfig<unknown> & IApiaApiRequestConfig<LoadType> & Partial<IApiaApiRequestConfig<unknown>>;
|
|
11
|
+
type TApiaApiAxiosResponse<LoadType> = AxiosResponse<LoadType | null> & {
|
|
12
|
+
hasError: boolean;
|
|
13
|
+
hasMessages: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* IMPORTANT!! The ApiaApi is programmed under the slogan that
|
|
17
|
+
* **should never throw an exception**. **Errors** coming from
|
|
18
|
+
* connectivity or exceptions on the server **will be handled
|
|
19
|
+
* automatically** by ApiaApi, using the notification system
|
|
20
|
+
* of the application. It is possible to determine in what context they should
|
|
21
|
+
* be thrown those exceptions (global, main, modal) using the
|
|
22
|
+
* alertsCategory configuration properties **(see errorsHandling.md)**.
|
|
23
|
+
*
|
|
24
|
+
* @param url String, the url you want to call
|
|
25
|
+
* @param config interface IApiaApiRequestConfig<DataType>;
|
|
26
|
+
*
|
|
27
|
+
* @throws Nothing
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* ApiaApi.post<ResponseType>('url...', {
|
|
32
|
+
axiosConfig?: AxiosRequestConfig;
|
|
33
|
+
|
|
34
|
+
// Configuración de postData
|
|
35
|
+
postData? unknown;
|
|
36
|
+
postDataTreatement?: 'stringify' | undefined;
|
|
37
|
+
|
|
38
|
+
// Configuración de queryString
|
|
39
|
+
queryData?: string | Record<string, unknown>;
|
|
40
|
+
stringifyOptions?: QueryString.IStringifyOptions;
|
|
41
|
+
|
|
42
|
+
// Response validator,
|
|
43
|
+
// If it returns true, everything continues correctly
|
|
44
|
+
// If it returns false, the ApiaApi throws a standard error.
|
|
45
|
+
// If it returns string, ApiaApi throws the error returned in the string.
|
|
46
|
+
validateResponse?: (
|
|
47
|
+
response: AxiosResponse<DataType | null>,
|
|
48
|
+
) => boolean | string;
|
|
49
|
+
|
|
50
|
+
// Configuración de alertas
|
|
51
|
+
alertsImportance?: TAlertImportance;
|
|
52
|
+
|
|
53
|
+
// Configuración de ApiaApiHandler, falta documentar
|
|
54
|
+
handleLoad?: boolean;
|
|
55
|
+
eventsHandler?: IEventsHandler;
|
|
56
|
+
|
|
57
|
+
// other configuration
|
|
58
|
+
colors?: TColors;
|
|
59
|
+
debug?: boolean;
|
|
60
|
+
}
|
|
61
|
+
* @returns The type of the return value depends on the type passed when calling the function. If there was an error it returns null.
|
|
62
|
+
*/
|
|
63
|
+
declare function post<LoadType extends Record<string, unknown> = Record<string, unknown>, DataType = unknown>(url: string | TModify<IApiaApiRequestConfig<LoadType>, {
|
|
64
|
+
postData?: DataType;
|
|
65
|
+
postDataTreatement?: 'stringify';
|
|
66
|
+
}>, config?: TModify<IApiaApiRequestConfig<LoadType>, {
|
|
67
|
+
postData?: DataType;
|
|
68
|
+
postDataTreatement?: 'stringify';
|
|
69
|
+
}>): TApiaApiResult<LoadType>;
|
|
70
|
+
declare function post<LoadType extends Record<string, unknown> = Record<string, unknown>, DataType = unknown>(config: TModify<IApiaApiRequestConfig<LoadType>, {
|
|
71
|
+
postData?: DataType;
|
|
72
|
+
postDataTreatement?: 'stringify';
|
|
73
|
+
}>): TApiaApiResult<LoadType>;
|
|
74
|
+
/**
|
|
75
|
+
* IMPORTANTE!! El ApiaApi está programado bajo la consigna de que
|
|
76
|
+
* **no debe tirar núnca una excepción**. **Los errores** provenientes
|
|
77
|
+
* de la conectividad o de excepciones en el servidor **serán manejados
|
|
78
|
+
* automáticamente** por el ApiaApi utilizando el sistema de notificaciones
|
|
79
|
+
* de la aplicación. Es posible determinar en qué contexto deben
|
|
80
|
+
* ser lanzadas esas excepciones (global, main, modal) utilizando las
|
|
81
|
+
* propiedades de configuración alertsCategory **(ver errorsHandling.md)**.
|
|
82
|
+
*
|
|
83
|
+
* @param url String, el url al que se desea llamar
|
|
84
|
+
* @param config interface IApiaApiRequestConfig<DataType>;
|
|
85
|
+
*
|
|
86
|
+
* @throws Nothing
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* ApiaApi.get<TipoDeRespuesta>('url...', {
|
|
91
|
+
axiosConfig?: AxiosRequestConfig;
|
|
92
|
+
|
|
93
|
+
// Configuración de queryString
|
|
94
|
+
queryData?: string | Record<string, unknown>;
|
|
95
|
+
stringifyOptions?: QueryString.IStringifyOptions;
|
|
96
|
+
|
|
97
|
+
// Validador de respuesta,
|
|
98
|
+
// Si devuelve true, todo sigue correctamente
|
|
99
|
+
// Si devuelve false, el ApiaApi tira un error estándar.
|
|
100
|
+
// Si devuelve string, el ApiaApi tira el error devuelto en el string.
|
|
101
|
+
validateResponse?: (
|
|
102
|
+
response: AxiosResponse<DataType | null>,
|
|
103
|
+
) => boolean | string;
|
|
104
|
+
|
|
105
|
+
// Configuración de alertas
|
|
106
|
+
alertsImportance?: TAlertImportance;
|
|
107
|
+
|
|
108
|
+
// Configuración de ApiaApiHandler, falta documentar
|
|
109
|
+
handleLoad?: boolean;
|
|
110
|
+
eventsHandler?: IEventsHandler;
|
|
111
|
+
|
|
112
|
+
// Otra configuración
|
|
113
|
+
colors?: TColors;
|
|
114
|
+
debug?: boolean;
|
|
115
|
+
}
|
|
116
|
+
* @returns El tipo del valor devuelto depende del tipo pasado al llamar a la función. Si hubo un error devuelve null
|
|
117
|
+
*/
|
|
118
|
+
declare function get<LoadType extends Record<string, unknown> = Record<string, unknown>>(url: string | IApiaApiRequestConfig<LoadType>, config?: IApiaApiRequestConfig<LoadType>): TApiaApiResult<LoadType>;
|
|
119
|
+
declare function get<LoadType extends Record<string, unknown> = Record<string, unknown>>(config: IApiaApiRequestConfig<LoadType>): TApiaApiResult<LoadType>;
|
|
120
|
+
declare const ApiaApi: {
|
|
121
|
+
get: typeof get;
|
|
122
|
+
getConfig: typeof getConfig;
|
|
123
|
+
post: typeof post;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Creates an url based on the general requirements of Apia.
|
|
127
|
+
* If the ajaxUrl property is not passed, it will use the
|
|
128
|
+
* window.URL_REQUEST_AJAX. Its use is very simple, just pass the objects you
|
|
129
|
+
* want to appear in the query string.
|
|
130
|
+
*
|
|
131
|
+
* @example makeApiaUrl({
|
|
132
|
+
* ajaxUrl: 'the.endpoint.you.want',
|
|
133
|
+
* queryString: 'an=existent&query=string',
|
|
134
|
+
* action: 'theAction',
|
|
135
|
+
* anotherProp: 15
|
|
136
|
+
* })
|
|
137
|
+
*
|
|
138
|
+
* @returns the well formed url, in the example, the response url is:
|
|
139
|
+
* /context/the.endpoint.you.want?an=existent&query=string&anotherProp=15&tabId=...&tokenId=...&action=theAction
|
|
140
|
+
*/
|
|
141
|
+
declare function makeApiaUrl(props?: {
|
|
142
|
+
action?: string;
|
|
143
|
+
ajaxUrl?: string;
|
|
144
|
+
queryString?: string;
|
|
145
|
+
stringifyOptions?: QueryString.IStringifyOptions;
|
|
146
|
+
tabId?: string | number;
|
|
147
|
+
preventAsXmlParameter?: boolean;
|
|
148
|
+
avoidTabId?: boolean;
|
|
149
|
+
[key: string]: unknown;
|
|
150
|
+
}): string;
|
|
151
|
+
declare global {
|
|
152
|
+
interface Window {
|
|
153
|
+
TAB_ID_REQUEST: string;
|
|
154
|
+
CONTEXT: string;
|
|
155
|
+
URL_REQUEST_AJAX: string;
|
|
156
|
+
FILTERS_LABEL: string;
|
|
157
|
+
BTN_DELETE_FILTERS: string;
|
|
158
|
+
FINDER_ORDER_BY: string;
|
|
159
|
+
FINDER_FILTERS: string;
|
|
160
|
+
ADDITIONAL_FILTERS_LABEL: string;
|
|
161
|
+
}
|
|
162
|
+
const usersModal: {
|
|
163
|
+
columns: TResponsiveTableColumn[];
|
|
164
|
+
filters: TApiaFilter[];
|
|
165
|
+
label: string;
|
|
166
|
+
path: string;
|
|
167
|
+
};
|
|
168
|
+
const poolsModal: {
|
|
169
|
+
columns: TResponsiveTableColumn[];
|
|
170
|
+
filters: TApiaFilter[];
|
|
171
|
+
label: string;
|
|
172
|
+
path: string;
|
|
173
|
+
};
|
|
174
|
+
const environmentsModal: {
|
|
175
|
+
columns: TResponsiveTableColumn[];
|
|
176
|
+
filters: TApiaFilter[];
|
|
177
|
+
label: string;
|
|
178
|
+
path: string;
|
|
179
|
+
};
|
|
180
|
+
const orgRolesModal: {
|
|
181
|
+
columns: TResponsiveTableColumn[];
|
|
182
|
+
filters: TApiaFilter[];
|
|
183
|
+
label: string;
|
|
184
|
+
path: string;
|
|
185
|
+
};
|
|
186
|
+
const tasksModal: {
|
|
187
|
+
columns: TResponsiveTableColumn[];
|
|
188
|
+
filters: TApiaFilter[];
|
|
189
|
+
label: string;
|
|
190
|
+
path: string;
|
|
191
|
+
};
|
|
192
|
+
const processesModal: {
|
|
193
|
+
columns: TResponsiveTableColumn[];
|
|
194
|
+
filters: TApiaFilter[];
|
|
195
|
+
label: string;
|
|
196
|
+
path: string;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface TColors {
|
|
201
|
+
exception?: string;
|
|
202
|
+
alert?: string;
|
|
203
|
+
message?: string;
|
|
204
|
+
}
|
|
205
|
+
type TApiaApiResult<LoadType> = Promise<TApiaApiAxiosResponse<(LoadType & TNotificationMessage) | null> | null>;
|
|
206
|
+
interface IApiaApiConsoleConfig {
|
|
207
|
+
colors?: TColors;
|
|
208
|
+
debug?: boolean;
|
|
209
|
+
}
|
|
210
|
+
type TSetModalProps = (configuration: THandleConfiguration, formDefinition?: TApiaLoad) => TModal | null;
|
|
211
|
+
interface IApiaApiRequestConfig<DataType> extends IApiaApiConsoleConfig {
|
|
212
|
+
axiosConfig?: AxiosRequestConfig;
|
|
213
|
+
modalConfiguration?: IModalConfig;
|
|
214
|
+
handleLoad?: boolean;
|
|
215
|
+
setModalProps?: TSetModalProps;
|
|
216
|
+
/**
|
|
217
|
+
* Algunas veces las funciones llamadas por una acción en el servidor
|
|
218
|
+
* tienen el mismo nombre siendo en realidad funciones distintas. Para
|
|
219
|
+
* corregir este problema es posible pasar un path relativo al directorio
|
|
220
|
+
* apiaApi/methods
|
|
221
|
+
*/
|
|
222
|
+
methodsPath?: string;
|
|
223
|
+
notificationsCategory?: string;
|
|
224
|
+
queryData?: string | Record<string, unknown>;
|
|
225
|
+
stringifyOptions?: QueryString.IStringifyOptions;
|
|
226
|
+
validateResponse?: (response: AxiosResponse<DataType | null>) => Promise<boolean | string> | boolean | string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
type TMethod = {
|
|
230
|
+
name: string;
|
|
231
|
+
props: {
|
|
232
|
+
attributes?: Record<string, unknown>;
|
|
233
|
+
currentUrl?: string;
|
|
234
|
+
funCall?: string;
|
|
235
|
+
inlineArguments?: string[];
|
|
236
|
+
messages?: unknown;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
type TApiaApiMethodHandler = {
|
|
240
|
+
alert: typeof notify;
|
|
241
|
+
close: () => void;
|
|
242
|
+
configuration?: THandleConfiguration;
|
|
243
|
+
formDefinition: TApiaLoad;
|
|
244
|
+
setModalProps?: (configuration: THandleConfiguration, formDefinition?: TApiaLoad) => TModal | null;
|
|
245
|
+
reset: () => void;
|
|
246
|
+
setError: typeof notify;
|
|
247
|
+
setMessage: (message: Record<string, unknown>) => unknown;
|
|
248
|
+
setState: React.Dispatch<React.SetStateAction<IApiaApiHandlerState>>;
|
|
249
|
+
state: IApiaApiHandlerState;
|
|
250
|
+
setValue: (name: string, value: string) => void;
|
|
251
|
+
};
|
|
252
|
+
type TApiaApiMethod = (handler: TApiaApiMethodHandler, props: TMethod['props']) => Promise<void> | void;
|
|
253
|
+
type TApiaApiField = TApiaApiMethodHandler & {
|
|
254
|
+
element: TModify<TApiaFormElement, {
|
|
255
|
+
onChange: React.ChangeEventHandler;
|
|
256
|
+
}>;
|
|
257
|
+
};
|
|
258
|
+
type TStoredApiaApiMethod = (props?: TMethod['props']) => unknown;
|
|
259
|
+
/**
|
|
260
|
+
* Este método permite cargar en forma asíncrona un método que se encuentre
|
|
261
|
+
* dentro del directorio /api/methods
|
|
262
|
+
*/
|
|
263
|
+
declare function getFunction(name: string, handler: TApiaApiMethodHandler): Promise<TStoredApiaApiMethod | undefined>;
|
|
264
|
+
interface IModalConfig {
|
|
265
|
+
modalTitle?: string;
|
|
266
|
+
onClose?: () => void;
|
|
267
|
+
onMessage?: (message: Record<string, unknown>) => unknown;
|
|
268
|
+
onMessageClose?: () => unknown;
|
|
269
|
+
onSubmitted?: (handler: TApiaApiMethodHandler, response: AxiosResponse<Record<string, unknown> | null> | null) => unknown;
|
|
270
|
+
}
|
|
271
|
+
type THandleConfiguration = Partial<Pick<IApiaApiRequestConfig<unknown>, 'modalConfiguration' | 'methodsPath' | 'setModalProps'>>;
|
|
272
|
+
interface IApiaApiHandlerState {
|
|
273
|
+
disabled: boolean;
|
|
274
|
+
isLoading: boolean;
|
|
275
|
+
isMultipart: boolean;
|
|
276
|
+
progress: number;
|
|
277
|
+
errors: Record<string, string>;
|
|
278
|
+
windowIndex: number;
|
|
279
|
+
}
|
|
280
|
+
declare const ApiaApiHandler: React.MemoExoticComponent<() => React.JSX.Element>;
|
|
281
|
+
|
|
282
|
+
declare global {
|
|
283
|
+
interface Window {
|
|
284
|
+
SALT: string;
|
|
285
|
+
IV: string;
|
|
286
|
+
PASSPHRASE: string;
|
|
287
|
+
KEY_SIZE: number;
|
|
288
|
+
ITERATION_COUNT: string;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Permite cargar en forma asíncrona un modal que se encuentre dentro del
|
|
293
|
+
* directorio /api/modals
|
|
294
|
+
* */
|
|
295
|
+
declare const getModal: (path: string) => React__default.LazyExoticComponent<React__default.ComponentType<TApiaApiField>>;
|
|
296
|
+
|
|
297
|
+
export { ApiaApi, ApiaApiHandler, type IApiaApiRequestConfig, type TApiaApiAxiosResponse, type TApiaApiMethod, type TApiaApiResult, getFunction, getModal, makeApiaUrl };
|
|
5
298
|
//# sourceMappingURL=index.d.ts.map
|