@ningboyz/ding
Advanced tools
Sorry, the diff of this file is not supported yet
+15
| { | ||
| "printWidth": 200, | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "semi": true, | ||
| "singleQuote": false, | ||
| "trailingComma": "none", | ||
| "bracketSpacing": true, | ||
| "bracketSameLine": true, | ||
| "arrowParens": "always", | ||
| "htmlWhitespaceSensitivity": "ignore", | ||
| "vueIndentScriptAndStyle": false, | ||
| "endOfLine": "auto", | ||
| "singleAttributePerLine": false | ||
| } |
| import axios, { AxiosInstance } from "axios"; | ||
| import { IAxiosConfig } from "../types/core/IAxiosConfig"; | ||
| import { IResponse } from "@ningboyz/types"; | ||
| import { TResponse } from "@ningboyz/types/src/response/IResponse"; | ||
| import _ from "lodash"; | ||
| class DingRequest { | ||
| private instance: AxiosInstance; | ||
| private constructor(config: IAxiosConfig) { | ||
| this.instance = axios.create({ | ||
| baseURL: config.baseURL, | ||
| timeout: config.timeout | ||
| }); | ||
| } | ||
| public static create(config: IAxiosConfig) { | ||
| return new DingRequest(config); | ||
| } | ||
| public post<T>(url: string, querys?: object, data?: object, headers?: object): Promise<IResponse<T>> { | ||
| return new Promise((resolve) => { | ||
| this.instance | ||
| .post<IResponse<T>>(url, data, { | ||
| params: querys, | ||
| headers: headers | ||
| }) | ||
| .then((res) => { | ||
| resolve(res.data); | ||
| }) | ||
| .catch((err) => { | ||
| const result = TResponse.toError(JSON.stringify(err)); | ||
| resolve(result); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
| const createDingRequest = (config: IAxiosConfig) => { | ||
| return DingRequest.create(config); | ||
| }; | ||
| export { type DingRequest, createDingRequest }; |
| import _ from "lodash"; | ||
| import { DingRequest, createDingRequest } from "../axios/dingRequest"; | ||
| import { IDingConfig } from "../types/core/IDingConfig"; | ||
| import { IGetUserInfoByAuthCodeQuerys } from "../types/request/IGetUserInfoByAuthCodeQuerys"; | ||
| import { IDingTalkUserAuthCodeResponse } from "../types/response/IDingTalkUserAuthCodeResponse"; | ||
| import { IGetUserInfoByQrCodeQuerys } from "../types/request/IGetUserInfoByQrCodeQuerys"; | ||
| class DingClient { | ||
| private prefixURL: string = "dapi"; | ||
| private config: IDingConfig; | ||
| private dingRequest: DingRequest; | ||
| private constructor(config: IDingConfig) { | ||
| this.config = config; | ||
| this.dingRequest = createDingRequest({ baseURL: config.dingTalkURL, timeout: 60000 }); | ||
| } | ||
| public static create = (config: IDingConfig) => { | ||
| return new DingClient(config); | ||
| }; | ||
| private createURL = (url: string) => { | ||
| return `/${this.prefixURL}${url}`; | ||
| }; | ||
| /** | ||
| * 通过临时授权码获取用户信息 | ||
| * @param querys | ||
| * @returns | ||
| */ | ||
| public getUserInfoByAuthCode(querys: IGetUserInfoByAuthCodeQuerys) { | ||
| const url = this.createURL("/user/get_userinfo_by_authcode"); | ||
| return this.dingRequest.post<IDingTalkUserAuthCodeResponse[]>(url, querys, undefined, { appid: this.config.appId }); | ||
| } | ||
| /** | ||
| * 扫码通过临时授权码获取用户信息 | ||
| * @param querys | ||
| * @returns | ||
| */ | ||
| public getUserInfoByQrCode(querys: IGetUserInfoByQrCodeQuerys) { | ||
| const url = this.createURL("/user/get_userinfo_by_qrcode"); | ||
| return this.dingRequest.post<IDingTalkUserAuthCodeResponse[]>(url, querys, undefined, { appid: this.config.scanAppId }); | ||
| } | ||
| } | ||
| const createDingClient = (config: IDingConfig) => { | ||
| return DingClient.create(config); | ||
| }; | ||
| export { type DingClient, createDingClient }; |
| import { DingClient, createDingClient } from "./client/dingClient"; | ||
| import * as DCore from "./types/core"; | ||
| import * as DRequest from "./types/request"; | ||
| import * as DResponse from "./types/response"; | ||
| import * as DCommonDingTalk from "./types/commonDingTalk"; | ||
| import * as DDedicatedDingTalk from "./types/dedicatedDingTalk"; | ||
| export { type DingClient, createDingClient, DCore, DRequest, DResponse, DCommonDingTalk, DDedicatedDingTalk }; |
| import { IDingTalkBaseResponse } from "../response/IDingTalkBaseResponse"; | ||
| import * as dd from "dingtalk-jsapi"; | ||
| // 钉钉标准扫描 | ||
| export interface ICommonDingTalkScanResponse extends IDingTalkBaseResponse {} | ||
| export class TCommonDingTalkScanResponse implements ICommonDingTalkScanResponse { | ||
| scan(): Promise<string> { | ||
| return new Promise((resolve, reject) => { | ||
| dd.scan({ | ||
| success: (res: any) => { | ||
| const { text } = res; | ||
| resolve(text); | ||
| }, | ||
| fail: (error: any) => { | ||
| reject(error); | ||
| }, | ||
| complete: () => {} | ||
| }); | ||
| }); | ||
| } | ||
| } |
| import { ICommonDingTalkScanResponse, TCommonDingTalkScanResponse } from "./ICommonDingTalkScanResponse"; | ||
| export { type ICommonDingTalkScanResponse, TCommonDingTalkScanResponse }; |
| export interface IAxiosConfig { | ||
| baseURL: string; | ||
| timeout: number; | ||
| } | ||
| export class TAxiosConfig implements IAxiosConfig { | ||
| baseURL: string = ""; | ||
| timeout: number = 60000; | ||
| } |
| export interface IDingConfig { | ||
| appId: string; | ||
| scanAppId: string; | ||
| dingTalkURL: string; | ||
| } | ||
| export class TDingConfig implements IDingConfig { | ||
| appId: string = ""; | ||
| scanAppId: string = ""; | ||
| dingTalkURL: string = ""; | ||
| } |
| import { IAxiosConfig, TAxiosConfig } from "./IAxiosConfig"; | ||
| import { IDingConfig, TDingConfig } from "./IDingConfig"; | ||
| export { type IAxiosConfig, type IDingConfig, TAxiosConfig, TDingConfig }; |
| import { IDingTalkBaseResponse } from "../response/IDingTalkBaseResponse"; | ||
| import dd from "gdt-jsapi"; | ||
| // 专有钉钉 | ||
| export interface IDedicatedDingTalkScanResponse extends IDingTalkBaseResponse {} | ||
| export class TDedicatedDingTalkScanResponse implements IDedicatedDingTalkScanResponse { | ||
| scan(): Promise<string> { | ||
| return new Promise((resolve, reject) => { | ||
| dd.scan({ | ||
| type: "all" | ||
| }) | ||
| .then((res: any) => { | ||
| resolve(res.text); | ||
| }) | ||
| .catch((error: any) => { | ||
| reject(error); | ||
| }); | ||
| }); | ||
| } | ||
| } |
| import { IDedicatedDingTalkScanResponse, TDedicatedDingTalkScanResponse } from "./IDedicatedDingTalkScanResponse"; | ||
| export { type IDedicatedDingTalkScanResponse, TDedicatedDingTalkScanResponse }; |
| export interface IGetUserInfoByAuthCodeQuerys { | ||
| authcode: string; | ||
| } | ||
| export class TGetUserInfoByAuthCodeQuerys implements IGetUserInfoByAuthCodeQuerys { | ||
| authcode: string = ""; | ||
| } |
| export interface IGetUserInfoByQrCodeQuerys { | ||
| authcode: string; | ||
| } | ||
| export class TGetUserInfoByQrCodeQuerys implements IGetUserInfoByQrCodeQuerys { | ||
| authcode: string = ""; | ||
| } |
| import { IGetUserInfoByAuthCodeQuerys, TGetUserInfoByAuthCodeQuerys } from "./IGetUserInfoByAuthCodeQuerys"; | ||
| import { IGetUserInfoByQrCodeQuerys, TGetUserInfoByQrCodeQuerys } from "./IGetUserInfoByQrCodeQuerys"; | ||
| export { type IGetUserInfoByAuthCodeQuerys, type IGetUserInfoByQrCodeQuerys, TGetUserInfoByAuthCodeQuerys, TGetUserInfoByQrCodeQuerys }; |
| // 规范钉钉和专有钉钉的基本类 | ||
| export interface IDingTalkBaseResponse { | ||
| scan(): Promise<string>; | ||
| } |
| export interface IDingTalkUserAuthCodeResponse { | ||
| accountId: string; | ||
| userName: string; | ||
| employeeCode: string; | ||
| avatar: string; | ||
| encryptData: string; | ||
| } | ||
| export class TDingTalkUserAuthCodeResponse implements IDingTalkUserAuthCodeResponse { | ||
| accountId: string = ""; | ||
| userName: string = ""; | ||
| employeeCode: string = ""; | ||
| avatar: string = ""; | ||
| encryptData: string = ""; | ||
| } |
| import { IDingTalkUserAuthCodeResponse, TDingTalkUserAuthCodeResponse } from "./IDingTalkUserAuthCodeResponse"; | ||
| export { type IDingTalkUserAuthCodeResponse, TDingTalkUserAuthCodeResponse }; |
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "lib": ["ES2023", "DOM"], | ||
| "module": "ESNext", | ||
| "skipLibCheck": true, | ||
| /* Bundler mode */ | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true, | ||
| "isolatedModules": true, | ||
| "moduleDetection": "force", | ||
| "noEmit": true, | ||
| /* Linting */ | ||
| "strict": true, | ||
| "noUnusedLocals": true, | ||
| "noUnusedParameters": true, | ||
| "noFallthroughCasesInSwitch": true, | ||
| "experimentalDecorators": true | ||
| } | ||
| } |
| import { defineConfig } from "vite"; | ||
| import tsxResolveTypes from "vite-plugin-tsx-resolve-types"; | ||
| import dts from "vite-plugin-dts"; | ||
| export default defineConfig({ | ||
| plugins: [ | ||
| tsxResolveTypes(), | ||
| dts({ | ||
| entryRoot: "src", | ||
| outDir: ["es"], | ||
| exclude: ["**/tests/**"] | ||
| }) | ||
| ], | ||
| build: { | ||
| rollupOptions: { | ||
| external: ["lodash", "@ningboyz/types", "axios"], | ||
| output: [ | ||
| { | ||
| preserveModules: true, | ||
| preserveModulesRoot: "src", | ||
| entryFileNames: "[name].js", | ||
| format: "esm", | ||
| dir: "es" | ||
| } | ||
| ] | ||
| }, | ||
| lib: { | ||
| entry: "src/index.ts" | ||
| } | ||
| } | ||
| }); |
+2
-14
| { | ||
| "name": "@ningboyz/ding", | ||
| "version": "1.0.15", | ||
| "version": "1.0.16", | ||
| "private": false, | ||
@@ -9,15 +9,3 @@ "description": "宁波甬政钉钉库", | ||
| "keywords": [], | ||
| "exports": { | ||
| ".": { | ||
| "types": "./es/index.d.ts", | ||
| "import": "./es/index.js" | ||
| }, | ||
| "./es/*": "./es/*", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "main": "es/index.js", | ||
| "types": "es/index.d.ts", | ||
| "files": [ | ||
| "es" | ||
| ], | ||
| "main": "src/index.ts", | ||
| "scripts": { | ||
@@ -24,0 +12,0 @@ "build": "vite build", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10367
429.47%22
1000%236
Infinity%1
-50%