@juzi/wechaty-puppet-service 1.0.20 → 1.0.21

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 (27) hide show
  1. package/dist/cjs/src/client/puppet-service.d.ts +9 -10
  2. package/dist/cjs/src/client/puppet-service.d.ts.map +1 -1
  3. package/dist/cjs/src/client/puppet-service.js +31 -76
  4. package/dist/cjs/src/client/puppet-service.js.map +1 -1
  5. package/dist/cjs/src/package-json.js +3 -3
  6. package/dist/cjs/src/server/event-stream-manager.d.ts.map +1 -1
  7. package/dist/cjs/src/server/event-stream-manager.js +7 -0
  8. package/dist/cjs/src/server/event-stream-manager.js.map +1 -1
  9. package/dist/cjs/src/server/puppet-implementation.d.ts.map +1 -1
  10. package/dist/cjs/src/server/puppet-implementation.js +14 -61
  11. package/dist/cjs/src/server/puppet-implementation.js.map +1 -1
  12. package/dist/esm/src/client/puppet-service.d.ts +9 -10
  13. package/dist/esm/src/client/puppet-service.d.ts.map +1 -1
  14. package/dist/esm/src/client/puppet-service.js +32 -77
  15. package/dist/esm/src/client/puppet-service.js.map +1 -1
  16. package/dist/esm/src/package-json.js +3 -3
  17. package/dist/esm/src/server/event-stream-manager.d.ts.map +1 -1
  18. package/dist/esm/src/server/event-stream-manager.js +7 -0
  19. package/dist/esm/src/server/event-stream-manager.js.map +1 -1
  20. package/dist/esm/src/server/puppet-implementation.d.ts.map +1 -1
  21. package/dist/esm/src/server/puppet-implementation.js +14 -61
  22. package/dist/esm/src/server/puppet-implementation.js.map +1 -1
  23. package/package.json +3 -3
  24. package/src/client/puppet-service.ts +35 -85
  25. package/src/package-json.ts +3 -3
  26. package/src/server/event-stream-manager.ts +7 -0
  27. package/src/server/puppet-implementation.ts +17 -61
@@ -4,7 +4,7 @@
4
4
  import type { PackageJson } from 'type-fest'
5
5
  export const packageJson: PackageJson = {
6
6
  "name": "@juzi/wechaty-puppet-service",
7
- "version": "1.0.20",
7
+ "version": "1.0.21",
8
8
  "description": "Puppet Service for Wechaty",
9
9
  "type": "module",
10
10
  "exports": {
@@ -69,10 +69,10 @@ export const packageJson: PackageJson = {
69
69
  "why-is-node-running": "^2.2.1"
70
70
  },
71
71
  "peerDependencies": {
72
- "@juzi/wechaty-puppet": "^1.0.24"
72
+ "@juzi/wechaty-puppet": "^1.0.28"
73
73
  },
74
74
  "dependencies": {
75
- "@juzi/wechaty-grpc": "^1.0.14",
75
+ "@juzi/wechaty-grpc": "^1.0.17",
76
76
  "@juzi/wechaty-redux": "^1.0.1",
77
77
  "clone-class": "^1.1.1",
78
78
  "ducks": "^1.0.2",
@@ -280,6 +280,13 @@ class EventStreamManager {
280
280
  this.offCallbackList.push(off)
281
281
  break
282
282
  }
283
+ case 'tag-group': {
284
+ const listener = (payload: PUPPET.payloads.EventTagGroup) => this.grpcEmit(grpcPuppet.EventType.EVENT_TYPE_TAG_GROUP, payload)
285
+ this.puppet.on('tag-group', listener)
286
+ const off = () => this.puppet.off('tag-group', listener)
287
+ this.offCallbackList.push(off)
288
+ break
289
+ }
283
290
  case 'reset':
284
291
  // the `reset` event should be dealed internally, should not send out
285
292
  break
@@ -1507,16 +1507,10 @@ function puppetImplementation (
1507
1507
  log.verbose('PuppetServiceImpl', 'tagContactTagAdd()')
1508
1508
 
1509
1509
  try {
1510
- const tagsProb = call.request.getTagsList()
1510
+ const tagIds = call.request.getTagIdsList()
1511
1511
  const contactIds = call.request.getContactIdsList()
1512
- const tags = tagsProb.map(tagProb => {
1513
- return {
1514
- id: tagProb.getId(),
1515
- groupId: tagProb.getGroupId(),
1516
- }
1517
- })
1518
1512
 
1519
- await puppet.tagContactTagAdd(tags, contactIds)
1513
+ await puppet.tagContactTagAdd(tagIds, contactIds)
1520
1514
 
1521
1515
  return callback(null, new grpcPuppet.TagContactTagAddResponse())
1522
1516
  } catch (e) {
@@ -1528,16 +1522,10 @@ function puppetImplementation (
1528
1522
  log.verbose('PuppetServiceImpl', 'tagContactTagRemove()')
1529
1523
 
1530
1524
  try {
1531
- const tagsProb = call.request.getTagsList()
1525
+ const tagIds = call.request.getTagIdsList()
1532
1526
  const contactIds = call.request.getContactIdsList()
1533
- const tags = tagsProb.map(tagProb => {
1534
- return {
1535
- id: tagProb.getId(),
1536
- groupId: tagProb.getGroupId(),
1537
- }
1538
- })
1539
1527
 
1540
- await puppet.tagContactTagRemove(tags, contactIds)
1528
+ await puppet.tagContactTagRemove(tagIds, contactIds)
1541
1529
 
1542
1530
  return callback(null, new grpcPuppet.TagContactTagRemoveResponse())
1543
1531
  } catch (e) {
@@ -1587,15 +1575,10 @@ function puppetImplementation (
1587
1575
  const tagName = call.request.getTagName()
1588
1576
 
1589
1577
  const result = await puppet.tagTagAdd(tagName, tagGroupId)
1590
- const tagIdentifier = new grpcPuppet.TagIdentifier()
1591
1578
  const response = new grpcPuppet.TagTagAddResponse()
1592
1579
 
1593
1580
  if (result) {
1594
- tagIdentifier.setId(result.id)
1595
- if (result.groupId) {
1596
- tagIdentifier.setGroupId(result.groupId)
1597
- }
1598
- response.setTag(tagIdentifier)
1581
+ response.setTagId(result)
1599
1582
  }
1600
1583
 
1601
1584
  return callback(null, response)
@@ -1608,11 +1591,9 @@ function puppetImplementation (
1608
1591
  log.verbose('PuppetServiceImpl', 'tagTagDelete()')
1609
1592
 
1610
1593
  try {
1611
- const tagProb = call.request.getTag()
1612
- const id = tagProb?.getId()!
1613
- const groupId = tagProb?.getGroupId()
1594
+ const tagId = call.request.getTagId()
1614
1595
 
1615
- await puppet.tagTagDelete({ id, groupId })
1596
+ await puppet.tagTagDelete(tagId)
1616
1597
 
1617
1598
  return callback(null, new grpcPuppet.TagTagDeleteResponse())
1618
1599
  } catch (e) {
@@ -1642,16 +1623,9 @@ function puppetImplementation (
1642
1623
  const tagGroupId = call.request.getTagGroupId()
1643
1624
 
1644
1625
  const result = await puppet.tagGroupTagList(tagGroupId)
1645
- const tagIdentifiers = result.map(tag => {
1646
- const tagIdentifier = new grpcPuppet.TagIdentifier()
1647
- tagIdentifier.setId(tag.id)
1648
- if (tag.groupId) {
1649
- tagIdentifier.setGroupId(tag.groupId)
1650
- }
1651
- return tagIdentifier
1652
- })
1626
+
1653
1627
  const response = new grpcPuppet.TagGroupTagListResponse()
1654
- response.setTagsList(tagIdentifiers)
1628
+ response.setTagIdsList(result)
1655
1629
 
1656
1630
  return callback(null, response)
1657
1631
  } catch (e) {
@@ -1665,16 +1639,9 @@ function puppetImplementation (
1665
1639
 
1666
1640
  try {
1667
1641
  const result = await puppet.tagTagList()
1668
- const tagIdentifiers = result.map(tag => {
1669
- const tagIdentifier = new grpcPuppet.TagIdentifier()
1670
- tagIdentifier.setId(tag.id)
1671
- if (tag.groupId) {
1672
- tagIdentifier.setGroupId(tag.groupId)
1673
- }
1674
- return tagIdentifier
1675
- })
1642
+
1676
1643
  const response = new grpcPuppet.TagTagListResponse()
1677
- response.setTagsList(tagIdentifiers)
1644
+ response.setTagIdsList(result)
1678
1645
 
1679
1646
  return callback(null, response)
1680
1647
  } catch (e) {
@@ -1689,16 +1656,9 @@ function puppetImplementation (
1689
1656
  const contactId = call.request.getContactId()
1690
1657
 
1691
1658
  const result = await puppet.tagContactTagList(contactId)
1692
- const tagIdentifiers = result.map(tag => {
1693
- const tagIdentifier = new grpcPuppet.TagIdentifier()
1694
- tagIdentifier.setId(tag.id)
1695
- if (tag.groupId) {
1696
- tagIdentifier.setGroupId(tag.groupId)
1697
- }
1698
- return tagIdentifier
1699
- })
1659
+
1700
1660
  const response = new grpcPuppet.TagContactTagListResponse()
1701
- response.setTagsList(tagIdentifiers)
1661
+ response.setTagIdsList(result)
1702
1662
 
1703
1663
  return callback(null, response)
1704
1664
  } catch (e) {
@@ -1710,11 +1670,9 @@ function puppetImplementation (
1710
1670
  log.verbose('PuppetServiceImpl', 'tagTagContactList()')
1711
1671
 
1712
1672
  try {
1713
- const tagProb = call.request.getTag()
1714
- const id = tagProb?.getId()!
1715
- const groupId = tagProb?.getGroupId()
1673
+ const tagId = call.request.getTagId()
1716
1674
 
1717
- const result = await puppet.tagTagContactList({ id, groupId })
1675
+ const result = await puppet.tagTagContactList(tagId)
1718
1676
 
1719
1677
  const response = new grpcPuppet.TagTagContactListResponse()
1720
1678
  response.setContactIdsList(result)
@@ -1750,11 +1708,9 @@ function puppetImplementation (
1750
1708
  log.verbose('PuppetServiceImpl', 'tagPayload()')
1751
1709
 
1752
1710
  try {
1753
- const tag = call.request.getTag()!
1754
- const id = tag.getId()
1755
- const groupId = tag.getGroupId() || ''
1711
+ const tagId = call.request.getTagId()
1756
1712
 
1757
- const result = await puppet.tagPayloadPuppet({ id, groupId })
1713
+ const result = await puppet.tagPayloadPuppet(tagId)
1758
1714
  const response = new grpcPuppet.TagPayloadResponse()
1759
1715
  const payload = new grpcPuppet.TagPayload()
1760
1716
  payload.setId(result.id)