@juzi/wechaty-puppet-service 1.0.14 → 1.0.16

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.
@@ -1920,139 +1920,60 @@ class PuppetService extends PUPPET.Puppet {
1920
1920
  * Tag
1921
1921
  *
1922
1922
  */
1923
- // add a tag for a Contact. Create it first if it not exist.
1924
- override async tagContactAdd (
1925
- id: string,
1926
- contactId: string,
1927
- ): Promise<void> {
1928
- log.verbose('PuppetService', 'tagContactAdd(%s, %s)', id, contactId)
1929
-
1930
- const request = new grpcPuppet.TagContactAddRequest()
1931
- request.setId(id)
1932
- request.setContactId(contactId)
1933
-
1934
- await util.promisify(
1935
- this.grpcManager.client.tagContactAdd
1936
- .bind(this.grpcManager.client),
1937
- )(request)
1938
- }
1939
1923
 
1940
- // remove a tag from the Contact
1941
- override async tagContactRemove (
1942
- id: string,
1943
- contactId: string,
1944
- ) : Promise<void> {
1945
- log.verbose('PuppetService', 'tagContactRemove(%s, %s)', id, contactId)
1946
-
1947
- const request = new grpcPuppet.TagContactRemoveRequest()
1948
- request.setId(id)
1949
- request.setContactId(contactId)
1950
-
1951
- await util.promisify(
1952
- this.grpcManager.client.tagContactRemove
1953
- .bind(this.grpcManager.client),
1954
- )(request)
1955
- }
1956
-
1957
- // delete a tag from Wechat
1958
- override async tagContactDelete (
1959
- id: string,
1960
- ) : Promise<void> {
1961
- log.verbose('PuppetService', 'tagContactDelete(%s)', id)
1962
-
1963
- const request = new grpcPuppet.TagContactDeleteRequest()
1964
- request.setId(id)
1965
-
1966
- await util.promisify(
1967
- this.grpcManager.client.tagContactDelete
1968
- .bind(this.grpcManager.client),
1969
- )(request)
1970
- }
1971
-
1972
- // get tags from a specific Contact
1973
- override async tagContactList (
1974
- contactId?: string,
1975
- ) : Promise<string[]> {
1976
- log.verbose('PuppetService', 'tagContactList(%s)', contactId)
1977
-
1978
- const request = new grpcPuppet.TagContactListRequest()
1979
-
1980
- if (typeof contactId !== 'undefined') {
1981
- request.setContactId(contactId)
1982
- {
1983
-
1984
- /**
1985
- * Huan(202110): Deprecated: will be removed after Dec 31, 2022
1986
- */
1987
- const contactIdWrapper = new StringValue()
1988
- contactIdWrapper.setValue(contactId)
1989
- request.setContactIdStringValueDeprecated(contactIdWrapper)
1990
- }
1991
- }
1992
-
1993
- const response = await util.promisify(
1994
- this.grpcManager.client.tagContactList
1995
- .bind(this.grpcManager.client),
1996
- )(request)
1997
-
1998
- return response.getIdsList()
1999
- }
2000
-
2001
- /**
2002
- *
2003
- * Tag
2004
- *
2005
- */
2006
-
2007
- override async corpTagContactTagAdd (
2008
- corpTagGroupId: string,
2009
- corpTagId: string,
1924
+ override async tagContactTagAdd (
1925
+ tagGroupId: string | undefined,
1926
+ tagId: string,
2010
1927
  contactId: string,
2011
1928
  ): Promise<void> {
2012
- log.verbose('PuppetService', 'corpTagContactTagAdd(%s, %s, %s)', corpTagGroupId, corpTagId, contactId)
1929
+ log.verbose('PuppetService', 'tagContactTagAdd(%s, %s, %s)', tagGroupId, tagId, contactId)
2013
1930
 
2014
- const request = new grpcPuppet.CorpTagContactTagAddRequest()
1931
+ const request = new grpcPuppet.TagContactTagAddRequest()
2015
1932
 
2016
- request.setCorpTagGroupId(corpTagGroupId)
2017
- request.setCorpTagId(corpTagId)
1933
+ if (typeof tagGroupId !== 'undefined') {
1934
+ request.setTagGroupId(tagGroupId)
1935
+ }
1936
+ request.setTagId(tagId)
2018
1937
  request.setContactId(contactId)
2019
1938
 
2020
1939
  await util.promisify(
2021
- this.grpcManager.client.corpTagContactTagAdd
1940
+ this.grpcManager.client.tagContactTagAdd
2022
1941
  .bind(this.grpcManager.client),
2023
1942
  )(request)
2024
1943
  }
2025
1944
 
2026
- override async corpTagContactTagRemove (
2027
- corpTagGroupId: string,
2028
- corpTagId: string,
1945
+ override async tagContactTagRemove (
1946
+ tagGroupId: string | undefined,
1947
+ tagId: string,
2029
1948
  contactId: string,
2030
1949
  ): Promise<void> {
2031
- log.verbose('PuppetService', 'corpTagContactRemoveAdd(%s, %s, %s)', corpTagGroupId, corpTagId, contactId)
1950
+ log.verbose('PuppetService', 'tagContactTagRemove(%s, %s, %s)', tagGroupId, tagId, contactId)
2032
1951
 
2033
- const request = new grpcPuppet.CorpTagContactTagRemoveRequest()
1952
+ const request = new grpcPuppet.TagContactTagRemoveRequest()
2034
1953
 
2035
- request.setCorpTagGroupId(corpTagGroupId)
2036
- request.setCorpTagId(corpTagId)
1954
+ if (typeof tagGroupId !== 'undefined') {
1955
+ request.setTagGroupId(tagGroupId)
1956
+ }
1957
+ request.setTagId(tagId)
2037
1958
  request.setContactId(contactId)
2038
1959
 
2039
1960
  await util.promisify(
2040
- this.grpcManager.client.corpTagContactTagRemove
1961
+ this.grpcManager.client.tagContactTagRemove
2041
1962
  .bind(this.grpcManager.client),
2042
1963
  )(request)
2043
1964
  }
2044
1965
 
2045
- override async corpTagGroupAdd (
2046
- corpTagGroupName: string,
2047
- ): Promise<PUPPET.payloads.CorpTagGroup | void> {
2048
- log.verbose('PuppetService', 'corpTagGroupAdd(%s)', corpTagGroupName)
1966
+ override async tagGroupAdd (
1967
+ tagGroupName: string,
1968
+ ): Promise<PUPPET.payloads.TagGroup | void> {
1969
+ log.verbose('PuppetService', 'tagGroupAdd(%s)', tagGroupName)
2049
1970
 
2050
- const request = new grpcPuppet.CorpTagGroupAddRequest()
1971
+ const request = new grpcPuppet.TagGroupAddRequest()
2051
1972
 
2052
- request.setCorpTagGroupName(corpTagGroupName)
1973
+ request.setTagGroupName(tagGroupName)
2053
1974
 
2054
1975
  const result = await util.promisify(
2055
- this.grpcManager.client.corpTagGroupAdd
1976
+ this.grpcManager.client.tagGroupAdd
2056
1977
  .bind(this.grpcManager.client),
2057
1978
  )(request)
2058
1979
 
@@ -2061,7 +1982,7 @@ class PuppetService extends PUPPET.Puppet {
2061
1982
  const name = grpcPayload?.getName()
2062
1983
 
2063
1984
  if (id && name) {
2064
- const payload: PUPPET.payloads.CorpTagGroup = {
1985
+ const payload: PUPPET.payloads.TagGroup = {
2065
1986
  id,
2066
1987
  name,
2067
1988
  }
@@ -2070,35 +1991,37 @@ class PuppetService extends PUPPET.Puppet {
2070
1991
 
2071
1992
  }
2072
1993
 
2073
- override async corpTagGroupDelete (
2074
- corpTagGroupId: string,
1994
+ override async tagGroupDelete (
1995
+ tagGroupId: string,
2075
1996
  ): Promise<void> {
2076
- log.verbose('PuppetService', 'corpTagGroupDelete(%s)', corpTagGroupId)
1997
+ log.verbose('PuppetService', 'tagGroupDelete(%s)', tagGroupId)
2077
1998
 
2078
- const request = new grpcPuppet.CorpTagGroupDeleteRequest()
1999
+ const request = new grpcPuppet.TagGroupDeleteRequest()
2079
2000
 
2080
- request.setCorpTagGroupId(corpTagGroupId)
2001
+ request.setTagGroupId(tagGroupId)
2081
2002
 
2082
2003
  await util.promisify(
2083
- this.grpcManager.client.corpTagGroupDelete
2004
+ this.grpcManager.client.tagGroupDelete
2084
2005
  .bind(this.grpcManager.client),
2085
2006
  )(request)
2086
2007
 
2087
2008
  }
2088
2009
 
2089
- override async corpTagTagAdd (
2090
- corpTagGroupId: string,
2091
- corpTagName: string,
2092
- ): Promise<PUPPET.payloads.CorpTag | void> {
2093
- log.verbose('PuppetService', 'corpTagTagAdd(%s, %s)', corpTagGroupId, corpTagName)
2010
+ override async tagTagAdd (
2011
+ tagGroupId: string | undefined,
2012
+ tagName: string,
2013
+ ): Promise<PUPPET.payloads.Tag | void> {
2014
+ log.verbose('PuppetService', 'tagTagAdd(%s, %s)', tagGroupId, tagName)
2094
2015
 
2095
- const request = new grpcPuppet.CorpTagTagAddRequest()
2016
+ const request = new grpcPuppet.TagTagAddRequest()
2096
2017
 
2097
- request.setCorpTagGroupId(corpTagGroupId)
2098
- request.setCorpTagName(corpTagName)
2018
+ if (typeof tagGroupId !== 'undefined') {
2019
+ request.setTagGroupId(tagGroupId)
2020
+ }
2021
+ request.setTagName(tagName)
2099
2022
 
2100
2023
  const result = await util.promisify(
2101
- this.grpcManager.client.corpTagTagAdd
2024
+ this.grpcManager.client.tagTagAdd
2102
2025
  .bind(this.grpcManager.client),
2103
2026
  )(request)
2104
2027
 
@@ -2106,104 +2029,156 @@ class PuppetService extends PUPPET.Puppet {
2106
2029
  const id = grpcPayload?.getId()
2107
2030
  const name = grpcPayload?.getName()
2108
2031
  const groupId = grpcPayload?.getGroupId()
2032
+ const type = grpcPayload?.getType()
2109
2033
 
2110
- if (id && name && groupId) {
2111
- const payload: PUPPET.payloads.CorpTag = {
2034
+ if (id && name && type) {
2035
+ const payload: PUPPET.payloads.Tag = {
2112
2036
  id,
2113
2037
  name,
2114
2038
  groupId,
2039
+ type,
2115
2040
  }
2116
2041
  return payload
2117
2042
  }
2118
2043
 
2119
2044
  }
2120
2045
 
2121
- override async corpTagTagDelete (
2122
- corpTagGroupId: string,
2123
- corpTagId: string,
2046
+ override async tagTagDelete (
2047
+ tagGroupId: string | undefined,
2048
+ tagId: string,
2124
2049
  ): Promise<void> {
2125
- log.verbose('PuppetService', 'corpTagTagDelete(%s, %s)', corpTagGroupId, corpTagId)
2050
+ log.verbose('PuppetService', 'tagTagDelete(%s, %s)', tagGroupId, tagId)
2126
2051
 
2127
- const request = new grpcPuppet.CorpTagTagDeleteRequest()
2052
+ const request = new grpcPuppet.TagTagDeleteRequest()
2128
2053
 
2129
- request.setCorpTagGroupId(corpTagGroupId)
2130
- request.setCorpTagId(corpTagId)
2054
+ if (typeof tagGroupId !== 'undefined') {
2055
+ request.setTagGroupId(tagGroupId)
2056
+ }
2057
+ request.setTagId(tagId)
2131
2058
 
2132
2059
  await util.promisify(
2133
- this.grpcManager.client.corpTagTagDelete
2060
+ this.grpcManager.client.tagTagDelete
2134
2061
  .bind(this.grpcManager.client),
2135
2062
  )(request)
2136
2063
 
2137
2064
  }
2138
2065
 
2139
- override async corpTagGroupList (): Promise<PUPPET.payloads.CorpTagGroup[]> {
2140
- log.verbose('PuppetService', 'corpTagGroupList()')
2066
+ override async tagGroupList (): Promise<PUPPET.payloads.TagGroup[]> {
2067
+ log.verbose('PuppetService', 'tagGroupList()')
2141
2068
 
2142
- const request = new grpcPuppet.CorpTagGroupListRequest()
2069
+ const request = new grpcPuppet.TagGroupListRequest()
2143
2070
 
2144
2071
  const result = await util.promisify(
2145
- this.grpcManager.client.corpTagGroupList
2072
+ this.grpcManager.client.tagGroupList
2146
2073
  .bind(this.grpcManager.client),
2147
2074
  )(request)
2148
2075
 
2149
2076
  const grpcPayloads = result.getPayloadsList()
2150
- const payloads: PUPPET.payloads.CorpTagGroup[] = grpcPayloads.map(payload => {
2077
+ const payloads: PUPPET.payloads.TagGroup[] = grpcPayloads.map(payload => {
2151
2078
  return {
2152
2079
  id: payload.getId(),
2153
2080
  name: payload.getName(),
2154
- } as PUPPET.payloads.CorpTagGroup
2081
+ } as PUPPET.payloads.TagGroup
2155
2082
  })
2156
2083
  return payloads
2157
2084
  }
2158
2085
 
2159
- override async corpTagTagList (
2160
- corpTagGroupId: string,
2161
- ): Promise<PUPPET.payloads.CorpTag[]> {
2162
- log.verbose('PuppetService', 'corpTagTagList(%s)', corpTagGroupId)
2086
+ override async tagGroupTagList (
2087
+ tagGroupId: string | undefined,
2088
+ ): Promise<PUPPET.payloads.Tag[]> {
2089
+ log.verbose('PuppetService', 'tagGroupTagList(%s)', tagGroupId)
2163
2090
 
2164
- const request = new grpcPuppet.CorpTagTagListRequest()
2165
- request.setCorpTagGroupId(corpTagGroupId)
2091
+ const request = new grpcPuppet.TagGroupTagListRequest()
2092
+ if (typeof tagGroupId !== 'undefined') {
2093
+ request.setTagGroupId(tagGroupId)
2094
+ }
2166
2095
 
2167
2096
  const result = await util.promisify(
2168
- this.grpcManager.client.corpTagTagList
2097
+ this.grpcManager.client.tagGroupTagList
2169
2098
  .bind(this.grpcManager.client),
2170
2099
  )(request)
2171
2100
 
2172
2101
  const grpcPayloads = result.getPayloadsList()
2173
- const payloads: PUPPET.payloads.CorpTag[] = grpcPayloads.map(payload => {
2102
+ const payloads: PUPPET.payloads.Tag[] = grpcPayloads.map(payload => {
2174
2103
  return {
2175
2104
  id: payload.getId(),
2176
2105
  name: payload.getName(),
2177
2106
  groupId: payload.getGroupId(),
2178
- } as PUPPET.payloads.CorpTag
2107
+ type: payload.getType(),
2108
+ } as PUPPET.payloads.Tag
2179
2109
  })
2180
2110
  return payloads
2181
2111
  }
2182
2112
 
2183
- override async corpTagContactTagList (
2113
+ override async tagTagList (
2114
+ ): Promise<PUPPET.payloads.Tag[]> {
2115
+ log.verbose('PuppetService', 'tagTagList()')
2116
+
2117
+ const request = new grpcPuppet.TagTagListRequest()
2118
+
2119
+ const result = await util.promisify(
2120
+ this.grpcManager.client.tagTagList
2121
+ .bind(this.grpcManager.client),
2122
+ )(request)
2123
+
2124
+ const grpcPayloads = result.getPayloadsList()
2125
+ const payloads: PUPPET.payloads.Tag[] = grpcPayloads.map(payload => {
2126
+ return {
2127
+ id: payload.getId(),
2128
+ name: payload.getName(),
2129
+ groupId: payload.getGroupId(),
2130
+ type: payload.getType(),
2131
+ } as PUPPET.payloads.Tag
2132
+ })
2133
+ return payloads
2134
+ }
2135
+
2136
+ override async tagContactTagList (
2184
2137
  contactId: string,
2185
- ): Promise<PUPPET.payloads.CorpTag[]> {
2186
- log.verbose('PuppetService', 'corpTagContactTagList(%s)', contactId)
2138
+ ): Promise<PUPPET.payloads.Tag[]> {
2139
+ log.verbose('PuppetService', 'tagContactTagList(%s)', contactId)
2187
2140
 
2188
- const request = new grpcPuppet.CorpTagContactTagListRequest()
2141
+ const request = new grpcPuppet.TagContactTagListRequest()
2189
2142
  request.setContactId(contactId)
2190
2143
 
2191
2144
  const result = await util.promisify(
2192
- this.grpcManager.client.corpTagContactTagList
2145
+ this.grpcManager.client.tagContactTagList
2193
2146
  .bind(this.grpcManager.client),
2194
2147
  )(request)
2195
2148
 
2196
2149
  const grpcPayloads = result.getPayloadsList()
2197
- const payloads: PUPPET.payloads.CorpTag[] = grpcPayloads.map(payload => {
2150
+ const payloads: PUPPET.payloads.Tag[] = grpcPayloads.map(payload => {
2198
2151
  return {
2199
2152
  id: payload.getId(),
2200
2153
  name: payload.getName(),
2201
2154
  groupId: payload.getGroupId(),
2202
- } as PUPPET.payloads.CorpTag
2155
+ type: payload.getType(),
2156
+ } as PUPPET.payloads.Tag
2203
2157
  })
2204
2158
  return payloads
2205
2159
  }
2206
2160
 
2161
+ override async tagTagContactList (
2162
+ tagGroupId: string | undefined,
2163
+ tagId: string,
2164
+ ): Promise<string[]> {
2165
+ log.verbose('PuppetService', 'tagTagContactList(%s, %s)', tagGroupId, tagId)
2166
+
2167
+ const request = new grpcPuppet.TagTagContactListRequest()
2168
+ if (typeof tagGroupId !== 'undefined') {
2169
+ request.setTagGroupId(tagGroupId)
2170
+ }
2171
+ request.setTagId(tagId)
2172
+
2173
+ const result = await util.promisify(
2174
+ this.grpcManager.client.tagTagContactList
2175
+ .bind(this.grpcManager.client),
2176
+ )(request)
2177
+
2178
+ const payloads = result.getPayloadsList()
2179
+ return payloads
2180
+ }
2181
+
2207
2182
  /**
2208
2183
  * @deprecated Will be removed in v2.0
2209
2184
  */
@@ -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.14",
7
+ "version": "1.0.16",
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.9"
72
+ "@juzi/wechaty-puppet": "^1.0.12"
73
73
  },
74
74
  "dependencies": {
75
- "@juzi/wechaty-grpc": "1.0.9",
75
+ "@juzi/wechaty-grpc": "^1.0.11",
76
76
  "clone-class": "^1.1.1",
77
77
  "ducks": "^1.0.2",
78
78
  "file-box": "^1.5.5",