baja-lite 1.6.2 → 1.6.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.
- package/.eslintignore +7 -0
- package/.eslintrc.cjs +89 -0
- package/.prettierrc +7 -0
- package/.vscode/settings.json +9 -0
- package/ci.js +33 -0
- package/package-cjs.json +17 -0
- package/package.json +80 -80
- package/pnpm-lock.yaml +2840 -0
- package/pnpm-workspace.yaml +2 -0
- package/{boot-remote.js → src/boot-remote.ts} +64 -63
- package/{boot.js → src/boot.ts} +170 -163
- package/{code.js → src/code.ts} +526 -517
- package/{convert-xml.js → src/convert-xml.ts} +460 -410
- package/src/error.ts +11 -0
- package/src/event.ts +34 -0
- package/src/fn.ts +295 -0
- package/{index.d.ts → src/index.ts} +11 -10
- package/src/math.ts +405 -0
- package/src/object.ts +342 -0
- package/{snowflake.js → src/snowflake.ts} +127 -108
- package/src/sql.ts +5529 -0
- package/{sqlite.js → src/sqlite.ts} +157 -156
- package/src/string.ts +111 -0
- package/src/test-mysql.ts +148 -0
- package/{test-postgresql.js → src/test-postgresql.ts} +80 -91
- package/{test-sqlite.js → src/test-sqlite.ts} +80 -90
- package/{test-xml.js → src/test-xml.ts} +70 -70
- package/{test.js → src/test.ts} +3 -2
- package/src/wx/base.ts +77 -0
- package/src/wx/mini.ts +147 -0
- package/src/wx/organ.ts +290 -0
- package/{wx/types.d.ts → src/wx/types.ts} +549 -560
- package/{wx.d.ts → src/wx.ts} +3 -3
- package/tsconfig.cjs.json +42 -0
- package/tsconfig.json +44 -0
- package/xml/event-report.xml +13 -0
- package/yarn.lock +1977 -0
- package/boot-remote.d.ts +0 -2
- package/boot.d.ts +0 -2
- package/code.d.ts +0 -2
- package/convert-xml.d.ts +0 -10
- package/error.d.ts +0 -5
- package/error.js +0 -13
- package/event.d.ts +0 -10
- package/event.js +0 -38
- package/fn.d.ts +0 -128
- package/fn.js +0 -172
- package/index.js +0 -10
- package/math.d.ts +0 -83
- package/math.js +0 -451
- package/object.d.ts +0 -126
- package/object.js +0 -321
- package/snowflake.d.ts +0 -12
- package/sql.d.ts +0 -2148
- package/sql.js +0 -5372
- package/sqlite.d.ts +0 -32
- package/string.d.ts +0 -17
- package/string.js +0 -105
- package/test-mysql.d.ts +0 -2
- package/test-mysql.js +0 -114
- package/test-postgresql.d.ts +0 -2
- package/test-sqlite.d.ts +0 -1
- package/test-xml.d.ts +0 -1
- package/test.d.ts +0 -1
- package/wx/base.d.ts +0 -11
- package/wx/base.js +0 -78
- package/wx/mini.d.ts +0 -52
- package/wx/mini.js +0 -112
- package/wx/organ.d.ts +0 -65
- package/wx/organ.js +0 -171
- package/wx/types.js +0 -1
- package/wx.js +0 -3
- /package/{README.md → Readme.md} +0 -0
package/wx/organ.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { BaseWx } from './base.js';
|
|
2
|
-
export class WxOrgan extends BaseWx {
|
|
3
|
-
// private aesKey: Buffer | undefined;
|
|
4
|
-
// private iv: Buffer | undefined;
|
|
5
|
-
constructor(config) {
|
|
6
|
-
super();
|
|
7
|
-
this.name = 'wxOrgan';
|
|
8
|
-
this.config = config;
|
|
9
|
-
this.tokenUrl = `https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${this.config.corpid}&corpsecret=${this.config.corpsecret}`;
|
|
10
|
-
this.miniMessCache = {};
|
|
11
|
-
this.messCache = {};
|
|
12
|
-
// if (this.config.msHook) {
|
|
13
|
-
// this.aesKey = Buffer.from(this.config.encodingAESKey + '=', 'base64');
|
|
14
|
-
// this.iv = this.aesKey.slice(0, 16);
|
|
15
|
-
// }
|
|
16
|
-
if (this.config.miniMessages) {
|
|
17
|
-
for (const item of this.config.miniMessages) {
|
|
18
|
-
if (!this.miniMessCache[item.name]) {
|
|
19
|
-
this.miniMessCache[item.name] = [];
|
|
20
|
-
}
|
|
21
|
-
this.miniMessCache[item.name].push({
|
|
22
|
-
appid: this.config.appid,
|
|
23
|
-
page: `pages/${item.model}/${item.page}/${item.page}`
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (this.config.messages) {
|
|
28
|
-
for (const item of this.config.messages) {
|
|
29
|
-
if (!this.messCache[item.name]) {
|
|
30
|
-
this.messCache[item.name] = [];
|
|
31
|
-
}
|
|
32
|
-
this.messCache[item.name].push({
|
|
33
|
-
agentid: this.config.agentid,
|
|
34
|
-
...item
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
this.mock = this.config.mock === true;
|
|
39
|
-
}
|
|
40
|
-
async createDepartment(param) {
|
|
41
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token=${token}`, 'post', param);
|
|
42
|
-
return data.id;
|
|
43
|
-
}
|
|
44
|
-
async updateDepartment(param) {
|
|
45
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/department/update?access_token=${token}`, 'post', param);
|
|
46
|
-
}
|
|
47
|
-
async deleteDepartment(id) {
|
|
48
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/department/delete?access_token=${token}`, 'get', { id });
|
|
49
|
-
}
|
|
50
|
-
async getDepartmentList(id) {
|
|
51
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=${token}`, 'get', { id });
|
|
52
|
-
return data.department;
|
|
53
|
-
}
|
|
54
|
-
async createUser(param) {
|
|
55
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token=${token}`, 'post', param);
|
|
56
|
-
return data.id;
|
|
57
|
-
}
|
|
58
|
-
async getUser(userid) {
|
|
59
|
-
return await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=${token}`, 'get', { userid });
|
|
60
|
-
}
|
|
61
|
-
async updateUser(param) {
|
|
62
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token=${token}`, 'post', param);
|
|
63
|
-
}
|
|
64
|
-
async deleteUser(userid) {
|
|
65
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token=${token}`, 'get', { userid });
|
|
66
|
-
}
|
|
67
|
-
async batchDeleteUser(useridlist) {
|
|
68
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete?access_token=${token}`, 'post', { useridlist });
|
|
69
|
-
}
|
|
70
|
-
async getDeptUserSimply(department_id, fetch_child) {
|
|
71
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=${token}`, 'get', { department_id, fetch_child: fetch_child ? 'FETCH_CHILD' : undefined });
|
|
72
|
-
return data.userlist;
|
|
73
|
-
}
|
|
74
|
-
async getDeptUser(department_id, fetch_child) {
|
|
75
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=${token}`, 'get', { department_id, fetch_child: fetch_child ? 'FETCH_CHILD' : undefined });
|
|
76
|
-
return data.userlist;
|
|
77
|
-
}
|
|
78
|
-
async userid2openid(userid) {
|
|
79
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid?access_token=${token}`, 'post', { userid });
|
|
80
|
-
return data.openid;
|
|
81
|
-
}
|
|
82
|
-
async openid2userid(openid) {
|
|
83
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid?access_token=${token}`, 'post', { openid });
|
|
84
|
-
return data.userid;
|
|
85
|
-
}
|
|
86
|
-
async authsucc(userid) {
|
|
87
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?access_token=${token}`, 'get', { userid });
|
|
88
|
-
}
|
|
89
|
-
async inviteUsers({ user, party, tag }) {
|
|
90
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/batch/invite?access_token=${token}`, 'post', { user, party, tag });
|
|
91
|
-
return {
|
|
92
|
-
invaliduser: data.invaliduser,
|
|
93
|
-
invalidparty: data.invalidparty,
|
|
94
|
-
invalidtag: data.invalidtag
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
async createTag(tagname, tagid) {
|
|
98
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=${token}`, 'post', { tagname, tagid });
|
|
99
|
-
return data.id;
|
|
100
|
-
}
|
|
101
|
-
async updateTag(tagname, tagid) {
|
|
102
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/update?access_token=${token}`, 'post', { tagname, tagid });
|
|
103
|
-
}
|
|
104
|
-
async deleteTag(tagid) {
|
|
105
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/delete?access_token=${token}`, 'get', { tagid });
|
|
106
|
-
}
|
|
107
|
-
async createTagUser(tagid, userlist) {
|
|
108
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers?access_token=${token}`, 'post', { tagid, userlist });
|
|
109
|
-
}
|
|
110
|
-
async deleteTagUser(tagid, userlist) {
|
|
111
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers?access_token=${token}`, 'post', { tagid, userlist });
|
|
112
|
-
}
|
|
113
|
-
async getTagUser(tagid) {
|
|
114
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/get?access_token=${token}`, 'get', { tagid });
|
|
115
|
-
return data;
|
|
116
|
-
}
|
|
117
|
-
async getTag() {
|
|
118
|
-
const data = await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=${token}`, 'get', {});
|
|
119
|
-
return data.taglist;
|
|
120
|
-
}
|
|
121
|
-
async updateTaskCard(userids, task_id, clicked_key) {
|
|
122
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/message/update_taskcard?access_token=${token}`, 'post', { userids, task_id, clicked_key });
|
|
123
|
-
}
|
|
124
|
-
async sendMiniMs({ touser, toparty, totag, name, scene, ms }) {
|
|
125
|
-
const touser_ = touser ? touser.join('|') : undefined;
|
|
126
|
-
const toparty_ = toparty ? toparty.join('|') : undefined;
|
|
127
|
-
const totag_ = totag ? totag.join('|') : undefined;
|
|
128
|
-
if (scene) {
|
|
129
|
-
scene = `?${scene}`;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
scene = '';
|
|
133
|
-
}
|
|
134
|
-
if (ms.content_item) {
|
|
135
|
-
for (const [key, value] of Object.entries(ms.content_item)) {
|
|
136
|
-
ms.content_item[key] = value ?? '';
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const temps = this.miniMessCache[name];
|
|
140
|
-
for (const item of temps) {
|
|
141
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${token}`, 'post', {
|
|
142
|
-
touser: touser_,
|
|
143
|
-
toparty: toparty_,
|
|
144
|
-
totag: totag_,
|
|
145
|
-
'msgtype': 'miniprogram_notice',
|
|
146
|
-
miniprogram_notice: {
|
|
147
|
-
...item,
|
|
148
|
-
page: `${item.page}${scene}`,
|
|
149
|
-
...ms
|
|
150
|
-
},
|
|
151
|
-
enable_id_trans: 0
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async sendMs({ touser, toparty, totag, name, ms }) {
|
|
156
|
-
const touser_ = touser ? touser.join('|') : undefined;
|
|
157
|
-
const toparty_ = toparty ? toparty.join('|') : undefined;
|
|
158
|
-
const totag_ = totag ? totag.join('|') : undefined;
|
|
159
|
-
const temps = this.messCache[name];
|
|
160
|
-
for (const item of temps) {
|
|
161
|
-
await this.fetch((token) => `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${token}`, 'post', {
|
|
162
|
-
touser: touser_,
|
|
163
|
-
toparty: toparty_,
|
|
164
|
-
totag: totag_,
|
|
165
|
-
...item,
|
|
166
|
-
[item.msgtype]: ms,
|
|
167
|
-
enable_id_trans: 0
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
package/wx/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/wx.js
DELETED
/package/{README.md → Readme.md}
RENAMED
|
File without changes
|