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/wx/organ.js DELETED
@@ -1,171 +0,0 @@
1
- import { BaseWx } from './base';
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 {};
File without changes