@thepassle/app-tools 0.9.8 → 0.9.10
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/api/index.js +8 -8
- package/api/plugins/abort.js +1 -1
- package/api/plugins/cache.js +1 -1
- package/api/plugins/delay.js +1 -1
- package/api/plugins/jsonPrefix.js +1 -1
- package/api/plugins/logger.js +1 -1
- package/api/plugins/mock.js +1 -1
- package/api/plugins/xsrf.js +1 -1
- package/package.json +1 -1
- package/router/index.js +3 -0
- package/router/plugins/redirect.js +1 -1
- package/types/api/index.d.ts +14 -14
- package/types/api/plugins/abort.d.ts +3 -3
- package/types/api/plugins/cache.d.ts +3 -3
- package/types/api/plugins/delay.d.ts +2 -2
- package/types/api/plugins/jsonPrefix.d.ts +3 -3
- package/types/api/plugins/logger.d.ts +3 -3
- package/types/api/plugins/mock.d.ts +2 -2
- package/types/api/plugins/xsrf.d.ts +3 -3
- package/types/api/types.d.ts +2 -2
- package/types/router/index.d.ts +4 -0
- package/types/router/plugins/redirect.d.ts +2 -2
package/api/index.js
CHANGED
|
@@ -149,20 +149,20 @@ export class Api {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
/** @type {import('./types.js').BodylessMethod
|
|
152
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
153
153
|
get = (url, opts) => this.fetch(url, 'GET', opts);
|
|
154
|
-
/** @type {import('./types.js').BodylessMethod
|
|
154
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
155
155
|
options = (url, opts) => this.fetch(url, 'OPTIONS', opts);
|
|
156
|
-
/** @type {import('./types.js').BodylessMethod
|
|
156
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
157
157
|
delete = (url, opts) => this.fetch(url, 'DELETE', opts);
|
|
158
|
-
/** @type {import('./types.js').BodylessMethod
|
|
158
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
159
159
|
head = (url, opts) => this.fetch(url, 'HEAD', opts);
|
|
160
|
-
/** @type {import('./types.js').BodyMethod
|
|
160
|
+
/** @type {import('./types.js').BodyMethod} */
|
|
161
161
|
post = (url, data, opts) => this.fetch(url, 'POST', opts, data);
|
|
162
|
-
/** @type {import('./types.js').BodyMethod
|
|
162
|
+
/** @type {import('./types.js').BodyMethod} */
|
|
163
163
|
put = (url, data, opts) => this.fetch(url, 'PUT', opts, data);
|
|
164
|
-
/** @type {import('./types.js').BodyMethod
|
|
164
|
+
/** @type {import('./types.js').BodyMethod} */
|
|
165
165
|
patch = (url, data, opts) => this.fetch(url, 'PATCH', opts, data);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
export const api = new Api();
|
|
168
|
+
export const api = new Api();
|
package/api/plugins/abort.js
CHANGED
package/api/plugins/cache.js
CHANGED
package/api/plugins/delay.js
CHANGED
package/api/plugins/logger.js
CHANGED
package/api/plugins/mock.js
CHANGED
|
@@ -2,7 +2,7 @@ import { setAbortableTimeout } from '../../utils/async.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {Response | (() => Response) | (() => Promise<Response>)} response
|
|
5
|
-
* @returns {import('../index').Plugin}
|
|
5
|
+
* @returns {import('../index.js').Plugin}
|
|
6
6
|
*/
|
|
7
7
|
export function mock(response) {
|
|
8
8
|
return {
|
package/api/plugins/xsrf.js
CHANGED
|
@@ -8,7 +8,7 @@ function getCookie(name, _document = document) {
|
|
|
8
8
|
* xsrfCookieName?: string,
|
|
9
9
|
* xsrfHeaderName?: string,
|
|
10
10
|
* }} options
|
|
11
|
-
* @returns {import('../index').Plugin}
|
|
11
|
+
* @returns {import('../index.js').Plugin}
|
|
12
12
|
*/
|
|
13
13
|
export function xsrfPlugin({
|
|
14
14
|
xsrfCookieName = 'XSRF-TOKEN',
|
package/package.json
CHANGED
package/router/index.js
CHANGED
package/types/api/index.d.ts
CHANGED
|
@@ -33,20 +33,20 @@ export class Api {
|
|
|
33
33
|
* @returns
|
|
34
34
|
*/
|
|
35
35
|
fetch(url: string, method: Method, opts?: RequestOptions, data?: object): Promise<any>;
|
|
36
|
-
/** @type {import('./types.js').BodylessMethod
|
|
37
|
-
get: import('./types.js').BodylessMethod
|
|
38
|
-
/** @type {import('./types.js').BodylessMethod
|
|
39
|
-
options: import('./types.js').BodylessMethod
|
|
40
|
-
/** @type {import('./types.js').BodylessMethod
|
|
41
|
-
delete: import('./types.js').BodylessMethod
|
|
42
|
-
/** @type {import('./types.js').BodylessMethod
|
|
43
|
-
head: import('./types.js').BodylessMethod
|
|
44
|
-
/** @type {import('./types.js').BodyMethod
|
|
45
|
-
post: import('./types.js').BodyMethod
|
|
46
|
-
/** @type {import('./types.js').BodyMethod
|
|
47
|
-
put: import('./types.js').BodyMethod
|
|
48
|
-
/** @type {import('./types.js').BodyMethod
|
|
49
|
-
patch: import('./types.js').BodyMethod
|
|
36
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
37
|
+
get: import('./types.js').BodylessMethod;
|
|
38
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
39
|
+
options: import('./types.js').BodylessMethod;
|
|
40
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
41
|
+
delete: import('./types.js').BodylessMethod;
|
|
42
|
+
/** @type {import('./types.js').BodylessMethod} */
|
|
43
|
+
head: import('./types.js').BodylessMethod;
|
|
44
|
+
/** @type {import('./types.js').BodyMethod} */
|
|
45
|
+
post: import('./types.js').BodyMethod;
|
|
46
|
+
/** @type {import('./types.js').BodyMethod} */
|
|
47
|
+
put: import('./types.js').BodyMethod;
|
|
48
|
+
/** @type {import('./types.js').BodyMethod} */
|
|
49
|
+
patch: import('./types.js').BodyMethod;
|
|
50
50
|
}
|
|
51
51
|
export const api: Api;
|
|
52
52
|
export type Config = import('./types.js').Config;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @returns {import('../index').Plugin}
|
|
2
|
+
* @returns {import('../index.js').Plugin}
|
|
3
3
|
*/
|
|
4
|
-
export function abortPlugin(): import('../index').Plugin;
|
|
5
|
-
export const abort: import("../types").Plugin;
|
|
4
|
+
export function abortPlugin(): import('../index.js').Plugin;
|
|
5
|
+
export const abort: import("../types.js").Plugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {{maxAge?: number}} options
|
|
3
|
-
* @returns {import('../index').Plugin}
|
|
3
|
+
* @returns {import('../index.js').Plugin}
|
|
4
4
|
*/
|
|
5
5
|
export function cachePlugin({ maxAge }?: {
|
|
6
6
|
maxAge?: number;
|
|
7
|
-
}): import('../index').Plugin;
|
|
8
|
-
export const cache: import("../types").Plugin;
|
|
7
|
+
}): import('../index.js').Plugin;
|
|
8
|
+
export const cache: import("../types.js").Plugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function delayPlugin(ms: number): import('../index').Plugin;
|
|
2
|
-
export const delay: import("../types").Plugin;
|
|
1
|
+
export function delayPlugin(ms: number): import('../index.js').Plugin;
|
|
2
|
+
export const delay: import("../types.js").Plugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {string} jsonPrefix
|
|
3
|
-
* @returns {import('../index').Plugin}
|
|
3
|
+
* @returns {import('../index.js').Plugin}
|
|
4
4
|
*/
|
|
5
|
-
export function jsonPrefixPlugin(jsonPrefix: string): import('../index').Plugin;
|
|
6
|
-
export const jsonPrefix: import("../types").Plugin;
|
|
5
|
+
export function jsonPrefixPlugin(jsonPrefix: string): import('../index.js').Plugin;
|
|
6
|
+
export const jsonPrefix: import("../types.js").Plugin;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @param {{
|
|
3
3
|
* collapsed?: boolean
|
|
4
4
|
* }} options
|
|
5
|
-
* @returns {import('../index').Plugin}
|
|
5
|
+
* @returns {import('../index.js').Plugin}
|
|
6
6
|
*/
|
|
7
7
|
export function loggerPlugin({ collapsed }?: {
|
|
8
8
|
collapsed?: boolean;
|
|
9
|
-
}): import('../index').Plugin;
|
|
10
|
-
export const logger: import("../types").Plugin;
|
|
9
|
+
}): import('../index.js').Plugin;
|
|
10
|
+
export const logger: import("../types.js").Plugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {Response | (() => Response) | (() => Promise<Response>)} response
|
|
3
|
-
* @returns {import('../index').Plugin}
|
|
3
|
+
* @returns {import('../index.js').Plugin}
|
|
4
4
|
*/
|
|
5
|
-
export function mock(response: Response | (() => Response) | (() => Promise<Response>)): import('../index').Plugin;
|
|
5
|
+
export function mock(response: Response | (() => Response) | (() => Promise<Response>)): import('../index.js').Plugin;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* xsrfCookieName?: string,
|
|
4
4
|
* xsrfHeaderName?: string,
|
|
5
5
|
* }} options
|
|
6
|
-
* @returns {import('../index').Plugin}
|
|
6
|
+
* @returns {import('../index.js').Plugin}
|
|
7
7
|
*/
|
|
8
8
|
export function xsrfPlugin({ xsrfCookieName, xsrfHeaderName }?: {
|
|
9
9
|
xsrfCookieName?: string;
|
|
10
10
|
xsrfHeaderName?: string;
|
|
11
|
-
}): import('../index').Plugin;
|
|
12
|
-
export const xsrf: import("../types").Plugin;
|
|
11
|
+
}): import('../index.js').Plugin;
|
|
12
|
+
export const xsrf: import("../types.js").Plugin;
|
package/types/api/types.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export interface Config {
|
|
|
4
4
|
responseType?: ResponseType;
|
|
5
5
|
baseURL?: string;
|
|
6
6
|
}
|
|
7
|
-
export type BodyMethod<R>
|
|
8
|
-
export type BodylessMethod<R>
|
|
7
|
+
export type BodyMethod = <R>(url: string, data?: object, opts?: RequestOptions) => Promise<R>;
|
|
8
|
+
export type BodylessMethod = <R>(url: string, opts?: RequestOptions) => Promise<R>;
|
|
9
9
|
export type Method = 'GET' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH';
|
|
10
10
|
export interface Plugin {
|
|
11
11
|
beforeFetch?: (meta: MetaParams) => MetaParams | Promise<MetaParams> | void;
|
package/types/router/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {string} path
|
|
2
|
+
* @param {string|((context: import('../index.js').Context) => string)} path
|
|
3
3
|
* @returns {import('../index.js').Plugin}
|
|
4
4
|
*/
|
|
5
|
-
export function redirect(path: string): import('../index.js').Plugin;
|
|
5
|
+
export function redirect(path: string | ((context: import('../index.js').Context) => string)): import('../index.js').Plugin;
|