baja-lite 1.6.4 → 1.6.6

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 (73) hide show
  1. package/boot-remote.d.ts +2 -0
  2. package/{src/boot-remote.ts → boot-remote.js} +66 -64
  3. package/boot.d.ts +2 -0
  4. package/{src/boot.ts → boot.js} +166 -170
  5. package/code.d.ts +2 -0
  6. package/{src/code.ts → code.js} +405 -414
  7. package/convert-xml.d.ts +10 -0
  8. package/{src/convert-xml.ts → convert-xml.js} +410 -460
  9. package/error.d.ts +5 -0
  10. package/error.js +13 -0
  11. package/event.d.ts +10 -0
  12. package/event.js +38 -0
  13. package/fn.d.ts +128 -0
  14. package/fn.js +172 -0
  15. package/{src/index.ts → index.d.ts} +10 -11
  16. package/index.js +10 -0
  17. package/math.d.ts +83 -0
  18. package/math.js +451 -0
  19. package/object.d.ts +126 -0
  20. package/object.js +321 -0
  21. package/package.json +13 -13
  22. package/snowflake.d.ts +12 -0
  23. package/{src/snowflake.ts → snowflake.js} +108 -127
  24. package/sql.d.ts +2151 -0
  25. package/sql.js +5371 -0
  26. package/sqlite.d.ts +32 -0
  27. package/{src/sqlite.ts → sqlite.js} +156 -157
  28. package/string.d.ts +17 -0
  29. package/string.js +105 -0
  30. package/test-mysql.d.ts +2 -0
  31. package/test-mysql.js +114 -0
  32. package/test-postgresql.d.ts +2 -0
  33. package/{src/test-postgresql.ts → test-postgresql.js} +91 -80
  34. package/test-sqlite.d.ts +1 -0
  35. package/{src/test-sqlite.ts → test-sqlite.js} +90 -80
  36. package/test-xml.d.ts +1 -0
  37. package/{src/test-xml.ts → test-xml.js} +2 -2
  38. package/test.d.ts +1 -0
  39. package/{src/test.ts → test.js} +2 -3
  40. package/wx/base.d.ts +11 -0
  41. package/wx/base.js +78 -0
  42. package/wx/mini.d.ts +52 -0
  43. package/wx/mini.js +112 -0
  44. package/wx/organ.d.ts +65 -0
  45. package/wx/organ.js +171 -0
  46. package/{src/wx/types.ts → wx/types.d.ts} +560 -549
  47. package/wx/types.js +1 -0
  48. package/{src/wx.ts → wx.d.ts} +3 -3
  49. package/wx.js +3 -0
  50. package/.eslintignore +0 -7
  51. package/.eslintrc.cjs +0 -89
  52. package/.prettierrc +0 -7
  53. package/.vscode/settings.json +0 -9
  54. package/ci.js +0 -33
  55. package/package-cjs.json +0 -17
  56. package/pnpm-lock.yaml +0 -2840
  57. package/pnpm-workspace.yaml +0 -2
  58. package/src/error.ts +0 -11
  59. package/src/event.ts +0 -34
  60. package/src/fn.ts +0 -295
  61. package/src/math.ts +0 -405
  62. package/src/object.ts +0 -342
  63. package/src/sql.ts +0 -5529
  64. package/src/string.ts +0 -111
  65. package/src/test-mysql.ts +0 -148
  66. package/src/wx/base.ts +0 -77
  67. package/src/wx/mini.ts +0 -147
  68. package/src/wx/organ.ts +0 -290
  69. package/tsconfig.cjs.json +0 -42
  70. package/tsconfig.json +0 -44
  71. package/xml/event-report.xml +0 -13
  72. package/yarn.lock +0 -1977
  73. /package/{Readme.md → README.md} +0 -0
package/wx/organ.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { BaseWx } from './base.js';
2
+ import { WxDepartment, WxOrganConfig, WxOrganFile, WxOrganImage, WxOrganMarkDown, WxOrganMini, WxOrganMpNews, WxOrganNews, WxOrganTaskCard, WxOrganText, WxOrganTextCard, WxOrganUser, WxOrganUserSimply, WxOrganVideo, WxOrganVoice } 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
+ }
package/wx/organ.js ADDED
@@ -0,0 +1,171 @@
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
+ }