@ningboyz/ding 1.0.14 → 1.0.15
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/package.json +14 -5
- package/.prettierignore +0 -0
- package/.prettierrc +0 -15
- package/src/axios/dingRequest.ts +0 -41
- package/src/client/dingClient.ts +0 -51
- package/src/index.ts +0 -7
- package/src/types/commonDingTalk/ICommonDingTalkScanResponse.ts +0 -24
- package/src/types/commonDingTalk/index.ts +0 -3
- package/src/types/core/IAxiosConfig.ts +0 -9
- package/src/types/core/IDingConfig.ts +0 -11
- package/src/types/core/index.ts +0 -4
- package/src/types/dedicatedDingTalk/IDedicatedDingTalkScanResponse.ts +0 -21
- package/src/types/dedicatedDingTalk/index.ts +0 -3
- package/src/types/request/IGetUserInfoByAuthCodeQuerys.ts +0 -7
- package/src/types/request/IGetUserInfoByQrCodeQuerys.ts +0 -7
- package/src/types/request/index.ts +0 -4
- package/src/types/response/IDingTalkBaseResponse.ts +0 -4
- package/src/types/response/IDingTalkUserAuthCodeResponse.ts +0 -15
- package/src/types/response/index.ts +0 -3
- package/tsconfig.json +0 -22
- package/vite.config.ts +0 -32
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ningboyz/ding",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "宁波甬政钉钉库",
|
|
6
6
|
"author": "nbyt-syq",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"keywords": [],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./es/index.d.ts",
|
|
12
|
+
"import": "./es/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./es/*": "./es/*",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"main": "es/index.js",
|
|
18
|
+
"types": "es/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"es"
|
|
21
|
+
],
|
|
13
22
|
"scripts": {
|
|
14
23
|
"build": "vite build",
|
|
15
24
|
"prettier": "prettier --config ./.prettierrc --write \"./**/*.{ts,tsx}\" "
|
package/.prettierignore
DELETED
|
File without changes
|
package/.prettierrc
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"printWidth": 200,
|
|
3
|
-
"tabWidth": 2,
|
|
4
|
-
"useTabs": false,
|
|
5
|
-
"semi": true,
|
|
6
|
-
"singleQuote": false,
|
|
7
|
-
"trailingComma": "none",
|
|
8
|
-
"bracketSpacing": true,
|
|
9
|
-
"bracketSameLine": true,
|
|
10
|
-
"arrowParens": "always",
|
|
11
|
-
"htmlWhitespaceSensitivity": "ignore",
|
|
12
|
-
"vueIndentScriptAndStyle": false,
|
|
13
|
-
"endOfLine": "auto",
|
|
14
|
-
"singleAttributePerLine": false
|
|
15
|
-
}
|
package/src/axios/dingRequest.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosInstance } from "axios";
|
|
2
|
-
import { IAxiosConfig } from "../types/core/IAxiosConfig";
|
|
3
|
-
import { IResponse } from "@ningboyz/types";
|
|
4
|
-
import { TResponse } from "@ningboyz/types/src/response/IResponse";
|
|
5
|
-
import _ from "lodash";
|
|
6
|
-
|
|
7
|
-
class DingRequest {
|
|
8
|
-
private instance: AxiosInstance;
|
|
9
|
-
private constructor(config: IAxiosConfig) {
|
|
10
|
-
this.instance = axios.create({
|
|
11
|
-
baseURL: config.baseURL,
|
|
12
|
-
timeout: config.timeout
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public static create(config: IAxiosConfig) {
|
|
17
|
-
return new DingRequest(config);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public post<T>(url: string, querys?: object, data?: object, headers?: object): Promise<IResponse<T>> {
|
|
21
|
-
return new Promise((resolve) => {
|
|
22
|
-
this.instance
|
|
23
|
-
.post<IResponse<T>>(url, data, {
|
|
24
|
-
params: querys,
|
|
25
|
-
headers: headers
|
|
26
|
-
})
|
|
27
|
-
.then((res) => {
|
|
28
|
-
resolve(res.data);
|
|
29
|
-
})
|
|
30
|
-
.catch((err) => {
|
|
31
|
-
const result = TResponse.toError(JSON.stringify(err));
|
|
32
|
-
resolve(result);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const createDingRequest = (config: IAxiosConfig) => {
|
|
39
|
-
return DingRequest.create(config);
|
|
40
|
-
};
|
|
41
|
-
export { type DingRequest, createDingRequest };
|
package/src/client/dingClient.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
2
|
-
import { DingRequest, createDingRequest } from "../axios/dingRequest";
|
|
3
|
-
import { IDingConfig } from "../types/core/IDingConfig";
|
|
4
|
-
import { IGetUserInfoByAuthCodeQuerys } from "../types/request/IGetUserInfoByAuthCodeQuerys";
|
|
5
|
-
import { IDingTalkUserAuthCodeResponse } from "../types/response/IDingTalkUserAuthCodeResponse";
|
|
6
|
-
import { IGetUserInfoByQrCodeQuerys } from "../types/request/IGetUserInfoByQrCodeQuerys";
|
|
7
|
-
|
|
8
|
-
class DingClient {
|
|
9
|
-
private prefixURL: string = "dapi";
|
|
10
|
-
private config: IDingConfig;
|
|
11
|
-
private dingRequest: DingRequest;
|
|
12
|
-
|
|
13
|
-
private constructor(config: IDingConfig) {
|
|
14
|
-
this.config = config;
|
|
15
|
-
this.dingRequest = createDingRequest({ baseURL: config.dingTalkURL, timeout: 60000 });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public static create = (config: IDingConfig) => {
|
|
19
|
-
return new DingClient(config);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
private createURL = (url: string) => {
|
|
23
|
-
return `/${this.prefixURL}${url}`;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 通过临时授权码获取用户信息
|
|
28
|
-
* @param querys
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
public getUserInfoByAuthCode(querys: IGetUserInfoByAuthCodeQuerys) {
|
|
32
|
-
const url = this.createURL("/user/get_userinfo_by_authcode");
|
|
33
|
-
return this.dingRequest.post<IDingTalkUserAuthCodeResponse[]>(url, querys, undefined, { appid: this.config.appId });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 扫码通过临时授权码获取用户信息
|
|
38
|
-
* @param querys
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
public getUserInfoByQrCode(querys: IGetUserInfoByQrCodeQuerys) {
|
|
42
|
-
const url = this.createURL("/user/get_userinfo_by_qrcode");
|
|
43
|
-
return this.dingRequest.post<IDingTalkUserAuthCodeResponse[]>(url, querys, undefined, { appid: this.config.scanAppId });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const createDingClient = (config: IDingConfig) => {
|
|
48
|
-
return DingClient.create(config);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { type DingClient, createDingClient };
|
package/src/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DingClient, createDingClient } from "./client/dingClient";
|
|
2
|
-
import * as DCore from "./types/core";
|
|
3
|
-
import * as DRequest from "./types/request";
|
|
4
|
-
import * as DResponse from "./types/response";
|
|
5
|
-
import * as DCommonDingTalk from "./types/commonDingTalk";
|
|
6
|
-
import * as DDedicatedDingTalk from "./types/dedicatedDingTalk";
|
|
7
|
-
export { type DingClient, createDingClient, DCore, DRequest, DResponse, DCommonDingTalk, DDedicatedDingTalk };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { IDingTalkBaseResponse } from "../response/IDingTalkBaseResponse";
|
|
2
|
-
import * as dd from "dingtalk-jsapi";
|
|
3
|
-
|
|
4
|
-
// 钉钉标准扫描
|
|
5
|
-
export interface ICommonDingTalkScanResponse extends IDingTalkBaseResponse {}
|
|
6
|
-
|
|
7
|
-
export class TCommonDingTalkScanResponse implements ICommonDingTalkScanResponse {
|
|
8
|
-
scan(): Promise<string> {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
dd.scan({
|
|
11
|
-
type: "qr",
|
|
12
|
-
source: "camera",
|
|
13
|
-
success: (res: any) => {
|
|
14
|
-
const { text } = res;
|
|
15
|
-
resolve(text);
|
|
16
|
-
},
|
|
17
|
-
fail: (error: any) => {
|
|
18
|
-
reject(error);
|
|
19
|
-
},
|
|
20
|
-
complete: () => {}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/types/core/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { IDingTalkBaseResponse } from "../response/IDingTalkBaseResponse";
|
|
2
|
-
import * as dd from "gdt-jsapi";
|
|
3
|
-
|
|
4
|
-
// 专有钉钉
|
|
5
|
-
export interface IDedicatedDingTalkScanResponse extends IDingTalkBaseResponse {}
|
|
6
|
-
|
|
7
|
-
export class TDedicatedDingTalkScanResponse implements IDedicatedDingTalkScanResponse {
|
|
8
|
-
scan(): Promise<string> {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
dd.scan({
|
|
11
|
-
type: "all"
|
|
12
|
-
})
|
|
13
|
-
.then((res: any) => {
|
|
14
|
-
resolve(res.text);
|
|
15
|
-
})
|
|
16
|
-
.catch((error: any) => {
|
|
17
|
-
reject(error);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { IGetUserInfoByAuthCodeQuerys, TGetUserInfoByAuthCodeQuerys } from "./IGetUserInfoByAuthCodeQuerys";
|
|
2
|
-
import { IGetUserInfoByQrCodeQuerys, TGetUserInfoByQrCodeQuerys } from "./IGetUserInfoByQrCodeQuerys";
|
|
3
|
-
|
|
4
|
-
export { type IGetUserInfoByAuthCodeQuerys, type IGetUserInfoByQrCodeQuerys, TGetUserInfoByAuthCodeQuerys, TGetUserInfoByQrCodeQuerys };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface IDingTalkUserAuthCodeResponse {
|
|
2
|
-
accountId: string;
|
|
3
|
-
userName: string;
|
|
4
|
-
employeeCode: string;
|
|
5
|
-
avatar: string;
|
|
6
|
-
encryptData: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class TDingTalkUserAuthCodeResponse implements IDingTalkUserAuthCodeResponse {
|
|
10
|
-
accountId: string = "";
|
|
11
|
-
userName: string = "";
|
|
12
|
-
employeeCode: string = "";
|
|
13
|
-
avatar: string = "";
|
|
14
|
-
encryptData: string = "";
|
|
15
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"lib": ["ES2023", "DOM"],
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
|
|
8
|
-
/* Bundler mode */
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"allowImportingTsExtensions": true,
|
|
11
|
-
"isolatedModules": true,
|
|
12
|
-
"moduleDetection": "force",
|
|
13
|
-
"noEmit": true,
|
|
14
|
-
|
|
15
|
-
/* Linting */
|
|
16
|
-
"strict": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noUnusedParameters": true,
|
|
19
|
-
"noFallthroughCasesInSwitch": true,
|
|
20
|
-
"experimentalDecorators": true
|
|
21
|
-
}
|
|
22
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
|
|
3
|
-
import tsxResolveTypes from "vite-plugin-tsx-resolve-types";
|
|
4
|
-
import dts from "vite-plugin-dts";
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [
|
|
8
|
-
tsxResolveTypes(),
|
|
9
|
-
dts({
|
|
10
|
-
entryRoot: "src",
|
|
11
|
-
outDir: ["es"],
|
|
12
|
-
exclude: ["**/tests/**"]
|
|
13
|
-
})
|
|
14
|
-
],
|
|
15
|
-
build: {
|
|
16
|
-
rollupOptions: {
|
|
17
|
-
external: ["lodash", "@ningboyz/types", "axios"],
|
|
18
|
-
output: [
|
|
19
|
-
{
|
|
20
|
-
preserveModules: true,
|
|
21
|
-
preserveModulesRoot: "src",
|
|
22
|
-
entryFileNames: "[name].js",
|
|
23
|
-
format: "esm",
|
|
24
|
-
dir: "es"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
lib: {
|
|
29
|
-
entry: "src/index.ts"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|