@juzi/wechaty 1.0.45 → 1.0.47

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 (55) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/src/doctor.js.map +1 -1
  3. package/dist/cjs/src/package-json.js +4 -4
  4. package/dist/cjs/src/plugin.spec.js.map +1 -1
  5. package/dist/cjs/src/pure-functions/update.js.map +1 -1
  6. package/dist/cjs/src/pure-functions/xml.spec.js.map +1 -1
  7. package/dist/cjs/src/user-mixins/validation.spec.js.map +1 -1
  8. package/dist/cjs/src/user-modules/contact.d.ts +1 -0
  9. package/dist/cjs/src/user-modules/contact.d.ts.map +1 -1
  10. package/dist/cjs/src/user-modules/contact.js +3 -0
  11. package/dist/cjs/src/user-modules/contact.js.map +1 -1
  12. package/dist/cjs/src/user-modules/message.spec.js.map +1 -1
  13. package/dist/cjs/src/user-modules/post.js.map +1 -1
  14. package/dist/cjs/src/user-modules/post.spec.js.map +1 -1
  15. package/dist/cjs/src/user-modules/room.d.ts +1 -0
  16. package/dist/cjs/src/user-modules/room.d.ts.map +1 -1
  17. package/dist/cjs/src/user-modules/room.js +13 -0
  18. package/dist/cjs/src/user-modules/room.js.map +1 -1
  19. package/dist/cjs/src/user-modules/room.spec.js.map +1 -1
  20. package/dist/cjs/src/user-modules/tag.js.map +1 -1
  21. package/dist/cjs/tests/node.spec.js.map +1 -1
  22. package/dist/esm/src/doctor.js.map +1 -1
  23. package/dist/esm/src/package-json.js +4 -4
  24. package/dist/esm/src/plugin.spec.js.map +1 -1
  25. package/dist/esm/src/pure-functions/update.js.map +1 -1
  26. package/dist/esm/src/pure-functions/xml.spec.js.map +1 -1
  27. package/dist/esm/src/user-mixins/validation.spec.js.map +1 -1
  28. package/dist/esm/src/user-modules/contact.d.ts +1 -0
  29. package/dist/esm/src/user-modules/contact.d.ts.map +1 -1
  30. package/dist/esm/src/user-modules/contact.js +3 -0
  31. package/dist/esm/src/user-modules/contact.js.map +1 -1
  32. package/dist/esm/src/user-modules/message.spec.js.map +1 -1
  33. package/dist/esm/src/user-modules/post.js.map +1 -1
  34. package/dist/esm/src/user-modules/post.spec.js.map +1 -1
  35. package/dist/esm/src/user-modules/room.d.ts +1 -0
  36. package/dist/esm/src/user-modules/room.d.ts.map +1 -1
  37. package/dist/esm/src/user-modules/room.js +13 -0
  38. package/dist/esm/src/user-modules/room.js.map +1 -1
  39. package/dist/esm/src/user-modules/room.spec.js.map +1 -1
  40. package/dist/esm/src/user-modules/tag.js.map +1 -1
  41. package/dist/esm/tests/node.spec.js.map +1 -1
  42. package/package.json +3 -3
  43. package/src/doctor.ts +1 -1
  44. package/src/package-json.ts +4 -4
  45. package/src/plugin.spec.ts +3 -3
  46. package/src/pure-functions/update.ts +2 -2
  47. package/src/pure-functions/xml.spec.ts +2 -2
  48. package/src/user-mixins/validation.spec.ts +8 -8
  49. package/src/user-modules/contact.ts +9 -5
  50. package/src/user-modules/message.spec.ts +2 -2
  51. package/src/user-modules/post.spec.ts +2 -2
  52. package/src/user-modules/post.ts +9 -9
  53. package/src/user-modules/room.spec.ts +7 -7
  54. package/src/user-modules/room.ts +15 -3
  55. package/src/user-modules/tag.ts +2 -2
@@ -25,18 +25,18 @@ test('validationMixin() valid()', async t => {
25
25
  interface UserClass extends UserClassImpl {}
26
26
 
27
27
  const FIXTURES = [
28
- [new UserClassImpl(), true],
28
+ [ new UserClassImpl(), true ],
29
29
  // Invalid things
30
- [{}, false],
31
- [[], false],
32
- [new Map(), false],
30
+ [ {}, false ],
31
+ [ [], false ],
32
+ [ new Map(), false ],
33
33
  // Object interface
34
- [{ bar: true, foo: true }, true],
35
- [{ bar: true }, false],
36
- [{ foo: true }, false],
34
+ [ { bar: true, foo: true }, true ],
35
+ [ { bar: true }, false ],
36
+ [ { foo: true }, false ],
37
37
  ]
38
38
 
39
- for (const [input, expected] of FIXTURES) {
39
+ for (const [ input, expected ] of FIXTURES) {
40
40
  const valid = expected ? 'valid' : 'invalid'
41
41
  /* eslint-disable multiline-ternary */
42
42
  const type = typeof input !== 'object' ? typeof input
@@ -131,7 +131,7 @@ class ContactMixin extends MixinBase implements SayableSayer {
131
131
  log.warn('Contact', 'find() got more than 1 result: %d total', contactList.length)
132
132
  }
133
133
 
134
- for (const [idx, contact] of contactList.entries()) {
134
+ for (const [ idx, contact ] of contactList.entries()) {
135
135
  // use puppet.contactValidate() to confirm double confirm that this contactId is valid.
136
136
  // https://github.com/wechaty/wechaty-puppet-padchat/issues/64
137
137
  // https://github.com/wechaty/wechaty/issues/1345
@@ -672,11 +672,11 @@ class ContactMixin extends MixinBase implements SayableSayer {
672
672
  log.verbose('Contact', 'tag(%s) for %s', JSON.stringify(tags), this)
673
673
 
674
674
  if (!Array.isArray(tags)) {
675
- tags = [tags]
675
+ tags = [ tags ]
676
676
  }
677
677
 
678
678
  const tagIds = tags.map(tag => tag.id)
679
- await this.wechaty.puppet.tagContactTagAdd(tagIds, [this.id])
679
+ await this.wechaty.puppet.tagContactTagAdd(tagIds, [ this.id ])
680
680
 
681
681
  }
682
682
 
@@ -688,12 +688,12 @@ class ContactMixin extends MixinBase implements SayableSayer {
688
688
  log.verbose('Contact', 'tagRemove(%s) for %s', JSON.stringify(tags), this)
689
689
 
690
690
  if (!Array.isArray(tags)) {
691
- tags = [tags]
691
+ tags = [ tags ]
692
692
  }
693
693
 
694
694
  const tagIds = tags.map(tag => tag.id)
695
695
 
696
- await this.wechaty.puppet.tagContactTagRemove(tagIds, [this.id])
696
+ await this.wechaty.puppet.tagContactTagRemove(tagIds, [ this.id ])
697
697
 
698
698
  }
699
699
 
@@ -824,6 +824,10 @@ class ContactMixin extends MixinBase implements SayableSayer {
824
824
  return additionalInfoObj
825
825
  }
826
826
 
827
+ async payloadModify (payload: Partial<PUPPET.payloads.Contact>): Promise<void> {
828
+ return this.wechaty.puppet.contactPayloadModify(this.id, payload)
829
+ }
830
+
827
831
  }
828
832
 
829
833
  class ContactImplBase extends validationMixin(ContactMixin)<ContactImplInterface>() {}
@@ -80,7 +80,7 @@ test('recalled()', async t => {
80
80
 
81
81
  sandbox.stub(puppet, 'roomMemberList').callsFake(async () => {
82
82
  await new Promise((resolve) => setImmediate(resolve))
83
- return [EXPECTED_TALKER_CONTACT_ID, EXPECTED_LISTENER_CONTACT_ID]
83
+ return [ EXPECTED_TALKER_CONTACT_ID, EXPECTED_LISTENER_CONTACT_ID ]
84
84
  })
85
85
 
86
86
  sandbox.stub(puppet, 'contactPayload').callsFake(async (id: string) => {
@@ -93,7 +93,7 @@ test('recalled()', async t => {
93
93
 
94
94
  const fakeIdSearcher = async (...args: any[]) => {
95
95
  await new Promise(setImmediate)
96
- return [args[0].id]
96
+ return [ args[0].id ]
97
97
  }
98
98
 
99
99
  sandbox.stub(puppet, 'messageSearch').callsFake(fakeIdSearcher)
@@ -63,14 +63,14 @@ test.skip('Post smoke testing', async t => {
63
63
  t.ok(descendantPost, 'tbw')
64
64
  }
65
65
 
66
- const [descendantList, _nextPageToken2] = await wechaty.Post.findAll({}, pagination)
66
+ const [ descendantList, _nextPageToken2 ] = await wechaty.Post.findAll({}, pagination)
67
67
  t.ok(descendantList, 'tbw')
68
68
 
69
69
  for await (const liker of post.taps({ type: PUPPET.types.Tap.Like })) {
70
70
  t.ok(liker, 'tbw')
71
71
  }
72
72
 
73
- const [tapList, _nextPageToken3] = await post.tapFind({ type: PUPPET.types.Tap.Like }, pagination)
73
+ const [ tapList, _nextPageToken3 ] = await post.tapFind({ type: PUPPET.types.Tap.Like }, pagination)
74
74
  t.ok(tapList, 'tbw')
75
75
 
76
76
  await wechaty.stop()
@@ -167,7 +167,7 @@ class PostMixin extends wechatifyMixinBase() {
167
167
  return post
168
168
  }
169
169
 
170
- const [postList] = await this.findAll(filter, { pageSize: 1 })
170
+ const [ postList ] = await this.findAll(filter, { pageSize: 1 })
171
171
  if (postList.length > 0) {
172
172
  return postList[0]
173
173
  }
@@ -211,7 +211,7 @@ class PostMixin extends wechatifyMixinBase() {
211
211
  }
212
212
  }
213
213
 
214
- return [postList, nextPageToken]
214
+ return [ postList, nextPageToken ]
215
215
  }
216
216
 
217
217
  protected _payload?: PUPPET.payloads.Post
@@ -387,7 +387,7 @@ class PostMixin extends wechatifyMixinBase() {
387
387
  parentId: this.id,
388
388
  }
389
389
 
390
- let [postList, nextPageToken] = await this.wechaty.Post.findAll(
390
+ let [ postList, nextPageToken ] = await this.wechaty.Post.findAll(
391
391
  parentIdFilter,
392
392
  pagination,
393
393
  )
@@ -400,7 +400,7 @@ class PostMixin extends wechatifyMixinBase() {
400
400
  break
401
401
  }
402
402
 
403
- [postList, nextPageToken] = await this.wechaty.Post.findAll(
403
+ [ postList, nextPageToken ] = await this.wechaty.Post.findAll(
404
404
  parentIdFilter,
405
405
  {
406
406
  ...pagination,
@@ -438,7 +438,7 @@ class PostMixin extends wechatifyMixinBase() {
438
438
 
439
439
  const pagination: PUPPET.filters.PaginationRequest = {}
440
440
 
441
- let [tapList, nextPageToken] = await this.tapFind(
441
+ let [ tapList, nextPageToken ] = await this.tapFind(
442
442
  filter,
443
443
  pagination,
444
444
  )
@@ -451,7 +451,7 @@ class PostMixin extends wechatifyMixinBase() {
451
451
  break
452
452
  }
453
453
 
454
- [tapList, nextPageToken] = await this.tapFind(
454
+ [ tapList, nextPageToken ] = await this.tapFind(
455
455
  filter,
456
456
  { ...pagination, pageToken: nextPageToken },
457
457
  )
@@ -556,8 +556,8 @@ class PostMixin extends wechatifyMixinBase() {
556
556
  )
557
557
 
558
558
  const tapList: Tap[] = []
559
- for (const [type, data] of Object.entries(response)) {
560
- for (const [i, contactId] of data.contactId.entries()) {
559
+ for (const [ type, data ] of Object.entries(response)) {
560
+ for (const [ i, contactId ] of data.contactId.entries()) {
561
561
  const contact = await this.wechaty.Contact.find({ id: contactId })
562
562
  if (!contact) {
563
563
  log.warn('Post', 'tapFind() contact not found for id: %s', contactId)
@@ -575,7 +575,7 @@ class PostMixin extends wechatifyMixinBase() {
575
575
  }
576
576
  }
577
577
 
578
- return [tapList, nextPageToken]
578
+ return [ tapList, nextPageToken ]
579
579
  }
580
580
 
581
581
  location (): LocationInterface | undefined {
@@ -35,7 +35,7 @@ import type {
35
35
  test('findAll()', async t => {
36
36
  const EXPECTED_ROOM_ID = 'test-id'
37
37
  const EXPECTED_ROOM_TOPIC = 'test-topic'
38
- const EXPECTED_ROOM_ID_LIST = [EXPECTED_ROOM_ID]
38
+ const EXPECTED_ROOM_ID_LIST = [ EXPECTED_ROOM_ID ]
39
39
 
40
40
  const sandbox = sinon.createSandbox()
41
41
 
@@ -113,7 +113,7 @@ test('room.say() smoke testing', async () => {
113
113
 
114
114
  const fakeIdSearcher = async (...args: any[]) => {
115
115
  await new Promise(setImmediate)
116
- return [args[0].id]
116
+ return [ args[0].id ]
117
117
  }
118
118
  sandbox.stub(puppet, 'contactSearch').callsFake(fakeIdSearcher)
119
119
  sandbox.stub(puppet, 'roomSearch').callsFake(fakeIdSearcher)
@@ -144,7 +144,7 @@ test('room.say() smoke testing', async () => {
144
144
  // { contactId: EXPECTED_CONTACT_1_ID, roomId: EXPECTED_ROOM_ID },
145
145
  EXPECTED_ROOM_ID,
146
146
  'To be @little1 or not to be @big2',
147
- [EXPECTED_CONTACT_1_ID, EXPECTED_CONTACT_2_ID],
147
+ [ EXPECTED_CONTACT_1_ID, EXPECTED_CONTACT_2_ID ],
148
148
  ], 'Tagged Template say should be matched')
149
149
  })
150
150
 
@@ -156,7 +156,7 @@ test('room.say() smoke testing', async () => {
156
156
  // { contactId: EXPECTED_CONTACT_1_ID, roomId: EXPECTED_ROOM_ID },
157
157
  EXPECTED_ROOM_ID,
158
158
  '@little1 Yo',
159
- [EXPECTED_CONTACT_1_ID],
159
+ [ EXPECTED_CONTACT_1_ID ],
160
160
  ], 'Single mention should work with old ways')
161
161
  })
162
162
 
@@ -168,7 +168,7 @@ test('room.say() smoke testing', async () => {
168
168
  // { contactId: EXPECTED_CONTACT_1_ID, roomId: EXPECTED_ROOM_ID },
169
169
  EXPECTED_ROOM_ID,
170
170
  '@little1 @big2 hey buddies, let\'s party',
171
- [EXPECTED_CONTACT_1_ID, EXPECTED_CONTACT_2_ID],
171
+ [ EXPECTED_CONTACT_1_ID, EXPECTED_CONTACT_2_ID ],
172
172
  ], 'Multiple mention should work with new way')
173
173
  })
174
174
 
@@ -180,7 +180,7 @@ test('room.say() smoke testing', async () => {
180
180
  // { contactId: EXPECTED_CONTACT_1_ID, roomId: EXPECTED_ROOM_ID },
181
181
  EXPECTED_ROOM_ID,
182
182
  '@all @little1 hey buddies, let\'s party',
183
- ['@all', EXPECTED_CONTACT_1_ID],
183
+ [ '@all', EXPECTED_CONTACT_1_ID ],
184
184
  ], 'should be alble to call with say')
185
185
  })
186
186
 
@@ -192,7 +192,7 @@ test('room.say() smoke testing', async () => {
192
192
  // { contactId: EXPECTED_CONTACT_1_ID, roomId: EXPECTED_ROOM_ID },
193
193
  EXPECTED_ROOM_ID,
194
194
  'hey @all let\'s party, especially @little1',
195
- ['@all', EXPECTED_CONTACT_1_ID],
195
+ [ '@all', EXPECTED_CONTACT_1_ID ],
196
196
  ], 'should be alble to call with template string array')
197
197
  })
198
198
 
@@ -227,7 +227,7 @@ class RoomMixin extends MixinBase implements SayableSayer {
227
227
  log.warn('Room', 'find() got more than one(%d) result', roomList.length)
228
228
  }
229
229
 
230
- for (const [idx, room] of roomList.entries()) {
230
+ for (const [ idx, room ] of roomList.entries()) {
231
231
  // use puppet.roomValidate() to confirm double confirm that this roomId is valid.
232
232
  // https://github.com/wechaty/wechaty-puppet-padchat/issues/64
233
233
  // https://github.com/wechaty/wechaty/issues/1345
@@ -735,7 +735,7 @@ class RoomMixin extends MixinBase implements SayableSayer {
735
735
  if (Array.isArray(contacts)) {
736
736
  contactIds = contacts.map(c => c.id)
737
737
  } else {
738
- contactIds = [contacts.id]
738
+ contactIds = [ contacts.id ]
739
739
  }
740
740
  await this.wechaty.puppet.roomDel(this.id, contactIds)
741
741
  // this.delLocal(contact)
@@ -952,7 +952,10 @@ class RoomMixin extends MixinBase implements SayableSayer {
952
952
 
953
953
  async joinInviter (contact: ContactInterface): Promise<undefined | ContactInterface> {
954
954
  const memberPayload = await this.wechaty.puppet.roomMemberPayload(this.id, contact.id)
955
-
955
+ const inviterId = memberPayload.inviterId
956
+ if (!inviterId) {
957
+ return
958
+ }
956
959
  return this.wechaty.Contact.find({ id: memberPayload.inviterId })
957
960
  }
958
961
 
@@ -1194,6 +1197,15 @@ class RoomMixin extends MixinBase implements SayableSayer {
1194
1197
  return additionalInfoObj
1195
1198
  }
1196
1199
 
1200
+ async remark (remark?: string): Promise<undefined | string> {
1201
+ if (typeof remark === 'string') {
1202
+ await this.wechaty.puppet.roomRemark(this.id, remark)
1203
+ } else {
1204
+ return this.payload?.remark
1205
+ }
1206
+ return undefined
1207
+ }
1208
+
1197
1209
  }
1198
1210
 
1199
1211
  class RoomImpl extends validationMixin(RoomMixin)<RoomImplInterface>() {}
@@ -192,9 +192,9 @@ class TagMixin extends MixinBase {
192
192
  if (Array.isArray(contacts)) {
193
193
  contactIds = contacts.map(c => c.id)
194
194
  } else {
195
- contactIds = [contacts.id]
195
+ contactIds = [ contacts.id ]
196
196
  }
197
- await this.wechaty.puppet.tagContactTagAdd([this.id], contactIds)
197
+ await this.wechaty.puppet.tagContactTagAdd([ this.id ], contactIds)
198
198
  }
199
199
 
200
200
  static async createTag (name: string, tagGroup?: TagGroupInterface): Promise<TagInterface | void> {