@mx-space/api-client 0.3.6 → 0.3.7
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/build/index.cjs.js +50 -0
- package/build/index.cjs.js.map +1 -1
- package/build/index.cjs.min.js +1 -1
- package/build/index.cjs.min.js.map +1 -1
- package/build/index.esm.js +50 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.esm.min.js +1 -1
- package/build/index.esm.min.js.map +1 -1
- package/build/index.umd.js +50 -0
- package/build/index.umd.js.map +1 -1
- package/build/index.umd.min.js +1 -1
- package/build/index.umd.min.js.map +1 -1
- package/esm/core/controllers/aggregate.js +2 -0
- package/esm/core/controllers/aggregate.js.map +1 -1
- package/esm/core/controllers/base.js +2 -0
- package/esm/core/controllers/base.js.map +1 -1
- package/esm/core/controllers/category.js +2 -0
- package/esm/core/controllers/category.js.map +1 -1
- package/esm/core/controllers/comment.js +2 -0
- package/esm/core/controllers/comment.js.map +1 -1
- package/esm/core/controllers/link.js +2 -0
- package/esm/core/controllers/link.js.map +1 -1
- package/esm/core/controllers/note.js +2 -0
- package/esm/core/controllers/note.js.map +1 -1
- package/esm/core/controllers/page.d.ts +4 -5
- package/esm/core/controllers/page.js +2 -0
- package/esm/core/controllers/page.js.map +1 -1
- package/esm/core/controllers/post.js +2 -0
- package/esm/core/controllers/post.js.map +1 -1
- package/esm/core/controllers/project.js +2 -0
- package/esm/core/controllers/project.js.map +1 -1
- package/esm/core/controllers/recently.d.ts +4 -5
- package/esm/core/controllers/recently.js +2 -0
- package/esm/core/controllers/recently.js.map +1 -1
- package/esm/core/controllers/say.d.ts +2 -3
- package/esm/core/controllers/say.js +2 -0
- package/esm/core/controllers/say.js.map +1 -1
- package/esm/core/controllers/search.js +2 -0
- package/esm/core/controllers/search.js.map +1 -1
- package/esm/core/controllers/snippet.d.ts +3 -4
- package/esm/core/controllers/snippet.js +2 -0
- package/esm/core/controllers/snippet.js.map +1 -1
- package/esm/core/controllers/user.d.ts +4 -5
- package/esm/core/controllers/user.js +2 -0
- package/esm/core/controllers/user.js.map +1 -1
- package/esm/utils/auto-bind.d.ts +4 -0
- package/esm/utils/auto-bind.js +36 -0
- package/esm/utils/auto-bind.js.map +1 -0
- package/lib/core/controllers/aggregate.js +2 -0
- package/lib/core/controllers/aggregate.js.map +1 -1
- package/lib/core/controllers/base.js +2 -0
- package/lib/core/controllers/base.js.map +1 -1
- package/lib/core/controllers/category.js +2 -0
- package/lib/core/controllers/category.js.map +1 -1
- package/lib/core/controllers/comment.js +2 -0
- package/lib/core/controllers/comment.js.map +1 -1
- package/lib/core/controllers/link.js +2 -0
- package/lib/core/controllers/link.js.map +1 -1
- package/lib/core/controllers/note.js +2 -0
- package/lib/core/controllers/note.js.map +1 -1
- package/lib/core/controllers/page.d.ts +4 -5
- package/lib/core/controllers/page.js +2 -0
- package/lib/core/controllers/page.js.map +1 -1
- package/lib/core/controllers/post.js +2 -0
- package/lib/core/controllers/post.js.map +1 -1
- package/lib/core/controllers/project.js +2 -0
- package/lib/core/controllers/project.js.map +1 -1
- package/lib/core/controllers/recently.d.ts +4 -5
- package/lib/core/controllers/recently.js +2 -0
- package/lib/core/controllers/recently.js.map +1 -1
- package/lib/core/controllers/say.d.ts +2 -3
- package/lib/core/controllers/say.js +2 -0
- package/lib/core/controllers/say.js.map +1 -1
- package/lib/core/controllers/search.js +2 -0
- package/lib/core/controllers/search.js.map +1 -1
- package/lib/core/controllers/snippet.d.ts +3 -4
- package/lib/core/controllers/snippet.js +2 -0
- package/lib/core/controllers/snippet.js.map +1 -1
- package/lib/core/controllers/user.d.ts +4 -5
- package/lib/core/controllers/user.js +2 -0
- package/lib/core/controllers/user.js.map +1 -1
- package/lib/utils/auto-bind.d.ts +4 -0
- package/lib/utils/auto-bind.js +40 -0
- package/lib/utils/auto-bind.js.map +1 -0
- package/package.json +4 -4
- package/readme.md +26 -3
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PageController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
class PageController {
|
|
5
6
|
constructor(client) {
|
|
6
7
|
this.client = client;
|
|
7
8
|
this.base = 'pages';
|
|
8
9
|
this.name = 'page';
|
|
10
|
+
(0, auto_bind_1.autoBind)(this);
|
|
9
11
|
}
|
|
10
12
|
get proxy() {
|
|
11
13
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/core/controllers/page.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/core/controllers/page.ts"],"names":[],"mappings":";;;AAIA,qDAA4C;AAS5C,MAAa,cAAc;IACzB,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAG/C,SAAI,GAAG,OAAO,CAAA;QACd,SAAI,GAAG,MAAM,CAAA;QAHX,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAGD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IACD;;OAEG;IACH,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,UAA2B,EAAE;QAC3D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B;YAC/C,MAAM,EAAE;gBACN,IAAI;gBACJ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,GAAG,CAAC;gBACzB,MAAM;gBACN,SAAS;aACV;SACF,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,EAAa,CAAA;IACxC,CAAC;IACD;;;;OAIG;IACH,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAY,EAAE,CAAC,CAAA;IACjD,CAAC;CACF;AAvCD,wCAuCC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
class PostController {
|
|
5
6
|
constructor(client) {
|
|
6
7
|
this.client = client;
|
|
7
8
|
this.base = 'posts';
|
|
8
9
|
this.name = 'post';
|
|
10
|
+
(0, auto_bind_1.autoBind)(this);
|
|
9
11
|
}
|
|
10
12
|
get proxy() {
|
|
11
13
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/core/controllers/post.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/core/controllers/post.ts"],"names":[],"mappings":";;;AAKA,qDAA4C;AAU5C,MAAa,cAAc;IACzB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAItC,SAAI,GAAG,OAAO,CAAA;QAEd,SAAI,GAAG,MAAM,CAAA;QALX,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAMD,IAAY,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,UAA2B,EAAE;QAC3D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B;YAC/C,MAAM,EAAE;gBACN,IAAI;gBACJ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,GAAG,CAAC;gBACzB,MAAM;gBACN,SAAS;gBACT,IAAI;aACL;SACF,CAAC,CAAA;IACJ,CAAC;IAaD,OAAO,CAAC,gBAAwB,EAAE,IAAa;QAC7C,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAa,CAAA;SACrD;aAAM;YACL,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAa,CAAA;SAC3D;IACH,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAa,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,GAAG,CAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAC/D,CAAC;CACF;AAjED,wCAiEC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
const base_1 = require("./base");
|
|
5
6
|
class ProjectController extends base_1.BaseCrudController {
|
|
6
7
|
constructor(client) {
|
|
@@ -8,6 +9,7 @@ class ProjectController extends base_1.BaseCrudController {
|
|
|
8
9
|
this.client = client;
|
|
9
10
|
this.base = 'projects';
|
|
10
11
|
this.name = 'project';
|
|
12
|
+
(0, auto_bind_1.autoBind)(this);
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
exports.ProjectController = ProjectController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/core/controllers/project.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/core/controllers/project.ts"],"names":[],"mappings":";;;AACA,qDAA4C;AAE5C,iCAA2C;AAE3C,MAAa,iBAAkB,SAAQ,yBAAgC;IACrE,YAA+B,MAAkB;QAC/C,KAAK,CAAC,MAAM,CAAC,CAAA;QADgB,WAAM,GAAN,MAAM,CAAY;QAKjD,SAAI,GAAG,UAAU,CAAA;QACjB,SAAI,GAAG,SAAS,CAAA;QAJd,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;CAIF;AARD,8CAQC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IController } from "../../interfaces/controller";
|
|
2
|
-
import { IRequestHandler, RequestProxyResult } from "../../interfaces/request";
|
|
3
2
|
import { RecentlyModel } from "../../models/recently";
|
|
4
3
|
import { HTTPClient } from '..';
|
|
5
4
|
export declare class RecentlyController implements IController {
|
|
@@ -7,15 +6,15 @@ export declare class RecentlyController implements IController {
|
|
|
7
6
|
base: string;
|
|
8
7
|
name: string;
|
|
9
8
|
constructor(client: HTTPClient);
|
|
10
|
-
get proxy(): IRequestHandler;
|
|
9
|
+
get proxy(): import("../../interfaces/request").IRequestHandler;
|
|
11
10
|
/**
|
|
12
11
|
* 获取最新一条
|
|
13
12
|
*/
|
|
14
|
-
getLatestOne(): RequestProxyResult<RecentlyModel, {
|
|
13
|
+
getLatestOne(): import("../../interfaces/request").RequestProxyResult<RecentlyModel, {
|
|
15
14
|
[key: string]: any;
|
|
16
15
|
data: RecentlyModel;
|
|
17
16
|
}>;
|
|
18
|
-
getAll(): RequestProxyResult<{
|
|
17
|
+
getAll(): import("../../interfaces/request").RequestProxyResult<{
|
|
19
18
|
data: RecentlyModel[];
|
|
20
19
|
}, {
|
|
21
20
|
[key: string]: any;
|
|
@@ -23,7 +22,7 @@ export declare class RecentlyController implements IController {
|
|
|
23
22
|
data: RecentlyModel[];
|
|
24
23
|
};
|
|
25
24
|
}>;
|
|
26
|
-
getList(before?: string | undefined, after?: string | undefined, size?: number | number): RequestProxyResult<{
|
|
25
|
+
getList(before?: string | undefined, after?: string | undefined, size?: number | number): import("../../interfaces/request").RequestProxyResult<{
|
|
27
26
|
data: RecentlyModel[];
|
|
28
27
|
}, {
|
|
29
28
|
[key: string]: any;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RecentlyController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
class RecentlyController {
|
|
5
6
|
constructor(client) {
|
|
6
7
|
this.client = client;
|
|
7
8
|
this.base = 'recently';
|
|
8
9
|
this.name = 'recently';
|
|
10
|
+
(0, auto_bind_1.autoBind)(this);
|
|
9
11
|
}
|
|
10
12
|
get proxy() {
|
|
11
13
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recently.js","sourceRoot":"","sources":["../../../src/core/controllers/recently.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"recently.js","sourceRoot":"","sources":["../../../src/core/controllers/recently.ts"],"names":[],"mappings":";;;AAEA,qDAA4C;AAG5C,MAAa,kBAAkB;IAI7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAH/C,SAAI,GAAG,UAAU,CAAA;QACjB,SAAI,GAAG,UAAU,CAAA;QAGf,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IACD;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAiB,CAAA;IAC/C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAA6B,CAAA;IACxD,CAAC;IAED,OAAO,CACL,MAA2B,EAC3B,KAA0B,EAC1B,IAAsB;QAEtB,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC3D;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B;YAC/C,MAAM,EAAE;gBACN,MAAM;gBACN,KAAK;gBACL,IAAI;aACL;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAtCD,gDAsCC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IController } from "../../interfaces/controller";
|
|
2
|
-
import { IRequestHandler, RequestProxyResult } from "../../interfaces/request";
|
|
3
2
|
import { SayModel } from "../../models/say";
|
|
4
3
|
import { HTTPClient } from '..';
|
|
5
4
|
import { BaseCrudController } from './base';
|
|
@@ -8,11 +7,11 @@ export declare class SayController extends BaseCrudController<SayModel> implemen
|
|
|
8
7
|
base: string;
|
|
9
8
|
name: string;
|
|
10
9
|
constructor(client: HTTPClient);
|
|
11
|
-
protected get proxy(): IRequestHandler;
|
|
10
|
+
protected get proxy(): import("../../interfaces/request").IRequestHandler;
|
|
12
11
|
/**
|
|
13
12
|
* 获取随机一条
|
|
14
13
|
*/
|
|
15
|
-
getRandom(): RequestProxyResult<{
|
|
14
|
+
getRandom(): import("../../interfaces/request").RequestProxyResult<{
|
|
16
15
|
data: SayModel | null;
|
|
17
16
|
}, {
|
|
18
17
|
[key: string]: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SayController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
const base_1 = require("./base");
|
|
5
6
|
class SayController extends base_1.BaseCrudController {
|
|
6
7
|
constructor(client) {
|
|
@@ -8,6 +9,7 @@ class SayController extends base_1.BaseCrudController {
|
|
|
8
9
|
this.client = client;
|
|
9
10
|
this.base = 'says';
|
|
10
11
|
this.name = 'say';
|
|
12
|
+
(0, auto_bind_1.autoBind)(this);
|
|
11
13
|
}
|
|
12
14
|
get proxy() {
|
|
13
15
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"say.js","sourceRoot":"","sources":["../../../src/core/controllers/say.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"say.js","sourceRoot":"","sources":["../../../src/core/controllers/say.ts"],"names":[],"mappings":";;;AAEA,qDAA4C;AAE5C,iCAA2C;AAE3C,MAAa,aACX,SAAQ,yBAA4B;IAMpC,YAAsB,MAAkB;QACtC,KAAK,CAAC,MAAM,CAAC,CAAA;QADO,WAAM,GAAN,MAAM,CAAY;QAHxC,SAAI,GAAG,MAAM,CAAA;QACb,SAAI,GAAG,KAAK,CAAA;QAIV,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAA6B,CAAA;IAC3D,CAAC;CACF;AAtBD,sCAsBC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SearchController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
class SearchController {
|
|
5
6
|
constructor(client) {
|
|
6
7
|
this.client = client;
|
|
7
8
|
this.base = 'search';
|
|
8
9
|
this.name = 'search';
|
|
10
|
+
(0, auto_bind_1.autoBind)(this);
|
|
9
11
|
}
|
|
10
12
|
get proxy() {
|
|
11
13
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/core/controllers/search.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/core/controllers/search.ts"],"names":[],"mappings":";;;AAKA,qDAA4C;AAU5C,MAAa,gBAAgB;IAI3B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAH/C,SAAI,GAAG,QAAQ,CAAA;QACf,SAAI,GAAG,QAAQ,CAAA;QAGb,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IA2BD,MAAM,CACJ,IAAgB,EAChB,OAAe,EACf,UAA4C,EAAE;QAE9C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;YAC1B,MAAM,kBAAI,OAAO,IAAK,OAAO,CAAE;SAChC,CAAC,CAAA;IACJ,CAAC;IACD;;;;;;OAMG;IACH,eAAe,CAAC,OAAe,EAAE,OAAsB;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAc9B,EAAE,MAAM,kBAAI,OAAO,IAAK,OAAO,CAAE,EAAE,CAAC,CAAA;IACxC,CAAC;CACF;AAtED,4CAsEC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IController } from "../../interfaces/controller";
|
|
2
|
-
import { IRequestHandler, RequestProxyResult } from "../../interfaces/request";
|
|
3
2
|
import { SnippetModel } from "../../models/snippet";
|
|
4
3
|
import { HTTPClient } from '..';
|
|
5
4
|
export declare class SnippetController implements IController {
|
|
@@ -7,12 +6,12 @@ export declare class SnippetController implements IController {
|
|
|
7
6
|
base: string;
|
|
8
7
|
name: string;
|
|
9
8
|
constructor(client: HTTPClient);
|
|
10
|
-
get proxy(): IRequestHandler;
|
|
11
|
-
getById(id: string): RequestProxyResult<SnippetModel, {
|
|
9
|
+
get proxy(): import("../../interfaces/request").IRequestHandler;
|
|
10
|
+
getById(id: string): import("../../interfaces/request").RequestProxyResult<SnippetModel, {
|
|
12
11
|
[key: string]: any;
|
|
13
12
|
data: SnippetModel;
|
|
14
13
|
}>;
|
|
15
|
-
getByReferenceAndName(reference: string, name: string): RequestProxyResult<SnippetModel, {
|
|
14
|
+
getByReferenceAndName(reference: string, name: string): import("../../interfaces/request").RequestProxyResult<SnippetModel, {
|
|
16
15
|
[key: string]: any;
|
|
17
16
|
data: SnippetModel;
|
|
18
17
|
}>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SnippetController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
class SnippetController {
|
|
5
6
|
constructor(client) {
|
|
6
7
|
this.client = client;
|
|
7
8
|
this.base = 'snippets';
|
|
8
9
|
this.name = 'snippet';
|
|
10
|
+
(0, auto_bind_1.autoBind)(this);
|
|
9
11
|
}
|
|
10
12
|
get proxy() {
|
|
11
13
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../../src/core/controllers/snippet.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../../src/core/controllers/snippet.ts"],"names":[],"mappings":";;;AAEA,qDAA4C;AAG5C,MAAa,iBAAiB;IAI5B,YAAsB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAHxC,SAAI,GAAG,UAAU,CAAA;QACjB,SAAI,GAAG,SAAS,CAAA;QAGd,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,EAAgB,CAAA;IAC3C,CAAC;IAED,qBAAqB,CAAC,SAAiB,EAAE,IAAY;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAgB,CAAA;IACxD,CAAC;CACF;AAnBD,8CAmBC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IController } from "../../interfaces/controller";
|
|
2
|
-
import { IRequestHandler, RequestProxyResult } from "../../interfaces/request";
|
|
3
2
|
import { TLogin, UserModel } from "../../models/user";
|
|
4
3
|
import { HTTPClient } from '..';
|
|
5
4
|
export declare class UserController implements IController {
|
|
@@ -7,16 +6,16 @@ export declare class UserController implements IController {
|
|
|
7
6
|
constructor(client: HTTPClient);
|
|
8
7
|
base: string;
|
|
9
8
|
name: string;
|
|
10
|
-
protected get proxy(): IRequestHandler;
|
|
11
|
-
getMasterInfo(): RequestProxyResult<UserModel, {
|
|
9
|
+
protected get proxy(): import("../../interfaces/request").IRequestHandler;
|
|
10
|
+
getMasterInfo(): import("../../interfaces/request").RequestProxyResult<UserModel, {
|
|
12
11
|
[key: string]: any;
|
|
13
12
|
data: UserModel;
|
|
14
13
|
}>;
|
|
15
|
-
login(username: string, password: string): RequestProxyResult<TLogin, {
|
|
14
|
+
login(username: string, password: string): import("../../interfaces/request").RequestProxyResult<TLogin, {
|
|
16
15
|
[key: string]: any;
|
|
17
16
|
data: TLogin;
|
|
18
17
|
}>;
|
|
19
|
-
checkTokenValid(token: string): RequestProxyResult<{
|
|
18
|
+
checkTokenValid(token: string): import("../../interfaces/request").RequestProxyResult<{
|
|
20
19
|
ok: number;
|
|
21
20
|
isGuest: boolean;
|
|
22
21
|
}, {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserController = void 0;
|
|
4
|
+
const auto_bind_1 = require("../../utils/auto-bind");
|
|
4
5
|
class UserController {
|
|
5
6
|
constructor(client) {
|
|
6
7
|
this.client = client;
|
|
7
8
|
this.base = 'master';
|
|
8
9
|
this.name = 'user';
|
|
10
|
+
(0, auto_bind_1.autoBind)(this);
|
|
9
11
|
}
|
|
10
12
|
get proxy() {
|
|
11
13
|
return this.client.proxy(this.base);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/core/controllers/user.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/core/controllers/user.ts"],"names":[],"mappings":";;;AAEA,qDAA4C;AAG5C,MAAa,cAAc;IACzB,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAI/C,SAAI,GAAG,QAAQ,CAAA;QAEf,SAAI,GAAG,MAAM,CAAA;QALX,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAMD,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAa,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,QAAgB,EAAE,QAAgB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAS;YACnC,IAAI,EAAE;gBACJ,QAAQ;gBACR,QAAQ;aACT;SACF,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAmC;YACnE,MAAM,EAAE;gBACN,KAAK;aACN;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAjCD,wCAiCC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
// @copy: https://github.com/sindresorhus/auto-bind/blob/main/index.js
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.autoBind = void 0;
|
|
6
|
+
// Gets all non-builtin properties up the prototype chain.
|
|
7
|
+
const getAllProperties = (object) => {
|
|
8
|
+
const properties = new Set();
|
|
9
|
+
do {
|
|
10
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
11
|
+
properties.add([object, key]);
|
|
12
|
+
}
|
|
13
|
+
} while ((object = Reflect.getPrototypeOf(object)) &&
|
|
14
|
+
object !== Object.prototype);
|
|
15
|
+
return properties;
|
|
16
|
+
};
|
|
17
|
+
function autoBind(self, { include, exclude } = {}) {
|
|
18
|
+
const filter = (key) => {
|
|
19
|
+
const match = (pattern) => typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
20
|
+
if (include) {
|
|
21
|
+
return include.some(match);
|
|
22
|
+
}
|
|
23
|
+
if (exclude) {
|
|
24
|
+
return !exclude.some(match);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
for (const [object, key] of getAllProperties(self.constructor.prototype)) {
|
|
29
|
+
if (key === 'constructor' || !filter(key)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
33
|
+
if (descriptor && typeof descriptor.value === 'function') {
|
|
34
|
+
self[key] = self[key].bind(self);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
exports.autoBind = autoBind;
|
|
40
|
+
//# sourceMappingURL=auto-bind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-bind.js","sourceRoot":"","sources":["../../src/utils/auto-bind.ts"],"names":[],"mappings":";AAAA,cAAc;AACd,sEAAsE;;;AAEtE,0DAA0D;AAC1D,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,EAAE;IAClC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;IAE5B,GAAG;QACD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;SAC9B;KACF,QACC,CAAC,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,MAAM,CAAC,SAAS,EAC5B;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED,SAAgB,QAAQ,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE;IACtD,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,EAAE,CACxB,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAEnE,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SAC5B;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE;QACxE,IAAI,GAAG,KAAK,aAAa,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACzC,SAAQ;SACT;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAChE,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU,EAAE;YACxD,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACjC;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AA5BD,4BA4BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "A api client for mx-space server@next",
|
|
5
5
|
"author": "Innei",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@innei-util/prettier": "latest",
|
|
62
62
|
"@innei/bump-version": "0.1.5",
|
|
63
63
|
"@rollup/plugin-commonjs": "21.0.1",
|
|
64
|
-
"@rollup/plugin-node-resolve": "13.
|
|
64
|
+
"@rollup/plugin-node-resolve": "13.1.1",
|
|
65
65
|
"@rollup/plugin-typescript": "8.3.0",
|
|
66
66
|
"@types/express": "4.17.13",
|
|
67
67
|
"@types/jest": "27.0.3",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"express": "4.17.1",
|
|
78
78
|
"gh-pages": "3.2.3",
|
|
79
79
|
"husky": "7.0.4",
|
|
80
|
-
"jest": "27.4.
|
|
80
|
+
"jest": "27.4.5",
|
|
81
81
|
"lint-staged": "12.1.2",
|
|
82
82
|
"lodash": "4.17.21",
|
|
83
83
|
"prettier": "2.5.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"ttypescript": "1.5.13",
|
|
93
93
|
"typescript": "4.4.4",
|
|
94
94
|
"umi-request": "1.4.0",
|
|
95
|
-
"vite": "2.7.
|
|
95
|
+
"vite": "2.7.2",
|
|
96
96
|
"vite-tsconfig-paths": "3.3.17"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
package/readme.md
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
以 `axios` 为例。
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
|
|
14
|
+
// esm format (spa recommend)
|
|
15
|
+
import { axiosAdaptor } from '@mx-space/api-client/esm/adaptors/axios'
|
|
16
|
+
// cjs format (ssr recommend)
|
|
17
|
+
// import { axiosAdaptor } from '@mx-space/api-client/lib/adaptors/axios'
|
|
15
18
|
import {
|
|
16
19
|
AggregateController,
|
|
17
20
|
CategoryController,
|
|
@@ -28,7 +31,27 @@ const client = createClient(axiosAdaptor)(endpoint)
|
|
|
28
31
|
// `default` is AxiosInstance
|
|
29
32
|
// you can do anything else on this
|
|
30
33
|
// interceptor or re-configure
|
|
31
|
-
const axios = axiosAdaptor.default
|
|
34
|
+
const $axios = axiosAdaptor.default
|
|
35
|
+
// re-config (optional)
|
|
36
|
+
$axios.defaults.timeout = 10000
|
|
37
|
+
// set interceptors (optional)
|
|
38
|
+
$axios.interceptors.request.use(
|
|
39
|
+
(config) => {
|
|
40
|
+
const token = getToken()
|
|
41
|
+
if (token) {
|
|
42
|
+
config.headers!['Authorization'] = 'bearer ' + getToken()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return config
|
|
46
|
+
},
|
|
47
|
+
(error) => {
|
|
48
|
+
if (__DEV__) {
|
|
49
|
+
console.log(error.message)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return Promise.reject(error)
|
|
53
|
+
},
|
|
54
|
+
)
|
|
32
55
|
|
|
33
56
|
// inject controller first.
|
|
34
57
|
client.injectControllers([
|
|
@@ -58,4 +81,4 @@ client.post.post.getList(page, 10, { year }).then((data) => {
|
|
|
58
81
|
|
|
59
82
|
**如果不使用 axios,应该如何编写适配器**
|
|
60
83
|
|
|
61
|
-
参考 `src/adaptors/axios.ts` 和 `src/adaptors/umi-request.ts`
|
|
84
|
+
参考 `src/adaptors/axios.ts` 和 `src/adaptors/umi-request.ts`
|