baja-lite 1.1.2 → 1.1.4

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.
Files changed (77) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc.cjs +89 -0
  3. package/.prettierrc +4 -0
  4. package/ci.js +29 -0
  5. package/package-cjs.json +17 -0
  6. package/package.json +7 -7
  7. package/{boot-remote.js → src/boot-remote.ts} +7 -6
  8. package/{boot.js → src/boot.ts} +39 -32
  9. package/{code.js → src/code.ts} +67 -64
  10. package/{convert-xml.js → src/convert-xml.ts} +155 -105
  11. package/src/enum.ts +71 -0
  12. package/src/error.ts +11 -0
  13. package/src/fn.ts +295 -0
  14. package/{index.d.ts → src/index.ts} +11 -11
  15. package/{list.js → src/list.ts} +9 -8
  16. package/src/math.ts +405 -0
  17. package/src/object.ts +247 -0
  18. package/src/set-ex.ts +374 -0
  19. package/src/sql.ts +5281 -0
  20. package/{sqlite.js → src/sqlite.ts} +52 -53
  21. package/src/string.ts +111 -0
  22. package/{test-mysql.js → src/test-mysql.ts} +126 -135
  23. package/src/test-postgresql.ts +79 -0
  24. package/{test-sqlite.js → src/test-sqlite.ts} +80 -89
  25. package/{test-xml.js → src/test-xml.ts} +1 -1
  26. package/src/test.ts +2 -0
  27. package/src/wx/base.ts +76 -0
  28. package/src/wx/mini.ts +133 -0
  29. package/src/wx/organ.ts +290 -0
  30. package/{wx/types.d.ts → src/wx/types.ts} +10 -21
  31. package/src/wx.ts +3 -0
  32. package/test.json +0 -0
  33. package/tsconfig.base.json +80 -0
  34. package/tsconfig.cjs.json +42 -0
  35. package/tsconfig.json +44 -0
  36. package/xml/event-report.xml +13 -0
  37. package/yarn.lock +1493 -0
  38. package/boot-remote.d.ts +0 -2
  39. package/boot.d.ts +0 -2
  40. package/code.d.ts +0 -2
  41. package/convert-xml.d.ts +0 -10
  42. package/enum.d.ts +0 -18
  43. package/enum.js +0 -59
  44. package/error.d.ts +0 -5
  45. package/error.js +0 -13
  46. package/fn.d.ts +0 -128
  47. package/fn.js +0 -172
  48. package/index.js +0 -11
  49. package/list.d.ts +0 -10
  50. package/math.d.ts +0 -83
  51. package/math.js +0 -451
  52. package/object.d.ts +0 -83
  53. package/object.js +0 -222
  54. package/set-ex.d.ts +0 -198
  55. package/set-ex.js +0 -338
  56. package/sql.d.ts +0 -1858
  57. package/sql.js +0 -5025
  58. package/sqlite.d.ts +0 -32
  59. package/string.d.ts +0 -17
  60. package/string.js +0 -105
  61. package/test-mysql.d.ts +0 -2
  62. package/test-postgresql.d.ts +0 -2
  63. package/test-postgresql.js +0 -90
  64. package/test-sqlite.d.ts +0 -1
  65. package/test-xml.d.ts +0 -1
  66. package/test.d.ts +0 -1
  67. package/test.js +0 -2
  68. package/wx/base.d.ts +0 -11
  69. package/wx/base.js +0 -78
  70. package/wx/index.d.ts +0 -3
  71. package/wx/index.js +0 -3
  72. package/wx/mini.d.ts +0 -45
  73. package/wx/mini.js +0 -102
  74. package/wx/organ.d.ts +0 -65
  75. package/wx/organ.js +0 -171
  76. package/wx/types.js +0 -1
  77. /package/{README.md → Readme.md} +0 -0
package/sqlite.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import { SqliteRemoteInterface } from './sql.js';
2
- export declare abstract class SqliteRemoteClass implements SqliteRemoteInterface {
3
- private dbList;
4
- /** 原始存放路径 */
5
- abstract getStoreName(dbName: string): string;
6
- /** 导入时,备份源文件路径 */
7
- abstract getBackName(dbName: string): string;
8
- abstract BetterSqlite3: any;
9
- /** 实现复制 */
10
- abstract cpSync(from: string, to: string, option?: {
11
- force: true;
12
- }): void;
13
- /**
14
- * 设置可执行权限
15
- ```
16
- const fd = openSync(dbPath, 1);
17
- fchmodSync(fd, 777);
18
- closeSync(fd);
19
- ```
20
- */
21
- abstract setMod(name: string): void;
22
- abstract trace: boolean;
23
- execute(inData: Uint8Array): Promise<Uint8Array>;
24
- pluck(inData: Uint8Array): Promise<Uint8Array>;
25
- get(inData: Uint8Array): Promise<Uint8Array>;
26
- raw(inData: Uint8Array): Promise<Uint8Array>;
27
- query(inData: Uint8Array): Promise<Uint8Array>;
28
- initDB(dbName: string): void;
29
- export(dbName: string, exportPath: string): Promise<void>;
30
- restore(dbName: string, importPath: string): void;
31
- close(dbName?: string): void;
32
- }
package/string.d.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * 通过uri获取key
3
- * @param uri
4
- */
5
- export declare const getPicKey: (uri: string) => string;
6
- export declare const emptyString: (source: any, skipEmptyString?: boolean) => boolean;
7
- export declare const notEmptyString: (source: any, skipEmptyString?: boolean) => boolean;
8
- export declare const safeString: (source?: string) => string;
9
- export declare const trimObject: <T>(data: any) => T;
10
- export declare const randomNumber: (len: number) => string;
11
- export declare const randomString: (len: number) => string;
12
- export declare const randomString2: (len: number) => string;
13
- export declare const randomString3: (len: number) => string;
14
- export declare const buildWxStr: (data: {
15
- [key: string]: string;
16
- }, maxLabelLength: number, ...titles: string[]) => string;
17
- export declare const replaceChineseCode: (str: string) => string;
package/string.js DELETED
@@ -1,105 +0,0 @@
1
- /**
2
- * 通过uri获取key
3
- * @param uri
4
- */
5
- export const getPicKey = (uri) => {
6
- const arr = /key=([0-9a-zA-Z.]+)/.exec(uri);
7
- if (arr && arr.length === 2) {
8
- return arr[1];
9
- }
10
- return uri;
11
- };
12
- export const emptyString = (source, skipEmptyString = true) => {
13
- return (source === null ||
14
- source === undefined ||
15
- (skipEmptyString === true && (source === '' || `${source}`.replace(/\s/g, '') === '')));
16
- };
17
- export const notEmptyString = (source, skipEmptyString = true) => {
18
- return emptyString(source, skipEmptyString) === false;
19
- };
20
- export const safeString = (source) => {
21
- if (source) {
22
- return `${source}`.replace(/'/g, '');
23
- }
24
- return '';
25
- };
26
- export const trimObject = (data) => {
27
- if (data) {
28
- for (const k in data) {
29
- if (typeof data[k] === 'string') {
30
- data[k] = data[k].trim();
31
- }
32
- }
33
- }
34
- return data;
35
- };
36
- export const randomNumber = (len) => {
37
- return `${parseInt(`${(Math.random() * 9 + 1) * Math.pow(10, (len - 1))}`, 10)}`;
38
- };
39
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
40
- const charLen = chars.length;
41
- export const randomString = (len) => {
42
- return Array.from(new Array(len)).map(() => chars.charAt(Math.floor(Math.random() * charLen))).join('');
43
- };
44
- const chars2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
45
- const charLen2 = chars2.length;
46
- export const randomString2 = (len) => {
47
- return Array.from(new Array(len)).map(() => chars2.charAt(Math.floor(Math.random() * charLen2))).join('');
48
- };
49
- const chars3 = 'abcdefghijklmnopqrstuvwxyz0123456789';
50
- const charLen3 = chars3.length;
51
- export const randomString3 = (len) => {
52
- return Array.from(new Array(len)).map(() => chars3.charAt(Math.floor(Math.random() * charLen3))).join('');
53
- };
54
- export const buildWxStr = (data, maxLabelLength, ...titles) => {
55
- let str = titles.join('\r\n');
56
- str += '\r\n\r\n';
57
- const items = new Array();
58
- // const maxLength = maxLabelLength * 2;
59
- for (const [key, value] of Object.entries(data)) {
60
- if (notEmptyString(value)) {
61
- const len = maxLabelLength - key.length;
62
- items.push(`${key}:${''.padEnd(len * 3 + (len > 0 ? 1 : 0), ' ')}${value}`);
63
- }
64
- }
65
- str += items.join('\r\n');
66
- return str;
67
- };
68
- const chinese = /[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/g;
69
- const table = {
70
- '!': '!',
71
- '¥': '$',
72
- '…': '.',
73
- '(': '(',
74
- ')': ')',
75
- '《': '<',
76
- '》': '>',
77
- '?': '?',
78
- ':': ':',
79
- '“': `'`,
80
- '”': `'`,
81
- '’': `'`,
82
- '‘': `'`,
83
- ',': ',',
84
- '。': '.',
85
- '、': '/',
86
- ';': ';',
87
- '〈': '<',
88
- '〉': '>',
89
- '【': '[',
90
- '】': ']',
91
- '『': '[',
92
- '』': ']',
93
- '「': '[',
94
- '」': ']',
95
- '﹃': '[',
96
- '﹄': ']',
97
- '〔': '(',
98
- '〕': ')',
99
- '—': '-',
100
- '~': '~',
101
- '﹏': '~'
102
- };
103
- export const replaceChineseCode = (str) => {
104
- return str.replace(chinese, (a) => table[a] || '');
105
- };
package/test-mysql.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import 'reflect-metadata';
2
- export declare function go2(): Promise<void>;
@@ -1,2 +0,0 @@
1
- import 'reflect-metadata';
2
- export declare function go2(): Promise<void>;
@@ -1,90 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import 'reflect-metadata';
11
- import { Boot } from './boot.js';
12
- import { SqlService, Field, DB, DBType, SqlType, ColumnMode, SelectResult, } from './sql.js';
13
- class AmaFuck2 {
14
- }
15
- __decorate([
16
- Field({ type: SqlType.int, length: 200, id: true, uuid: true }),
17
- __metadata("design:type", Number)
18
- ], AmaFuck2.prototype, "userid", void 0);
19
- __decorate([
20
- Field({ type: SqlType.varchar, length: 200, def: '333' }),
21
- __metadata("design:type", String)
22
- ], AmaFuck2.prototype, "username", void 0);
23
- __decorate([
24
- Field({ type: SqlType.varchar, length: 200 }),
25
- __metadata("design:type", String)
26
- ], AmaFuck2.prototype, "pwd", void 0);
27
- let AmaService2 = class AmaService2 extends SqlService {
28
- };
29
- AmaService2 = __decorate([
30
- DB({
31
- tableName: 'nfc_user', clz: AmaFuck2, dbType: DBType.Postgresql
32
- })
33
- ], AmaService2);
34
- // interface Menu {
35
- // resourceid: string;
36
- // resourcepid: string;
37
- // resourcename: string;
38
- // children: Menu[];
39
- // }
40
- export async function go2() {
41
- await Boot({
42
- Postgresql: {
43
- database: 'nfc',
44
- user: 'postgres',
45
- password: 'abcd1234',
46
- port: 5432,
47
- host: '127.0.0.1'
48
- },
49
- log: 'info',
50
- columnMode: ColumnMode.HUMP,
51
- sqlDir: 'E:/pro/baja-lite/xml',
52
- sqlMap: {
53
- ['test.test']: `SELECT * FROM nfc_user {{#username}} WHERE username = :username {{/username}}`
54
- }
55
- });
56
- const service = new AmaService2();
57
- await service.transaction({
58
- fn: async (conn) => {
59
- const rt5 = await service.select({
60
- sqlId: 'test.test',
61
- params: { username: '1111' },
62
- selectResult: SelectResult.RS_CS,
63
- conn
64
- });
65
- console.log(55, rt5.length);
66
- await service.insert({
67
- data: {
68
- userid: 22,
69
- username: '222',
70
- pwd: '333'
71
- }
72
- });
73
- return 1;
74
- }
75
- });
76
- // const data = await service.select<Menu>({
77
- // sql: 'SELECT resourceid, resourcepid,resourcename FROM cp_resource ',
78
- // params: {
79
- // site: '1234',
80
- // matchInfo: { reportType: 'yyyy', id: '11' }
81
- // },
82
- // // mapper: [
83
- // // ['site', ['info', 'bSist'], 989],
84
- // // ['site', ['info2', 'bSist'], 33],
85
- // // ['site', ['Bsite'], 0]
86
- // // ]
87
- // });
88
- // console.log(data);
89
- }
90
- go2();
package/test-sqlite.d.ts DELETED
@@ -1 +0,0 @@
1
- import 'reflect-metadata';
package/test-xml.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/test.js DELETED
@@ -1,2 +0,0 @@
1
- import { format } from 'mysql2';
2
- console.log(format('select 1 from a where ?', [['1', '2', '3']]));
package/wx/base.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export declare abstract class BaseWx {
2
- protected authErrorCodes: number[];
3
- protected name: string;
4
- protected tokenUrl: string;
5
- private tokenData;
6
- protected mock: boolean;
7
- protected getToken(force?: boolean): Promise<string>;
8
- protected fetch(uri: (token: string) => string, method: 'get' | 'post', data: {
9
- [key: string]: any;
10
- }, needToken?: boolean, buffer?: boolean): Promise<any>;
11
- }
package/wx/base.js DELETED
@@ -1,78 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- import * as rp from 'request-promise';
3
- import { Throw } from '../error.js';
4
- import pino from 'pino';
5
- const logger = process.env['NODE_ENV'] !== 'production' ? pino({
6
- name: 'wx',
7
- transport: {
8
- target: 'pino-pretty'
9
- }
10
- }) : pino({ name: 'wx' });
11
- export class BaseWx {
12
- constructor() {
13
- this.authErrorCodes = [40001, 40014, 41001, 42001];
14
- this.name = '';
15
- this.tokenUrl = '';
16
- this.tokenData = '';
17
- this.mock = false;
18
- }
19
- async getToken(force) {
20
- let token = '';
21
- const now = +new Date();
22
- let need = force === true;
23
- if (this.tokenData) {
24
- const datas = this.tokenData.split('^_^');
25
- token = datas[0];
26
- const lastTime = datas[1];
27
- const spliceTime = datas[2];
28
- if (now - parseInt(lastTime, 10) - parseInt(spliceTime, 10) > 0) {
29
- need = true;
30
- }
31
- }
32
- else {
33
- need = true;
34
- }
35
- if (need === true) {
36
- const data = await this.fetch(() => this.tokenUrl, 'get', {}, false);
37
- token = data.access_token;
38
- this.tokenData = `${token}^_^${now}^_^${data.expires_in * 1000}`;
39
- }
40
- return token;
41
- }
42
- async fetch(uri, method, data, needToken = true, buffer = false) {
43
- if (this.mock === true) {
44
- return {};
45
- }
46
- let token = needToken ? await this.getToken() : '';
47
- if (!needToken || token) {
48
- const start = +new Date();
49
- let url = uri(token);
50
- const param = method === 'get' ? {
51
- method,
52
- json: buffer ? false : true,
53
- qs: data,
54
- encoding: buffer ? null : undefined
55
- } : {
56
- json: data,
57
- method,
58
- encoding: buffer ? null : undefined
59
- };
60
- let response = await rp.default({
61
- uri: url,
62
- ...param
63
- });
64
- if (this.authErrorCodes.includes(response.errcode)) {
65
- token = await this.getToken(true);
66
- url = uri(token);
67
- response = await rp.default({
68
- uri: url,
69
- ...param
70
- });
71
- Throw.if(response.errcode && response.errcode - 0 !== 0, `${url}-${response.errcode}-${response.errmsg}`);
72
- }
73
- Throw.if(response.errcode && response.errcode - 0 !== 0, `${url}-${response.errcode}-${response.errmsg}`);
74
- logger.info(`fetch data ${+new Date() - start} ms`);
75
- return response;
76
- }
77
- }
78
- }
package/wx/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './mini.js';
2
- export * from './organ.js';
3
- export * from './types.js';
package/wx/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './mini.js';
2
- export * from './organ.js';
3
- export * from './types.js';
package/wx/mini.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import { BaseWx } from './base';
2
- import { WxMiniConfig, WxLiveInfo, WxLiveReplay } from './types.js';
3
- export declare class WxMini extends BaseWx {
4
- protected name: string;
5
- private config;
6
- private templNameCache;
7
- private templKeyCache;
8
- constructor(config: WxMiniConfig);
9
- getUnlimited({ scene, model, page, fullpath, png, width, lineColor }: {
10
- scene: string;
11
- model?: string;
12
- page?: string;
13
- fullpath?: string;
14
- png?: '0' | '1' | 0 | 1 | true | false | 'true' | 'false';
15
- width?: number;
16
- lineColor?: {
17
- r: number;
18
- g: number;
19
- b: number;
20
- };
21
- }): Promise<any>;
22
- sendMs({ openids, name, data, scene }: {
23
- openids: string[];
24
- name: string;
25
- data: {
26
- [key: string]: string | number;
27
- };
28
- scene: string;
29
- }): Promise<void>;
30
- code2session(code: string): Promise<{
31
- openid: string;
32
- session_key: string;
33
- unionid?: string;
34
- }>;
35
- getTemplIds(): {
36
- [key: string]: string[];
37
- };
38
- decrypt<T>({ sessionKey, encryptedData, iv }: {
39
- iv: string;
40
- sessionKey: string;
41
- encryptedData: string;
42
- }): T | undefined;
43
- getLiveInfo(start: number, limit: number): Promise<WxLiveInfo[]>;
44
- getLiveReplay(room_id: number, start: number, limit: number): Promise<WxLiveReplay[]>;
45
- }
package/wx/mini.js DELETED
@@ -1,102 +0,0 @@
1
- import { BaseWx } from './base';
2
- import crypto from 'crypto';
3
- import { Throw } from '../error.js';
4
- export class WxMini extends BaseWx {
5
- constructor(config) {
6
- super();
7
- this.name = 'wxMini';
8
- this.config = config;
9
- this.tokenUrl = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${this.config.appId}&secret=${this.config.appSecret}`;
10
- this.templNameCache = {};
11
- this.templKeyCache = {};
12
- if (this.config.messages) {
13
- for (const item of this.config.messages) {
14
- if (!this.templNameCache[item.name]) {
15
- this.templNameCache[item.name] = [];
16
- }
17
- this.templNameCache[item.name].push({
18
- tmplId: item.tmplId,
19
- page: `pages/${item.model}/${item.page}/${item.page}`
20
- });
21
- for (const key of item.keys) {
22
- if (!this.templKeyCache[key]) {
23
- this.templKeyCache[key] = [];
24
- }
25
- this.templKeyCache[key].push(item.tmplId);
26
- }
27
- }
28
- }
29
- }
30
- async getUnlimited({ scene, model, page, fullpath, png, width, lineColor }) {
31
- Throw.if(!fullpath && (!model || !page), '路径不完整,fullpath或者model+page必须传一个');
32
- const pageto = fullpath ?? `pages/${model}/${page}/${page}`;
33
- return await this.fetch((token) => `https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${token}`, 'post', {
34
- scene,
35
- page: pageto,
36
- line_color: lineColor ?? this.config.qrcode?.lineColor,
37
- is_hyaline: png === 'true' || png === '1' || png === true || png === 1,
38
- width: width ?? this.config.qrcode?.width ?? 500
39
- }, true, true);
40
- }
41
- async sendMs({ openids, name, data, scene }) {
42
- const temps = this.templNameCache[name];
43
- const dataSend = {};
44
- for (const [key, value] of Object.entries(data)) {
45
- dataSend[key] = { value: value ?? '' };
46
- }
47
- if (scene) {
48
- scene = `?${scene}`;
49
- }
50
- else {
51
- scene = '';
52
- }
53
- for (const temp of temps) {
54
- for (const touser of openids) {
55
- await this.fetch((token) => `https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=${token}`, 'post', {
56
- touser,
57
- data: dataSend,
58
- template_id: temp.tmplId,
59
- page: `${temp.page}${scene}`
60
- });
61
- }
62
- }
63
- }
64
- async code2session(code) {
65
- const data = await this.fetch(() => `https://api.weixin.qq.com/sns/jscode2session?appid=${this.config.appId}&secret=${this.config.appSecret}&js_code=${code}&grant_type=authorization_code`, 'get', {}, false);
66
- return {
67
- openid: data.openid,
68
- session_key: data.session_key,
69
- unionid: data.unionid
70
- };
71
- }
72
- getTemplIds() {
73
- return this.templKeyCache;
74
- }
75
- decrypt({ sessionKey, encryptedData, iv }) {
76
- Throw.if(!sessionKey, '会话过期,请重新登陆!');
77
- const sessionKeyBuf = Buffer.from(sessionKey, 'base64');
78
- const encryptedDataBuf = Buffer.from(encryptedData, 'base64');
79
- const ivBuf = Buffer.from(iv, 'base64');
80
- try {
81
- // 解密
82
- const decipher = crypto.createDecipheriv('aes-128-cbc', sessionKeyBuf, ivBuf);
83
- // 设置自动 padding 为 true,删除填充补位
84
- decipher.setAutoPadding(true);
85
- const decoded = decipher.update(encryptedDataBuf, undefined, 'utf8') + decipher.final('utf8');
86
- const decodedData = JSON.parse(decoded);
87
- Throw.if(decodedData.watermark.appid !== this.config.appId, '加密验证失败');
88
- return decodedData;
89
- }
90
- catch (err) {
91
- throw new Error('加密验证失败');
92
- }
93
- }
94
- async getLiveInfo(start, limit) {
95
- const data = await this.fetch((token) => `https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=${token}`, 'post', { start, limit });
96
- return data.room_info;
97
- }
98
- async getLiveReplay(room_id, start, limit) {
99
- const data = await this.fetch((token) => `https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=${token}`, 'post', { room_id, start, limit, action: 'get_replay' });
100
- return data.live_replay;
101
- }
102
- }
package/wx/organ.d.ts DELETED
@@ -1,65 +0,0 @@
1
- import { BaseWx } from './base';
2
- import { WxOrganConfig, WxDepartment, WxOrganUser, WxOrganUserSimply, WxOrganText, WxOrganImage, WxOrganVoice, WxOrganVideo, WxOrganFile, WxOrganTextCard, WxOrganNews, WxOrganMpNews, WxOrganMarkDown, WxOrganTaskCard, WxOrganMini } from './types.js';
3
- export declare class WxOrgan extends BaseWx {
4
- protected name: string;
5
- private config;
6
- private miniMessCache;
7
- private messCache;
8
- constructor(config: WxOrganConfig);
9
- createDepartment(param: WxDepartment): Promise<number>;
10
- updateDepartment(param: WxDepartment): Promise<void>;
11
- deleteDepartment(id: number): Promise<void>;
12
- getDepartmentList(id?: number): Promise<WxDepartment[]>;
13
- createUser(param: WxOrganUser): Promise<string | number>;
14
- getUser(userid: number | string): Promise<WxOrganUser>;
15
- updateUser(param: WxOrganUser): Promise<void>;
16
- deleteUser(userid: number | string): Promise<void>;
17
- batchDeleteUser(useridlist: Array<number | string>): Promise<void>;
18
- getDeptUserSimply(department_id: number, fetch_child: boolean): Promise<WxOrganUserSimply[]>;
19
- getDeptUser(department_id: number, fetch_child: boolean): Promise<WxOrganUser[]>;
20
- userid2openid(userid: number | string): Promise<string>;
21
- openid2userid(openid: string): Promise<number | string>;
22
- authsucc(userid: string): Promise<void>;
23
- inviteUsers({ user, party, tag }: {
24
- user?: Array<number | string>;
25
- party?: number[];
26
- tag?: number[];
27
- }): Promise<{
28
- invaliduser?: Array<number | string>;
29
- invalidparty?: number[];
30
- invalidtag?: number[];
31
- }>;
32
- createTag(tagname: string, tagid: number): Promise<number>;
33
- updateTag(tagname: string, tagid: number): Promise<void>;
34
- deleteTag(tagid: number): Promise<void>;
35
- createTagUser(tagid: number, userlist: Array<string | number>): Promise<void>;
36
- deleteTagUser(tagid: number, userlist: Array<string | number>): Promise<void>;
37
- getTagUser(tagid: number): Promise<{
38
- tagname: string;
39
- userlist: Array<{
40
- userid: string | number;
41
- name: string;
42
- }>;
43
- partylist: number[];
44
- }>;
45
- getTag(): Promise<Array<{
46
- tagid: number;
47
- tagname: string;
48
- }>>;
49
- updateTaskCard(userids: Array<string | number>, task_id: string, clicked_key: string): Promise<void>;
50
- sendMiniMs({ touser, toparty, totag, name, scene, ms }: {
51
- touser?: Array<number | string>;
52
- toparty?: number[];
53
- totag?: number[];
54
- name: string;
55
- scene?: string;
56
- ms: WxOrganMini;
57
- }): Promise<void>;
58
- sendMs({ touser, toparty, totag, name, ms }: {
59
- touser?: Array<number | string>;
60
- toparty?: number[];
61
- totag?: number[];
62
- name: string;
63
- ms: WxOrganText | WxOrganImage | WxOrganVoice | WxOrganVideo | WxOrganFile | WxOrganTextCard | WxOrganNews | WxOrganMpNews | WxOrganMarkDown | WxOrganTaskCard;
64
- }): Promise<void>;
65
- }