@apia/api 0.0.7 → 0.1.0
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/README.md +1 -1
- package/cleanDist.json +3 -0
- package/dist/index.d.ts +84 -68
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1557 -4
- package/dist/index.js.map +1 -1
- package/package.json +25 -16
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Los archivos **tsconfig.json** y **tsup.config.ts** no son archivos únicos sino
|
|
|
19
19
|
|
|
20
20
|
Luego de ejecutar estos pasos, el package estaría listo para comenzar a usarse.
|
|
21
21
|
|
|
22
|
-
Este package trae como dependencias por defecto theme-ui y react. Si se desea agregar más dependencias se debe ejecutar el comando ```lerna add --scope="@apia/packageName" dependencyName```. Ejemplo, si creamos un paquete con el nombre @apia/myPackage y queremos agregar lodash
|
|
22
|
+
Este package trae como dependencias por defecto theme-ui y react. Si se desea agregar más dependencias se debe ejecutar el comando ```lerna add --scope="@apia/packageName" dependencyName```. Ejemplo, si creamos un paquete con el nombre @apia/myPackage y queremos agregar lodash como dependencia, ejecutamos el comando ```lerna add --scope="@apia/myPackage" lodash```.
|
|
23
23
|
|
|
24
24
|
**Importante 1**: Dado que estamos desarrollando packages, es importante determinar si las dependencias que vamos a agregar son de tipo dependency o de tipo peerDependency.
|
|
25
25
|
|
package/cleanDist.json
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,68 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as theme_ui_jsx_runtime from 'theme-ui/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
4
|
+
import { TModify, TApiaLoad } from '@apia/util';
|
|
5
|
+
import { TNotificationMessage, notify } from '@apia/notifications';
|
|
3
6
|
import QueryString from 'qs';
|
|
4
|
-
import { notify, TNotificationMessage } from '@apia/notifications';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
|
|
7
|
-
type TApiaApiMethodHandler = {
|
|
8
|
-
alert: typeof notify;
|
|
9
|
-
close: () => void;
|
|
10
|
-
configuration?: THandleConfiguration;
|
|
11
|
-
formDefinition: TApiaLoad;
|
|
12
|
-
reset: () => void;
|
|
13
|
-
setError: typeof notify;
|
|
14
|
-
setMessage: (message: Record<string, unknown>) => unknown;
|
|
15
|
-
setState: React.Dispatch<React.SetStateAction<IApiaApiHandlerState>>;
|
|
16
|
-
state: IApiaApiHandlerState;
|
|
17
|
-
setValue: (name: string, value: string) => void;
|
|
18
|
-
};
|
|
19
|
-
interface IModalConfig {
|
|
20
|
-
modalTitle?: string;
|
|
21
|
-
onClose?: () => void;
|
|
22
|
-
onMessage?: (message: Record<string, unknown>) => unknown;
|
|
23
|
-
onMessageClose?: () => unknown;
|
|
24
|
-
onSubmitted?: (handler: TApiaApiMethodHandler, response: AxiosResponse<Record<string, unknown> | null> | null) => unknown;
|
|
25
|
-
}
|
|
26
|
-
type THandleConfiguration = Partial<Pick<IApiaApiRequestConfig<unknown>, 'modalConfiguration' | 'methodsPath'>>;
|
|
27
|
-
interface IApiaApiHandlerState {
|
|
28
|
-
disabled: boolean;
|
|
29
|
-
isLoading: boolean;
|
|
30
|
-
isMultipart: boolean;
|
|
31
|
-
progress: number;
|
|
32
|
-
errors: Record<string, string>;
|
|
33
|
-
windowIndex: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface TColors {
|
|
37
|
-
exception?: string;
|
|
38
|
-
alert?: string;
|
|
39
|
-
message?: string;
|
|
40
|
-
}
|
|
41
|
-
interface IApiaApiConsoleConfig {
|
|
42
|
-
colors?: TColors;
|
|
43
|
-
debug?: boolean;
|
|
44
|
-
}
|
|
45
|
-
interface IApiaApiRequestConfig<DataType> extends IApiaApiConsoleConfig {
|
|
46
|
-
axiosConfig?: AxiosRequestConfig;
|
|
47
|
-
modalConfiguration?: IModalConfig;
|
|
48
|
-
handleLoad?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Algunas veces las funciones llamadas por una acción en el servidor
|
|
51
|
-
* tienen el mismo nombre siendo en realidad funciones distintas. Para
|
|
52
|
-
* corregir este problema es posible pasar un path relativo al directorio
|
|
53
|
-
* apiaApi/methods
|
|
54
|
-
*/
|
|
55
|
-
methodsPath?: string;
|
|
56
|
-
notificationsCategory?: string;
|
|
57
|
-
queryData?: string | Record<string, unknown>;
|
|
58
|
-
stringifyOptions?: QueryString.IStringifyOptions;
|
|
59
|
-
validateResponse?: (response: AxiosResponse<DataType | null>) => Promise<boolean | string> | boolean | string;
|
|
60
|
-
}
|
|
61
|
-
declare global {
|
|
62
|
-
interface Window {
|
|
63
|
-
[key: string]: string;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
7
|
|
|
67
8
|
declare function getConfig<LoadType>(outerBehaveConfig?: IApiaApiRequestConfig<LoadType>): IApiaApiRequestConfig<unknown> & IApiaApiRequestConfig<LoadType> & Partial<IApiaApiRequestConfig<unknown>>;
|
|
68
9
|
type TApiaApiAxiosResponse<LoadType> = AxiosResponse<LoadType | null> & {
|
|
@@ -123,11 +64,11 @@ declare function post<LoadType extends Record<string, unknown> = Record<string,
|
|
|
123
64
|
}>, config?: TModify<IApiaApiRequestConfig<LoadType>, {
|
|
124
65
|
postData?: DataType;
|
|
125
66
|
postDataTreatement?: 'stringify';
|
|
126
|
-
}>):
|
|
67
|
+
}>): TApiaApiResult<LoadType>;
|
|
127
68
|
declare function post<LoadType extends Record<string, unknown> = Record<string, unknown>, DataType = unknown>(config: TModify<IApiaApiRequestConfig<LoadType>, {
|
|
128
69
|
postData?: DataType;
|
|
129
70
|
postDataTreatement?: 'stringify';
|
|
130
|
-
}>):
|
|
71
|
+
}>): TApiaApiResult<LoadType>;
|
|
131
72
|
/**
|
|
132
73
|
* IMPORTANTE!! El ApiaApi está programado bajo la consigna de que
|
|
133
74
|
* **no debe tirar núnca una excepción**. **Los errores** provenientes
|
|
@@ -172,8 +113,8 @@ declare function post<LoadType extends Record<string, unknown> = Record<string,
|
|
|
172
113
|
}
|
|
173
114
|
* @returns El tipo del valor devuelto depende del tipo pasado al llamar a la función. Si hubo un error devuelve null
|
|
174
115
|
*/
|
|
175
|
-
declare function get<LoadType extends Record<string, unknown> = Record<string, unknown>>(url: string | IApiaApiRequestConfig<LoadType>, config?: IApiaApiRequestConfig<LoadType>):
|
|
176
|
-
declare function get<LoadType extends Record<string, unknown> = Record<string, unknown>>(config: IApiaApiRequestConfig<LoadType>):
|
|
116
|
+
declare function get<LoadType extends Record<string, unknown> = Record<string, unknown>>(url: string | IApiaApiRequestConfig<LoadType>, config?: IApiaApiRequestConfig<LoadType>): TApiaApiResult<LoadType>;
|
|
117
|
+
declare function get<LoadType extends Record<string, unknown> = Record<string, unknown>>(config: IApiaApiRequestConfig<LoadType>): TApiaApiResult<LoadType>;
|
|
177
118
|
declare const ApiaApi: {
|
|
178
119
|
get: typeof get;
|
|
179
120
|
getConfig: typeof getConfig;
|
|
@@ -206,4 +147,79 @@ declare function makeApiaUrl(props?: {
|
|
|
206
147
|
[key: string]: unknown;
|
|
207
148
|
}): string;
|
|
208
149
|
|
|
209
|
-
|
|
150
|
+
interface TColors {
|
|
151
|
+
exception?: string;
|
|
152
|
+
alert?: string;
|
|
153
|
+
message?: string;
|
|
154
|
+
}
|
|
155
|
+
type TApiaApiResult<LoadType> = Promise<TApiaApiAxiosResponse<(LoadType & TNotificationMessage) | null> | null>;
|
|
156
|
+
interface IApiaApiConsoleConfig {
|
|
157
|
+
colors?: TColors;
|
|
158
|
+
debug?: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface IApiaApiRequestConfig<DataType> extends IApiaApiConsoleConfig {
|
|
161
|
+
axiosConfig?: AxiosRequestConfig;
|
|
162
|
+
modalConfiguration?: IModalConfig;
|
|
163
|
+
handleLoad?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Algunas veces las funciones llamadas por una acción en el servidor
|
|
166
|
+
* tienen el mismo nombre siendo en realidad funciones distintas. Para
|
|
167
|
+
* corregir este problema es posible pasar un path relativo al directorio
|
|
168
|
+
* apiaApi/methods
|
|
169
|
+
*/
|
|
170
|
+
methodsPath?: string;
|
|
171
|
+
notificationsCategory?: string;
|
|
172
|
+
queryData?: string | Record<string, unknown>;
|
|
173
|
+
stringifyOptions?: QueryString.IStringifyOptions;
|
|
174
|
+
validateResponse?: (response: AxiosResponse<DataType | null>) => Promise<boolean | string> | boolean | string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type TMethod = {
|
|
178
|
+
name: string;
|
|
179
|
+
props: {
|
|
180
|
+
attributes?: Record<string, unknown>;
|
|
181
|
+
currentUrl?: string;
|
|
182
|
+
funCall?: string;
|
|
183
|
+
inlineArguments?: string[];
|
|
184
|
+
messages?: unknown;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
type TApiaApiMethodHandler = {
|
|
188
|
+
alert: typeof notify;
|
|
189
|
+
close: () => void;
|
|
190
|
+
configuration?: THandleConfiguration;
|
|
191
|
+
formDefinition: TApiaLoad;
|
|
192
|
+
reset: () => void;
|
|
193
|
+
setError: typeof notify;
|
|
194
|
+
setMessage: (message: Record<string, unknown>) => unknown;
|
|
195
|
+
setState: React.Dispatch<React.SetStateAction<IApiaApiHandlerState>>;
|
|
196
|
+
state: IApiaApiHandlerState;
|
|
197
|
+
setValue: (name: string, value: string) => void;
|
|
198
|
+
};
|
|
199
|
+
type TApiaApiMethod = (handler: TApiaApiMethodHandler, props: TMethod['props']) => Promise<void> | void;
|
|
200
|
+
interface IModalConfig {
|
|
201
|
+
modalTitle?: string;
|
|
202
|
+
onClose?: () => void;
|
|
203
|
+
onMessage?: (message: Record<string, unknown>) => unknown;
|
|
204
|
+
onMessageClose?: () => unknown;
|
|
205
|
+
onSubmitted?: (handler: TApiaApiMethodHandler, response: AxiosResponse<Record<string, unknown> | null> | null) => unknown;
|
|
206
|
+
}
|
|
207
|
+
type THandleConfiguration = Partial<Pick<IApiaApiRequestConfig<unknown>, 'modalConfiguration' | 'methodsPath'>>;
|
|
208
|
+
interface IApiaApiHandlerState {
|
|
209
|
+
disabled: boolean;
|
|
210
|
+
isLoading: boolean;
|
|
211
|
+
isMultipart: boolean;
|
|
212
|
+
progress: number;
|
|
213
|
+
errors: Record<string, string>;
|
|
214
|
+
windowIndex: number;
|
|
215
|
+
}
|
|
216
|
+
declare const ApiaApiHandler: React.MemoExoticComponent<() => theme_ui_jsx_runtime.JSX.Element>;
|
|
217
|
+
|
|
218
|
+
declare global {
|
|
219
|
+
interface Window {
|
|
220
|
+
[key: string]: string;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { ApiaApi, ApiaApiHandler, TApiaApiMethod, TApiaApiResult, makeApiaUrl };
|
|
225
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|