@ningboyz/ding 1.0.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/es/axios/dingRequest.d.ts +10 -0
- package/es/axios/dingRequest.js +31 -0
- package/es/client/dingClient.d.ts +19 -0
- package/es/client/dingClient.js +24 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +12 -0
- package/es/node_modules/.pnpm/@ningboyz_types@1.2.150/node_modules/@ningboyz/types/src/response/IResponse.js +30 -0
- package/es/types/core/IAxiosConfig.d.ts +8 -0
- package/es/types/core/IAxiosConfig.js +7 -0
- package/es/types/core/IDingConfig.d.ts +12 -0
- package/es/types/core/IDingConfig.js +9 -0
- package/es/types/core/index.d.ts +3 -0
- package/es/types/core/index.js +6 -0
- package/es/types/request/IGetUserInfoByAuthCodeQuerys.d.ts +6 -0
- package/es/types/request/IGetUserInfoByAuthCodeQuerys.js +6 -0
- package/es/types/request/index.d.ts +2 -0
- package/es/types/request/index.js +4 -0
- package/es/types/response/IDingTalkUserAuthCodeResponse.d.ts +14 -0
- package/es/types/response/IDingTalkUserAuthCodeResponse.js +10 -0
- package/es/types/response/index.d.ts +2 -0
- package/es/types/response/index.js +4 -0
- package/package.json +41 -0
- package/readme.md +43 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAxiosConfig } from '../types/core/IAxiosConfig';
|
|
2
|
+
import { IResponse } from '@ningboyz/types';
|
|
3
|
+
declare class DingRequest {
|
|
4
|
+
private instance;
|
|
5
|
+
private constructor();
|
|
6
|
+
static create(config: IAxiosConfig): DingRequest;
|
|
7
|
+
post<T>(url: string, querys?: object, data?: object, headers?: object): Promise<IResponse<T>>;
|
|
8
|
+
}
|
|
9
|
+
declare const createDingRequest: (config: IAxiosConfig) => DingRequest;
|
|
10
|
+
export { type DingRequest, createDingRequest };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import m from "axios";
|
|
2
|
+
import { TResponse as u } from "../node_modules/.pnpm/@ningboyz_types@1.2.150/node_modules/@ningboyz/types/src/response/IResponse.js";
|
|
3
|
+
class r {
|
|
4
|
+
instance;
|
|
5
|
+
constructor(t) {
|
|
6
|
+
this.instance = m.create({
|
|
7
|
+
baseURL: t.baseURL,
|
|
8
|
+
timeout: t.timeout
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
static create(t) {
|
|
12
|
+
return new r(t);
|
|
13
|
+
}
|
|
14
|
+
post(t, n, o, c) {
|
|
15
|
+
return new Promise((s) => {
|
|
16
|
+
this.instance.post(t, o, {
|
|
17
|
+
params: n,
|
|
18
|
+
headers: c
|
|
19
|
+
}).then((e) => {
|
|
20
|
+
s(e.data);
|
|
21
|
+
}).catch((e) => {
|
|
22
|
+
const i = u.toError(JSON.stringify(e));
|
|
23
|
+
s(i);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const R = (a) => r.create(a);
|
|
29
|
+
export {
|
|
30
|
+
R as createDingRequest
|
|
31
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IDingConfig } from '../types/core/IDingConfig';
|
|
2
|
+
import { IGetUserInfoByAuthCodeQuerys } from '../types/request/IGetUserInfoByAuthCodeQuerys';
|
|
3
|
+
import { IDingTalkUserAuthCodeResponse } from '../types/response/IDingTalkUserAuthCodeResponse';
|
|
4
|
+
declare class DingClient {
|
|
5
|
+
private prefixURL;
|
|
6
|
+
private config;
|
|
7
|
+
private dingRequest;
|
|
8
|
+
private constructor();
|
|
9
|
+
static create: (config: IDingConfig) => DingClient;
|
|
10
|
+
private createURL;
|
|
11
|
+
/**
|
|
12
|
+
* 扫码通过临时授权码获取用户信息
|
|
13
|
+
* @param querys
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
getUserInfoByAuthCode(querys: IGetUserInfoByAuthCodeQuerys): Promise<import('@ningboyz/types').IResponse<IDingTalkUserAuthCodeResponse>>;
|
|
17
|
+
}
|
|
18
|
+
declare const createDingClient: (config: IDingConfig) => DingClient;
|
|
19
|
+
export { type DingClient, createDingClient };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createDingRequest as s } from "../axios/dingRequest.js";
|
|
2
|
+
class t {
|
|
3
|
+
prefixURL = "dapi";
|
|
4
|
+
config;
|
|
5
|
+
dingRequest;
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.config = e, this.dingRequest = s({ baseURL: e.dingTalkURL, timeout: 6e4 });
|
|
8
|
+
}
|
|
9
|
+
static create = (e) => new t(e);
|
|
10
|
+
createURL = (e) => `/${this.prefixURL}${e}`;
|
|
11
|
+
/**
|
|
12
|
+
* 扫码通过临时授权码获取用户信息
|
|
13
|
+
* @param querys
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
getUserInfoByAuthCode(e) {
|
|
17
|
+
const i = this.createURL("/user/get_userinfo_by_authcode");
|
|
18
|
+
return this.dingRequest.post(i, e, void 0, { appid: this.config.scanAppId });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const c = (r) => t.create(r);
|
|
22
|
+
export {
|
|
23
|
+
c as createDingClient
|
|
24
|
+
};
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as DingRequest from "./axios/dingRequest";
|
|
2
|
+
import * as DingClient from "./client/dingClient";
|
|
3
|
+
import * as DCore from "./types/core";
|
|
4
|
+
import * as DRequest from "./types/request";
|
|
5
|
+
import * as DResponse from "./types/response";
|
|
6
|
+
export { DingRequest, DingClient, DCore, DRequest, DResponse };
|
package/es/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as e from "./axios/dingRequest.js";
|
|
2
|
+
import * as o from "./client/dingClient.js";
|
|
3
|
+
import * as r from "./types/core/index.js";
|
|
4
|
+
import * as s from "./types/request/index.js";
|
|
5
|
+
import * as t from "./types/response/index.js";
|
|
6
|
+
export {
|
|
7
|
+
r as DCore,
|
|
8
|
+
s as DRequest,
|
|
9
|
+
t as DResponse,
|
|
10
|
+
o as DingClient,
|
|
11
|
+
e as DingRequest
|
|
12
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import r from "lodash";
|
|
2
|
+
const T = class T {
|
|
3
|
+
};
|
|
4
|
+
T.toError = (A) => ({
|
|
5
|
+
DATASIZE: 0,
|
|
6
|
+
ERORCODE: -1,
|
|
7
|
+
ERORMEMO: A,
|
|
8
|
+
LISTDATA: [],
|
|
9
|
+
ONSTATUS: !1,
|
|
10
|
+
DATATIME: (/* @__PURE__ */ new Date()).getTime(),
|
|
11
|
+
DATADATE: 0,
|
|
12
|
+
REALPAGE: 0,
|
|
13
|
+
PAGESIZE: 0,
|
|
14
|
+
TOTALCNT: 0
|
|
15
|
+
}), T.toTrue = (A, E) => ({
|
|
16
|
+
DATASIZE: r.isArray(A) ? A.length : 0,
|
|
17
|
+
ERORCODE: 0,
|
|
18
|
+
ERORMEMO: E,
|
|
19
|
+
LISTDATA: A,
|
|
20
|
+
ONSTATUS: !0,
|
|
21
|
+
DATATIME: (/* @__PURE__ */ new Date()).getTime(),
|
|
22
|
+
DATADATE: 0,
|
|
23
|
+
REALPAGE: 0,
|
|
24
|
+
PAGESIZE: 0,
|
|
25
|
+
TOTALCNT: 0
|
|
26
|
+
});
|
|
27
|
+
let t = T;
|
|
28
|
+
export {
|
|
29
|
+
t as TResponse
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IDingConfig {
|
|
2
|
+
appId: string;
|
|
3
|
+
scanAppId: string;
|
|
4
|
+
dingTalkURL: string;
|
|
5
|
+
domain: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class TDingConfig implements IDingConfig {
|
|
8
|
+
appId: string;
|
|
9
|
+
scanAppId: string;
|
|
10
|
+
dingTalkURL: string;
|
|
11
|
+
domain: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IDingTalkUserAuthCodeResponse {
|
|
2
|
+
accountId: string;
|
|
3
|
+
userName: string;
|
|
4
|
+
employeeCode: string;
|
|
5
|
+
avatar: string;
|
|
6
|
+
encryptData: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class TDingTalkUserAuthCodeResponse implements IDingTalkUserAuthCodeResponse {
|
|
9
|
+
accountId: string;
|
|
10
|
+
userName: string;
|
|
11
|
+
employeeCode: string;
|
|
12
|
+
avatar: string;
|
|
13
|
+
encryptData: string;
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ningboyz/ding",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "宁波甬政钉钉库",
|
|
6
|
+
"author": "nbyt-syq",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"keywords": [],
|
|
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
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "vite build",
|
|
24
|
+
"prettier": "prettier --config ./.prettierrc --write \"./**/*.{ts,tsx}\" "
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@ningboyz/types": "^1.2.150",
|
|
32
|
+
"axios": "^1.12.2",
|
|
33
|
+
"lodash": "4.17.21"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/lodash": "4.17.20",
|
|
37
|
+
"vite": "7.1.3",
|
|
38
|
+
"vite-plugin-dts": "4.5.4",
|
|
39
|
+
"vite-plugin-tsx-resolve-types": "0.0.4"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ningboyz/utils",
|
|
3
|
+
"version": "1.2.30",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "宁波甬政工具库",
|
|
6
|
+
"author": "nbyt-syq",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./es/index.d.ts",
|
|
12
|
+
"import": "./es/index.js",
|
|
13
|
+
"require": "./lib/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./es/*": "./es/*",
|
|
16
|
+
"./lib/*": "./lib/*",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"main": "es/index.js",
|
|
20
|
+
"types": "es/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"es",
|
|
23
|
+
"lib"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "vite build",
|
|
27
|
+
"prettier": "prettier --config ./.prettierrc --write \"./**/*.{ts,tsx}\" "
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@ningboyz/types": "1.2.28",
|
|
35
|
+
"lodash": "4.17.21"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/lodash": "4.17.20",
|
|
39
|
+
"vite": "^7.1.3",
|
|
40
|
+
"vite-plugin-dts": "^4.5.4",
|
|
41
|
+
"vite-plugin-tsx-resolve-types": "^0.0.4"
|
|
42
|
+
}
|
|
43
|
+
}
|