@mx-space/api-client 1.6.0 → 1.6.1
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/controllers/note.ts +2 -8
- package/controllers/post.ts +2 -8
- package/dist/adaptors/ky.cjs +1 -1
- package/dist/adaptors/ky.global.js +25 -39
- package/dist/adaptors/ky.js +1 -1
- package/dist/index.cjs +0 -12
- package/dist/index.d.cts +0 -22
- package/dist/index.d.ts +0 -22
- package/dist/index.global.js +0 -12
- package/dist/index.js +0 -12
- package/package.json +4 -4
package/controllers/note.ts
CHANGED
|
@@ -8,11 +8,12 @@ import type {
|
|
|
8
8
|
NoteWrappedPayload,
|
|
9
9
|
NoteWrappedWithLikedPayload,
|
|
10
10
|
} from '~/models/note'
|
|
11
|
-
import type { HTTPClient } from '../core/client'
|
|
12
11
|
import type { SortOptions } from './base'
|
|
13
12
|
|
|
14
13
|
import { autoBind } from '~/utils/auto-bind'
|
|
15
14
|
|
|
15
|
+
import { HTTPClient } from '../core/client'
|
|
16
|
+
|
|
16
17
|
declare module '../core/client' {
|
|
17
18
|
interface HTTPClient<
|
|
18
19
|
T extends IRequestAdapter = IRequestAdapter,
|
|
@@ -110,13 +111,6 @@ export class NoteController<ResponseWrapper> implements IController {
|
|
|
110
111
|
})
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
/**
|
|
114
|
-
* 喜欢这篇日记
|
|
115
|
-
*/
|
|
116
|
-
likeIt(id: string | number) {
|
|
117
|
-
return this.proxy.like(id).get<never>()
|
|
118
|
-
}
|
|
119
|
-
|
|
120
114
|
/**
|
|
121
115
|
* 获取专栏内的所有日记
|
|
122
116
|
*/
|
package/controllers/post.ts
CHANGED
|
@@ -4,10 +4,11 @@ import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
|
|
4
4
|
import type { SelectFields } from '~/interfaces/types'
|
|
5
5
|
import type { ModelWithLiked, PaginateResult } from '~/models/base'
|
|
6
6
|
import type { PostModel } from '~/models/post'
|
|
7
|
-
import type { HTTPClient } from '../core/client'
|
|
8
7
|
|
|
9
8
|
import { autoBind } from '~/utils/auto-bind'
|
|
10
9
|
|
|
10
|
+
import { HTTPClient } from '../core/client'
|
|
11
|
+
|
|
11
12
|
declare module '../core/client' {
|
|
12
13
|
interface HTTPClient<
|
|
13
14
|
T extends IRequestAdapter = IRequestAdapter,
|
|
@@ -85,11 +86,4 @@ export class PostController<ResponseWrapper> implements IController {
|
|
|
85
86
|
getLatest() {
|
|
86
87
|
return this.proxy.latest.get<ModelWithLiked<PostModel>>()
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 点赞
|
|
91
|
-
*/
|
|
92
|
-
thumbsUp(id: string) {
|
|
93
|
-
return this.proxy('_thumbs-up').get<void>({ params: { id } })
|
|
94
|
-
}
|
|
95
89
|
}
|
package/dist/adaptors/ky.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
// ../../node_modules/.pnpm/ky@
|
|
3
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/errors/HTTPError.js
|
|
4
4
|
var HTTPError = class extends Error {
|
|
5
5
|
constructor(response, request, options) {
|
|
6
6
|
const code = response.status || response.status === 0 ? response.status : "";
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/ky@
|
|
36
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/errors/TimeoutError.js
|
|
37
37
|
var TimeoutError = class extends Error {
|
|
38
38
|
constructor(request) {
|
|
39
39
|
super("Request timed out");
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
// ../../node_modules/.pnpm/ky@
|
|
51
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/utils/is.js
|
|
52
52
|
var isObject = (value) => value !== null && typeof value === "object";
|
|
53
53
|
|
|
54
|
-
// ../../node_modules/.pnpm/ky@
|
|
54
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/utils/merge.js
|
|
55
55
|
var validateAndMerge = (...sources) => {
|
|
56
56
|
for (const source of sources) {
|
|
57
|
-
if ((!isObject(source) || Array.isArray(source)) &&
|
|
57
|
+
if ((!isObject(source) || Array.isArray(source)) && source !== void 0) {
|
|
58
58
|
throw new TypeError("The `options` argument must be an object");
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -98,14 +98,14 @@
|
|
|
98
98
|
return returnValue;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
// ../../node_modules/.pnpm/ky@
|
|
101
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/core/constants.js
|
|
102
102
|
var supportsRequestStreams = (() => {
|
|
103
103
|
let duplexAccessed = false;
|
|
104
104
|
let hasContentType = false;
|
|
105
105
|
const supportsReadableStream = typeof globalThis.ReadableStream === "function";
|
|
106
106
|
const supportsRequest = typeof globalThis.Request === "function";
|
|
107
107
|
if (supportsReadableStream && supportsRequest) {
|
|
108
|
-
hasContentType = new globalThis.Request("https://
|
|
108
|
+
hasContentType = new globalThis.Request("https://empty.invalid", {
|
|
109
109
|
body: new globalThis.ReadableStream(),
|
|
110
110
|
method: "POST",
|
|
111
111
|
// @ts-expect-error - Types are outdated.
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
var maxSafeTimeout = 2147483647;
|
|
134
134
|
var stop = Symbol("stop");
|
|
135
135
|
|
|
136
|
-
// ../../node_modules/.pnpm/ky@
|
|
136
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/utils/normalize.js
|
|
137
137
|
var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
|
|
138
138
|
var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
|
|
139
139
|
var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
|
|
@@ -144,7 +144,8 @@
|
|
|
144
144
|
statusCodes: retryStatusCodes,
|
|
145
145
|
afterStatusCodes: retryAfterStatusCodes,
|
|
146
146
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
147
|
-
backoffLimit: Number.POSITIVE_INFINITY
|
|
147
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
148
|
+
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1e3
|
|
148
149
|
};
|
|
149
150
|
var normalizeRetryOptions = (retry = {}) => {
|
|
150
151
|
if (typeof retry === "number") {
|
|
@@ -166,7 +167,7 @@
|
|
|
166
167
|
};
|
|
167
168
|
};
|
|
168
169
|
|
|
169
|
-
// ../../node_modules/.pnpm/ky@
|
|
170
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/utils/timeout.js
|
|
170
171
|
async function timeout(request, abortController, options) {
|
|
171
172
|
return new Promise((resolve, reject) => {
|
|
172
173
|
const timeoutId = setTimeout(() => {
|
|
@@ -181,45 +182,30 @@
|
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
// ../../node_modules/.pnpm/ky@
|
|
185
|
-
var isDomExceptionSupported = Boolean(globalThis.DOMException);
|
|
186
|
-
function composeAbortError(signal) {
|
|
187
|
-
if (isDomExceptionSupported) {
|
|
188
|
-
return new DOMException(signal?.reason ?? "The operation was aborted.", "AbortError");
|
|
189
|
-
}
|
|
190
|
-
const error = new Error(signal?.reason ?? "The operation was aborted.");
|
|
191
|
-
error.name = "AbortError";
|
|
192
|
-
return error;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// ../../node_modules/.pnpm/ky@0.33.3/node_modules/ky/distribution/utils/delay.js
|
|
185
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/utils/delay.js
|
|
196
186
|
async function delay(ms, { signal }) {
|
|
197
187
|
return new Promise((resolve, reject) => {
|
|
198
188
|
if (signal) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
signal.addEventListener("abort", handleAbort, { once: true });
|
|
189
|
+
signal.throwIfAborted();
|
|
190
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
204
191
|
}
|
|
205
|
-
function
|
|
206
|
-
reject(composeAbortError(signal));
|
|
192
|
+
function abortHandler() {
|
|
207
193
|
clearTimeout(timeoutId);
|
|
194
|
+
reject(signal.reason);
|
|
208
195
|
}
|
|
209
196
|
const timeoutId = setTimeout(() => {
|
|
210
|
-
signal?.removeEventListener("abort",
|
|
197
|
+
signal?.removeEventListener("abort", abortHandler);
|
|
211
198
|
resolve();
|
|
212
199
|
}, ms);
|
|
213
200
|
});
|
|
214
201
|
}
|
|
215
202
|
|
|
216
|
-
// ../../node_modules/.pnpm/ky@
|
|
203
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/core/Ky.js
|
|
217
204
|
var Ky = class _Ky {
|
|
218
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
219
205
|
static create(input, options) {
|
|
220
206
|
const ky2 = new _Ky(input, options);
|
|
221
207
|
const fn = async () => {
|
|
222
|
-
if (ky2._options.timeout > maxSafeTimeout) {
|
|
208
|
+
if (typeof ky2._options.timeout === "number" && ky2._options.timeout > maxSafeTimeout) {
|
|
223
209
|
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
|
|
224
210
|
}
|
|
225
211
|
await Promise.resolve();
|
|
@@ -323,7 +309,7 @@
|
|
|
323
309
|
prefixUrl: String(options.prefixUrl || ""),
|
|
324
310
|
retry: normalizeRetryOptions(options.retry),
|
|
325
311
|
throwHttpErrors: options.throwHttpErrors !== false,
|
|
326
|
-
timeout:
|
|
312
|
+
timeout: options.timeout ?? 1e4,
|
|
327
313
|
fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
|
|
328
314
|
};
|
|
329
315
|
if (typeof this._input !== "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
|
|
@@ -382,7 +368,7 @@
|
|
|
382
368
|
} else {
|
|
383
369
|
after *= 1e3;
|
|
384
370
|
}
|
|
385
|
-
if (
|
|
371
|
+
if (this._options.retry.maxRetryAfter !== void 0 && after > this._options.retry.maxRetryAfter) {
|
|
386
372
|
return 0;
|
|
387
373
|
}
|
|
388
374
|
return after;
|
|
@@ -391,8 +377,8 @@
|
|
|
391
377
|
return 0;
|
|
392
378
|
}
|
|
393
379
|
}
|
|
394
|
-
const
|
|
395
|
-
return Math.min(this._options.retry.backoffLimit,
|
|
380
|
+
const retryDelay = this._options.retry.delay(this._retryCount);
|
|
381
|
+
return Math.min(this._options.retry.backoffLimit, retryDelay);
|
|
396
382
|
}
|
|
397
383
|
return 0;
|
|
398
384
|
}
|
|
@@ -485,7 +471,7 @@
|
|
|
485
471
|
}
|
|
486
472
|
};
|
|
487
473
|
|
|
488
|
-
// ../../node_modules/.pnpm/ky@
|
|
474
|
+
// ../../node_modules/.pnpm/ky@1.1.0/node_modules/ky/distribution/index.js
|
|
489
475
|
var createInstance = (defaults) => {
|
|
490
476
|
const ky2 = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
|
|
491
477
|
for (const method of requestMethods) {
|
|
@@ -520,7 +506,7 @@
|
|
|
520
506
|
get(url, options) {
|
|
521
507
|
return getDataFromKyResponse(ky2.get(url, options));
|
|
522
508
|
},
|
|
523
|
-
post(url, options) {
|
|
509
|
+
async post(url, options) {
|
|
524
510
|
const data = options.data;
|
|
525
511
|
delete options.data;
|
|
526
512
|
const kyOptions = {
|
package/dist/adaptors/ky.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -485,12 +485,6 @@ var NoteController = class {
|
|
|
485
485
|
params: { size }
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
|
-
/**
|
|
489
|
-
* 喜欢这篇日记
|
|
490
|
-
*/
|
|
491
|
-
likeIt(id) {
|
|
492
|
-
return this.proxy.like(id).get();
|
|
493
|
-
}
|
|
494
488
|
/**
|
|
495
489
|
* 获取专栏内的所有日记
|
|
496
490
|
*/
|
|
@@ -586,12 +580,6 @@ var PostController = class {
|
|
|
586
580
|
getLatest() {
|
|
587
581
|
return this.proxy.latest.get();
|
|
588
582
|
}
|
|
589
|
-
/**
|
|
590
|
-
* 点赞
|
|
591
|
-
*/
|
|
592
|
-
thumbsUp(id) {
|
|
593
|
-
return this.proxy("_thumbs-up").get({ params: { id } });
|
|
594
|
-
}
|
|
595
583
|
};
|
|
596
584
|
|
|
597
585
|
// controllers/project.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -884,17 +884,6 @@ declare class NoteController<ResponseWrapper> implements IController {
|
|
|
884
884
|
size: number;
|
|
885
885
|
};
|
|
886
886
|
}>;
|
|
887
|
-
/**
|
|
888
|
-
* 喜欢这篇日记
|
|
889
|
-
*/
|
|
890
|
-
likeIt(id: string | number): RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
891
|
-
[key: string]: any;
|
|
892
|
-
data: never;
|
|
893
|
-
} : ResponseWrapper extends {
|
|
894
|
-
data: never;
|
|
895
|
-
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
896
|
-
data: never;
|
|
897
|
-
}>;
|
|
898
887
|
/**
|
|
899
888
|
* 获取专栏内的所有日记
|
|
900
889
|
*/
|
|
@@ -1014,17 +1003,6 @@ declare class PostController<ResponseWrapper> implements IController {
|
|
|
1014
1003
|
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1015
1004
|
data: ModelWithLiked<PostModel>;
|
|
1016
1005
|
}>;
|
|
1017
|
-
/**
|
|
1018
|
-
* 点赞
|
|
1019
|
-
*/
|
|
1020
|
-
thumbsUp(id: string): RequestProxyResult<void, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1021
|
-
[key: string]: any;
|
|
1022
|
-
data: void;
|
|
1023
|
-
} : ResponseWrapper extends {
|
|
1024
|
-
data: void;
|
|
1025
|
-
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1026
|
-
data: void;
|
|
1027
|
-
}>;
|
|
1028
1006
|
}
|
|
1029
1007
|
|
|
1030
1008
|
interface ProjectModel extends BaseModel {
|
package/dist/index.d.ts
CHANGED
|
@@ -884,17 +884,6 @@ declare class NoteController<ResponseWrapper> implements IController {
|
|
|
884
884
|
size: number;
|
|
885
885
|
};
|
|
886
886
|
}>;
|
|
887
|
-
/**
|
|
888
|
-
* 喜欢这篇日记
|
|
889
|
-
*/
|
|
890
|
-
likeIt(id: string | number): RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
891
|
-
[key: string]: any;
|
|
892
|
-
data: never;
|
|
893
|
-
} : ResponseWrapper extends {
|
|
894
|
-
data: never;
|
|
895
|
-
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
896
|
-
data: never;
|
|
897
|
-
}>;
|
|
898
887
|
/**
|
|
899
888
|
* 获取专栏内的所有日记
|
|
900
889
|
*/
|
|
@@ -1014,17 +1003,6 @@ declare class PostController<ResponseWrapper> implements IController {
|
|
|
1014
1003
|
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1015
1004
|
data: ModelWithLiked<PostModel>;
|
|
1016
1005
|
}>;
|
|
1017
|
-
/**
|
|
1018
|
-
* 点赞
|
|
1019
|
-
*/
|
|
1020
|
-
thumbsUp(id: string): RequestProxyResult<void, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1021
|
-
[key: string]: any;
|
|
1022
|
-
data: void;
|
|
1023
|
-
} : ResponseWrapper extends {
|
|
1024
|
-
data: void;
|
|
1025
|
-
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1026
|
-
data: void;
|
|
1027
|
-
}>;
|
|
1028
1006
|
}
|
|
1029
1007
|
|
|
1030
1008
|
interface ProjectModel extends BaseModel {
|
package/dist/index.global.js
CHANGED
|
@@ -421,12 +421,6 @@
|
|
|
421
421
|
params: { size }
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
|
-
/**
|
|
425
|
-
* 喜欢这篇日记
|
|
426
|
-
*/
|
|
427
|
-
likeIt(id) {
|
|
428
|
-
return this.proxy.like(id).get();
|
|
429
|
-
}
|
|
430
424
|
/**
|
|
431
425
|
* 获取专栏内的所有日记
|
|
432
426
|
*/
|
|
@@ -522,12 +516,6 @@
|
|
|
522
516
|
getLatest() {
|
|
523
517
|
return this.proxy.latest.get();
|
|
524
518
|
}
|
|
525
|
-
/**
|
|
526
|
-
* 点赞
|
|
527
|
-
*/
|
|
528
|
-
thumbsUp(id) {
|
|
529
|
-
return this.proxy("_thumbs-up").get({ params: { id } });
|
|
530
|
-
}
|
|
531
519
|
};
|
|
532
520
|
|
|
533
521
|
// controllers/project.ts
|
package/dist/index.js
CHANGED
|
@@ -419,12 +419,6 @@ var NoteController = class {
|
|
|
419
419
|
params: { size }
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
|
-
/**
|
|
423
|
-
* 喜欢这篇日记
|
|
424
|
-
*/
|
|
425
|
-
likeIt(id) {
|
|
426
|
-
return this.proxy.like(id).get();
|
|
427
|
-
}
|
|
428
422
|
/**
|
|
429
423
|
* 获取专栏内的所有日记
|
|
430
424
|
*/
|
|
@@ -520,12 +514,6 @@ var PostController = class {
|
|
|
520
514
|
getLatest() {
|
|
521
515
|
return this.proxy.latest.get();
|
|
522
516
|
}
|
|
523
|
-
/**
|
|
524
|
-
* 点赞
|
|
525
|
-
*/
|
|
526
|
-
thumbsUp(id) {
|
|
527
|
-
return this.proxy("_thumbs-up").get({ params: { id } });
|
|
528
|
-
}
|
|
529
517
|
};
|
|
530
518
|
|
|
531
519
|
// controllers/project.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A api client for mx-space server@next",
|
|
6
6
|
"author": "Innei",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/cors": "2.8.15",
|
|
48
48
|
"@types/express": "4.17.20",
|
|
49
|
-
"@types/lodash": "4.14.
|
|
49
|
+
"@types/lodash": "4.14.200",
|
|
50
50
|
"abort-controller": "3.0.0",
|
|
51
51
|
"axios": "^1.5.1",
|
|
52
52
|
"camelcase-keys": "^7.0.2",
|
|
53
53
|
"cors": "2.8.5",
|
|
54
54
|
"express": "4.18.2",
|
|
55
55
|
"form-data": "4.0.0",
|
|
56
|
-
"ky": "
|
|
56
|
+
"ky": "1.1.0",
|
|
57
57
|
"lodash": "4.17.21",
|
|
58
58
|
"tsup": "7.2.0",
|
|
59
59
|
"umi-request": "1.4.0",
|
|
60
|
-
"vite": "^4.
|
|
60
|
+
"vite": "^4.5.0",
|
|
61
61
|
"vitest": "^0.34.6"
|
|
62
62
|
}
|
|
63
63
|
}
|