@ccw-api/api 0.4.0 → 0.4.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.
@@ -0,0 +1,14 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://bfs-web.ccw.site/extensions";
3
+ /**
4
+ * 向扩展投币
5
+ * @param {ExtensionDonateEid} eid 扩展id
6
+ * @param {number} bucks 捐赠金币数量
7
+ * @returns {Promise<Res>} 是否捐赠成功
8
+ */
9
+ export async function donateExtension(eid, bucks) {
10
+ const req = { eid, bucks };
11
+ return await ccwAxios
12
+ .post(`${url}/${eid}/donate`, req)
13
+ .then((res) => res.data.body);
14
+ }
@@ -0,0 +1,4 @@
1
+ import { donateExtension } from "./donate";
2
+ test("donate extension should fail without token", async () => {
3
+ await expect(donateExtension("spineAnimation", 1)).rejects.toThrow();
4
+ });
@@ -1,4 +1,6 @@
1
1
  import { getUserExtensions } from "./users/{oid}/extensions";
2
+ import { donateExtension } from "./extensions/{eid}/donate";
2
3
  export const bfsWeb = {
4
+ donateExtension,
3
5
  getUserExtensions,
4
6
  };
@@ -92,8 +92,10 @@ import { deleteComment } from "./study-community/comment/delete";
92
92
  import { createComment } from "./comment/create";
93
93
  import { likeComment } from "./comment/like_record/create";
94
94
  import { getStudentFollowingPage } from "./student/following/page";
95
+ import { donateTrade } from "./study-trade/trade/donate";
95
96
  export const communityWeb = {
96
97
  acceptAward,
98
+ donateTrade,
97
99
  encodeShortCode,
98
100
  createCloudVariable,
99
101
  createComment,
@@ -0,0 +1,15 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/study-trade/trade/donate";
3
+ /**
4
+ * 向作品投币
5
+ * @param {number} bucks 投币数量
6
+ * @param {MongoDBId} objectId 作品id
7
+ * @param {DonateObjectType} objectType
8
+ * @returns {Promise<Res>} 无返回值
9
+ */
10
+ export async function donateTrade(bucks, objectId, objectType = "CREATION") {
11
+ const req = { bucks, objectId, objectType };
12
+ return await ccwAxios
13
+ .post(url, req)
14
+ .then((res) => res.data.body);
15
+ }
@@ -0,0 +1,4 @@
1
+ import { donateTrade } from "./donate";
2
+ test("donate trade should fail without token", async () => {
3
+ await expect(donateTrade(1, "68ce4849811b737483bf7027", "CREATION")).rejects.toThrow();
4
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.donateExtension = donateExtension;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://bfs-web.ccw.site/extensions";
7
+ /**
8
+ * 向扩展投币
9
+ * @param {ExtensionDonateEid} eid 扩展id
10
+ * @param {number} bucks 捐赠金币数量
11
+ * @returns {Promise<Res>} 是否捐赠成功
12
+ */
13
+ async function donateExtension(eid, bucks) {
14
+ const req = { eid, bucks };
15
+ return await axios_1.ccwAxios
16
+ .post(`${exports.url}/${eid}/donate`, req)
17
+ .then((res) => res.data.body);
18
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const donate_1 = require("./donate");
4
+ test("donate extension should fail without token", async () => {
5
+ await expect((0, donate_1.donateExtension)("spineAnimation", 1)).rejects.toThrow();
6
+ });
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.bfsWeb = void 0;
4
4
  const extensions_1 = require("./users/{oid}/extensions");
5
+ const donate_1 = require("./extensions/{eid}/donate");
5
6
  exports.bfsWeb = {
7
+ donateExtension: donate_1.donateExtension,
6
8
  getUserExtensions: extensions_1.getUserExtensions,
7
9
  };
@@ -95,8 +95,10 @@ const delete_1 = require("./study-community/comment/delete");
95
95
  const create_4 = require("./comment/create");
96
96
  const create_5 = require("./comment/like_record/create");
97
97
  const page_14 = require("./student/following/page");
98
+ const donate_1 = require("./study-trade/trade/donate");
98
99
  exports.communityWeb = {
99
100
  acceptAward: award_1.acceptAward,
101
+ donateTrade: donate_1.donateTrade,
100
102
  encodeShortCode: encode_1.encodeShortCode,
101
103
  createCloudVariable: create_3.createCloudVariable,
102
104
  createComment: create_4.createComment,
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.donateTrade = donateTrade;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/study-trade/trade/donate";
7
+ /**
8
+ * 向作品投币
9
+ * @param {number} bucks 投币数量
10
+ * @param {MongoDBId} objectId 作品id
11
+ * @param {DonateObjectType} objectType
12
+ * @returns {Promise<Res>} 无返回值
13
+ */
14
+ async function donateTrade(bucks, objectId, objectType = "CREATION") {
15
+ const req = { bucks, objectId, objectType };
16
+ return await axios_1.ccwAxios
17
+ .post(exports.url, req)
18
+ .then((res) => res.data.body);
19
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const donate_1 = require("./donate");
4
+ test("donate trade should fail without token", async () => {
5
+ await expect((0, donate_1.donateTrade)(1, "68ce4849811b737483bf7027", "CREATION")).rejects.toThrow();
6
+ });
@@ -0,0 +1,13 @@
1
+ export declare const url = "https://bfs-web.ccw.site/extensions";
2
+ export type Req = {
3
+ bucks: number;
4
+ eid: string;
5
+ };
6
+ export type Res = boolean;
7
+ /**
8
+ * 向扩展投币
9
+ * @param {ExtensionDonateEid} eid 扩展id
10
+ * @param {number} bucks 捐赠金币数量
11
+ * @returns {Promise<Res>} 是否捐赠成功
12
+ */
13
+ export declare function donateExtension(eid: string, bucks: number): Promise<Res>;
@@ -1,4 +1,6 @@
1
1
  import { getUserExtensions } from "./users/{oid}/extensions";
2
+ import { donateExtension } from "./extensions/{eid}/donate";
2
3
  export declare const bfsWeb: {
4
+ donateExtension: typeof donateExtension;
3
5
  getUserExtensions: typeof getUserExtensions;
4
6
  };
@@ -92,8 +92,10 @@ import { deleteComment } from "./study-community/comment/delete";
92
92
  import { createComment } from "./comment/create";
93
93
  import { likeComment } from "./comment/like_record/create";
94
94
  import { getStudentFollowingPage } from "./student/following/page";
95
+ import { donateTrade } from "./study-trade/trade/donate";
95
96
  export declare const communityWeb: {
96
97
  acceptAward: typeof acceptAward;
98
+ donateTrade: typeof donateTrade;
97
99
  encodeShortCode: typeof encodeShortCode;
98
100
  createCloudVariable: typeof createCloudVariable;
99
101
  createComment: typeof createComment;
@@ -0,0 +1,17 @@
1
+ import { MongoDBId } from "types/api";
2
+ export declare const url = "https://community-web.ccw.site/study-trade/trade/donate";
3
+ export type DonateObjectType = "CREATION";
4
+ export type Req = {
5
+ bucks: number;
6
+ objectId: MongoDBId;
7
+ objectType: DonateObjectType;
8
+ };
9
+ export type Res = null;
10
+ /**
11
+ * 向作品投币
12
+ * @param {number} bucks 投币数量
13
+ * @param {MongoDBId} objectId 作品id
14
+ * @param {DonateObjectType} objectType
15
+ * @returns {Promise<Res>} 无返回值
16
+ */
17
+ export declare function donateTrade(bucks: number, objectId: MongoDBId, objectType?: DonateObjectType): Promise<Res>;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  };
13
13
  communityWeb: {
14
14
  acceptAward: typeof import("./community-web/task/award").acceptAward;
15
+ donateTrade: typeof import("./community-web/study-trade/trade/donate").donateTrade;
15
16
  encodeShortCode: typeof import("./community-web/api/v1/short_code/encode").encodeShortCode;
16
17
  createCloudVariable: typeof import("./community-web/study-community/cloud_variable/create").createCloudVariable;
17
18
  createComment: typeof import("./community-web/comment/create").createComment;
@@ -112,6 +113,7 @@ declare const _default: {
112
113
  getBulletinDetail: typeof import("./gandi-main/bulletins/detail").getBulletinDetail;
113
114
  };
114
115
  bfsWeb: {
116
+ donateExtension: typeof import("./bfs-web/extensions/{eid}/donate").donateExtension;
115
117
  getUserExtensions: typeof import("./bfs-web/users/{oid}/extensions").getUserExtensions;
116
118
  };
117
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccw-api/api",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "ccw api collections",
5
5
  "license": "MIT",
6
6
  "author": "Meng Fuzi",
@@ -8,10 +8,10 @@
8
8
  "type": "module",
9
9
  "main": "dist/node/index.js",
10
10
  "module": "dist/esm/index.js",
11
- "types": "dist/index.d.ts",
11
+ "types": "dist/type/index.d.ts",
12
12
  "exports": {
13
13
  ".": {
14
- "types": "./dist/index.d.ts",
14
+ "types": "./dist/type/index.d.ts",
15
15
  "import": "./dist/esm/index.js",
16
16
  "require": "./dist/node/index.js"
17
17
  }