@nest-packages/nestjs-lark-sdk 0.1.0 → 0.1.1

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 (53) hide show
  1. package/dist/bitable-base-field.d.ts +177 -0
  2. package/dist/bitable-base-field.js +188 -0
  3. package/dist/bitable-base-field.js.map +1 -0
  4. package/dist/bitable-base-record.d.ts +211 -0
  5. package/dist/bitable-base-record.js +276 -0
  6. package/dist/bitable-base-record.js.map +1 -0
  7. package/dist/bitable-base.abstract.d.ts +18 -0
  8. package/dist/bitable-base.abstract.js +68 -0
  9. package/dist/bitable-base.abstract.js.map +1 -0
  10. package/dist/contact-base.d.ts +333 -0
  11. package/dist/contact-base.js +238 -0
  12. package/dist/contact-base.js.map +1 -0
  13. package/dist/feishu-base-plus.d.ts +19 -0
  14. package/dist/feishu-base-plus.js +187 -0
  15. package/dist/feishu-base-plus.js.map +1 -0
  16. package/dist/feishu-code.d.ts +22 -0
  17. package/dist/feishu-code.js +26 -0
  18. package/dist/feishu-code.js.map +1 -0
  19. package/dist/feishu.constants.d.ts +2 -0
  20. package/dist/feishu.constants.js +6 -0
  21. package/dist/feishu.constants.js.map +1 -0
  22. package/dist/feishu.utils.d.ts +5 -0
  23. package/dist/feishu.utils.js +23 -0
  24. package/dist/feishu.utils.js.map +1 -0
  25. package/dist/im-base.config.d.ts +3 -0
  26. package/dist/im-base.config.js +18 -0
  27. package/dist/im-base.config.js.map +1 -0
  28. package/dist/im-base.d.ts +96 -0
  29. package/dist/im-base.js +270 -0
  30. package/dist/im-base.js.map +1 -0
  31. package/dist/im-base.type.d.ts +19 -0
  32. package/dist/im-base.type.js +3 -0
  33. package/dist/im-base.type.js.map +1 -0
  34. package/dist/index.d.ts +8 -0
  35. package/dist/index.js +25 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/nestjs-lark-sdk.module.d.ts +9 -0
  38. package/dist/nestjs-lark-sdk.module.js +95 -0
  39. package/dist/nestjs-lark-sdk.module.js.map +1 -0
  40. package/dist/nestjs-lark-sdk.service.d.ts +2 -0
  41. package/dist/nestjs-lark-sdk.service.js +17 -0
  42. package/dist/nestjs-lark-sdk.service.js.map +1 -0
  43. package/dist/tsconfig.build.tsbuildinfo +1 -0
  44. package/dist/type.bitable.d.ts +9 -0
  45. package/dist/type.bitable.js +3 -0
  46. package/dist/type.bitable.js.map +1 -0
  47. package/dist/type.d.ts +63 -0
  48. package/dist/type.js +3 -0
  49. package/dist/type.js.map +1 -0
  50. package/dist/types/index.d.ts +168 -0
  51. package/dist/types/index.js +3 -0
  52. package/dist/types/index.js.map +1 -0
  53. package/package.json +13 -6
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeishuBasePlus = void 0;
4
+ const node_sdk_1 = require("@larksuiteoapi/node-sdk");
5
+ const common_1 = require("@nestjs/common");
6
+ const axios_1 = require("axios");
7
+ const axios_retry_1 = require("axios-retry");
8
+ const http = require("http");
9
+ const uuid_1 = require("uuid");
10
+ const feishu_code_1 = require("./feishu-code");
11
+ class FeishuBasePlus {
12
+ constructor(larkClientParams, larkClientCardActionHandler) {
13
+ var _a, _b;
14
+ this.logger = new common_1.Logger(FeishuBasePlus.name);
15
+ const appId = larkClientParams.appId;
16
+ const appSecret = larkClientParams.appSecret;
17
+ if (!appId || !appSecret) {
18
+ throw new Error('appId or appSecret is required');
19
+ }
20
+ if ((_a = FeishuBasePlus.instance) === null || _a === void 0 ? void 0 : _a.get(appId)) {
21
+ return (_b = FeishuBasePlus.instance) === null || _b === void 0 ? void 0 : _b.get(appId);
22
+ }
23
+ this.appId = appId;
24
+ this.appSecret = appSecret;
25
+ this.logger.debug(`FeishuBase appId: ${appId}`);
26
+ const verificationToken = larkClientCardActionHandler === null || larkClientCardActionHandler === void 0 ? void 0 : larkClientCardActionHandler.verificationToken;
27
+ const encryptKey = larkClientCardActionHandler === null || larkClientCardActionHandler === void 0 ? void 0 : larkClientCardActionHandler.encryptKey;
28
+ this.verificationToken = verificationToken;
29
+ this.encryptKey = encryptKey;
30
+ this.main();
31
+ FeishuBasePlus.instance.set(appId, this);
32
+ Object.freeze(FeishuBasePlus);
33
+ }
34
+ main() {
35
+ this.initLarkClient();
36
+ this.initEventDispatcher();
37
+ this.initCardDispatcher();
38
+ }
39
+ initLarkClient() {
40
+ const appId = this.appId;
41
+ const appSecret = this.appSecret;
42
+ const logger = this.logger;
43
+ if (!this.larkClient) {
44
+ const httpInstance = axios_1.default.create();
45
+ (0, axios_retry_1.default)(httpInstance, {
46
+ retries: 3,
47
+ onRetry(_retryCount, error, _requestConfig) {
48
+ logger.debug(`onRetry 重试第 ${_retryCount} 次`, error === null || error === void 0 ? void 0 : error.stack, _requestConfig);
49
+ },
50
+ retryCondition: (error) => {
51
+ var _a, _b, _c;
52
+ const code = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.code;
53
+ logger.debug(`retryCondition error?.response?.status ${(_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.status} code: ${code}`);
54
+ return (axios_retry_1.default.isNetworkOrIdempotentRequestError(error) ||
55
+ error.code === 'ECONNABORTED' ||
56
+ [
57
+ feishu_code_1.CODE_FREQUENCY_LIMIT,
58
+ feishu_code_1.CODE_FAIL,
59
+ feishu_code_1.DATA_NOT_READY,
60
+ feishu_code_1.CODE_WRITE_CONFLICT,
61
+ feishu_code_1.TooManyRequest,
62
+ ].includes(code));
63
+ },
64
+ onMaxRetryTimesExceeded(err, retryCount) {
65
+ logger.debug(`onMaxRetryTimesExceeded 重试总次数 ${retryCount}`);
66
+ },
67
+ retryDelay: (retryCount) => {
68
+ return retryCount * 1000;
69
+ },
70
+ });
71
+ httpInstance.interceptors.request.use((req) => {
72
+ var _a;
73
+ const requestId = (req.headers['x-request-id'] || (0, uuid_1.v4)()).substring(0, 8);
74
+ if (req.headers) {
75
+ req.headers['User-Agent'] = 'oapi-node-sdk/1.0.0 custom';
76
+ req.headers['x-request-id'] = requestId;
77
+ }
78
+ const { method, url, data, params, headers } = req;
79
+ if (!headers['x-ignore-log']) {
80
+ if (method.toUpperCase() === 'GET') {
81
+ logger.log(`[${requestId}] GET 请求 ${url} 的查询参数:`, params);
82
+ }
83
+ else if (method.toUpperCase() === 'POST') {
84
+ const dataCopy = Object.assign({}, data);
85
+ if (dataCopy['app_secret']) {
86
+ dataCopy['app_secret'] = '***';
87
+ }
88
+ if ((_a = dataCopy['records']) === null || _a === void 0 ? void 0 : _a.length) {
89
+ dataCopy['records'] = [dataCopy['records'][0]];
90
+ }
91
+ logger.log(`[${requestId}] POST 请求 ${url} 的请求体参数:`, dataCopy);
92
+ }
93
+ }
94
+ return req;
95
+ }, (error) => {
96
+ var _a;
97
+ logger.error(`interceptors.request.error`, error === null || error === void 0 ? void 0 : error.stack, (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
98
+ }, { synchronous: true });
99
+ httpInstance.interceptors.response.use((response) => {
100
+ var _a, _b, _c, _d;
101
+ if (!((response === null || response === void 0 ? void 0 : response.data) instanceof http.IncomingMessage) &&
102
+ ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.code) !== feishu_code_1.CODE_SUCCESS) {
103
+ const requestId = (_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-request-id'];
104
+ const errorData = {
105
+ response: {
106
+ code: (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.code,
107
+ msg: (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.msg,
108
+ },
109
+ request: {
110
+ url: response.config.url,
111
+ data: response.config.data,
112
+ params: response.config.params,
113
+ requestId: requestId,
114
+ method: response.config.method,
115
+ },
116
+ };
117
+ logger.error(`FeishuBasePlus 公共请求返回不为 0 [${requestId}]`, errorData);
118
+ }
119
+ return response === null || response === void 0 ? void 0 : response.data;
120
+ }, (error) => {
121
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
122
+ const requestId = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b['x-request-id'];
123
+ const response = error === null || error === void 0 ? void 0 : error.response;
124
+ const errorData = {
125
+ request: {
126
+ headers: (_c = error === null || error === void 0 ? void 0 : error.config) === null || _c === void 0 ? void 0 : _c.headers,
127
+ data: (_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.data,
128
+ url: (_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.url,
129
+ params: (_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.params,
130
+ method: (_g = error === null || error === void 0 ? void 0 : error.config) === null || _g === void 0 ? void 0 : _g.method,
131
+ requestId,
132
+ },
133
+ response: {
134
+ data: (_h = response === null || response === void 0 ? void 0 : response.data) === null || _h === void 0 ? void 0 : _h.data,
135
+ code: (_j = response === null || response === void 0 ? void 0 : response.data) === null || _j === void 0 ? void 0 : _j.code,
136
+ msg: (_k = response === null || response === void 0 ? void 0 : response.data) === null || _k === void 0 ? void 0 : _k.msg,
137
+ },
138
+ };
139
+ logger.error(`interceptors.response.error [${requestId}]`, error === null || error === void 0 ? void 0 : error.stack, (_l = error === null || error === void 0 ? void 0 : error.response) === null || _l === void 0 ? void 0 : _l.data, errorData);
140
+ });
141
+ const client = new node_sdk_1.Client({
142
+ appId,
143
+ appSecret,
144
+ appType: node_sdk_1.AppType.SelfBuild,
145
+ domain: node_sdk_1.Domain.Feishu,
146
+ httpInstance,
147
+ loggerLevel: node_sdk_1.LoggerLevel.error,
148
+ disableTokenCache: false,
149
+ });
150
+ this.larkClient = client;
151
+ this.logger.debug(`${appId} larkClient init success`);
152
+ }
153
+ }
154
+ initEventDispatcher() {
155
+ const encryptKey = this.encryptKey;
156
+ const verificationToken = this.verificationToken;
157
+ if (!encryptKey || !verificationToken) {
158
+ this.logger.warn('encryptKey or verificationToken is not set');
159
+ return;
160
+ }
161
+ if (!this.eventDispatcher) {
162
+ this.eventDispatcher = new node_sdk_1.EventDispatcher({
163
+ encryptKey,
164
+ verificationToken,
165
+ });
166
+ }
167
+ }
168
+ initCardDispatcher() {
169
+ const encryptKey = this.encryptKey;
170
+ const verificationToken = this.verificationToken;
171
+ if (!encryptKey || !verificationToken) {
172
+ this.logger.warn('encryptKey or verificationToken is not set');
173
+ return;
174
+ }
175
+ if (!this.cardDispatcher) {
176
+ this.cardDispatcher = new node_sdk_1.CardActionHandler({
177
+ encryptKey,
178
+ verificationToken,
179
+ }, async (data) => {
180
+ this.logger.log('cardDispatcher', data);
181
+ });
182
+ }
183
+ }
184
+ }
185
+ exports.FeishuBasePlus = FeishuBasePlus;
186
+ FeishuBasePlus.instance = new Map();
187
+ //# sourceMappingURL=feishu-base-plus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feishu-base-plus.js","sourceRoot":"","sources":["../src/feishu-base-plus.ts"],"names":[],"mappings":";;;AAAA,sDAQiC;AACjC,2CAAwC;AACxC,iCAA6C;AAC7C,6CAAqC;AACrC,6BAA6B;AAC7B,+BAAoC;AACpC,+CAOuB;AAOvB,MAAa,cAAc;IAYzB,YACE,gBAAsC,EACtC,2BAA6D;;QAb5C,WAAM,GAAG,IAAI,eAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAe1D,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC;QACrC,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC;QAC7C,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,MAAA,cAAc,CAAC,QAAQ,0CAAE,GAAG,CAAC,KAAK,CAAC,EAA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export declare const CODE_WRITE_CONFLICT = 1254291;
4
+ export declare const CODE_RPC_ERROR = 1255002;
5
+ export declare const CODE_IP_DENIED = 99991401;
6
+ export declare const CODE_SUCCESS = 0;
7
+ export declare const CODE_FREQUENCY_LIMIT = 99991400;
8
+ export declare const CODE_FieldNameDuplicated = 1254014;
9
+ export declare const MESSAGE_IS_BEING_SENT = 230049;
10
+ export declare const RecordExceedLimit = 1254103;
11
+ export declare const INTERNAL_ERROR = 1241001;
12
+ export declare const internalError = 2200;
13
+ export declare const CHAT_BEEN_DISSOLVED = 232009;
14
+ export declare const BOT_NOT_IN_CHAT = 232011;
15
+ export declare const FieldNameNotFound = 1254045;
16
+ export declare const RESOURCE_NOT_FOUND = 131005;
17
+ export declare const MESSAGE_HAS_EXPIRED = 230031;
18
+ export declare const NumberFieldConvFail = 1254061;
19
+ export declare const InternalErrorInner = 40003;
20
+ export declare const TooManyRequest = 1254290;
21
+ export declare const UserFieldConvFail = 1254066;
22
+ export declare const TextFieldConvFail = 1254060;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextFieldConvFail = exports.UserFieldConvFail = exports.TooManyRequest = exports.InternalErrorInner = exports.NumberFieldConvFail = exports.MESSAGE_HAS_EXPIRED = exports.RESOURCE_NOT_FOUND = exports.FieldNameNotFound = exports.BOT_NOT_IN_CHAT = exports.CHAT_BEEN_DISSOLVED = exports.internalError = exports.INTERNAL_ERROR = exports.RecordExceedLimit = exports.MESSAGE_IS_BEING_SENT = exports.CODE_FieldNameDuplicated = exports.CODE_FREQUENCY_LIMIT = exports.CODE_SUCCESS = exports.CODE_IP_DENIED = exports.CODE_RPC_ERROR = exports.CODE_WRITE_CONFLICT = exports.CODE_FAIL = exports.DATA_NOT_READY = void 0;
4
+ exports.DATA_NOT_READY = 1254607;
5
+ exports.CODE_FAIL = 1254002;
6
+ exports.CODE_WRITE_CONFLICT = 1254291;
7
+ exports.CODE_RPC_ERROR = 1255002;
8
+ exports.CODE_IP_DENIED = 99991401;
9
+ exports.CODE_SUCCESS = 0;
10
+ exports.CODE_FREQUENCY_LIMIT = 99991400;
11
+ exports.CODE_FieldNameDuplicated = 1254014;
12
+ exports.MESSAGE_IS_BEING_SENT = 230049;
13
+ exports.RecordExceedLimit = 1254103;
14
+ exports.INTERNAL_ERROR = 1241001;
15
+ exports.internalError = 2200;
16
+ exports.CHAT_BEEN_DISSOLVED = 232009;
17
+ exports.BOT_NOT_IN_CHAT = 232011;
18
+ exports.FieldNameNotFound = 1254045;
19
+ exports.RESOURCE_NOT_FOUND = 131005;
20
+ exports.MESSAGE_HAS_EXPIRED = 230031;
21
+ exports.NumberFieldConvFail = 1254061;
22
+ exports.InternalErrorInner = 40003;
23
+ exports.TooManyRequest = 1254290;
24
+ exports.UserFieldConvFail = 1254066;
25
+ exports.TextFieldConvFail = 1254060;
26
+ //# sourceMappingURL=feishu-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feishu-code.js","sourceRoot":"","sources":["../src/feishu-code.ts"],"names":[],"mappings":";;;AAMa,QAAA,cAAc,GAAG,OAAO,CAAC;AAGzB,QAAA,SAAS,GAAG,OAAO,CAAC;AAEpB,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAE9B,QAAA,cAAc,GAAG,OAAO,CAAC;AAEzB,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,YAAY,GAAG,CAAC,CAAC;AAIjB,QAAA,oBAAoB,GAAG,QAAQ,CAAC;AAEhC,QAAA,wBAAwB,GAAG,OAAO,CAAC;AACnC,QAAA,qBAAqB,GAAG,MAAM,CAAC;AAC/B,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAG5B,QAAA,cAAc,GAAG,OAAO,CAAC;AACzB,QAAA,aAAa,GAAG,IAAI,CAAC;AACrB,QAAA,mBAAmB,GAAG,MAAM,CAAC;AAC7B,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAC5B,QAAA,kBAAkB,GAAG,MAAM,CAAC;AAC5B,QAAA,mBAAmB,GAAG,MAAM,CAAC;AAC7B,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAE9B,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAE3B,QAAA,cAAc,GAAG,OAAO,CAAC;AACzB,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAC5B,QAAA,iBAAiB,GAAG,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const MODULE_INSTANCE: unique symbol;
2
+ export declare const MODULE_OPTIONS: unique symbol;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MODULE_OPTIONS = exports.MODULE_INSTANCE = void 0;
4
+ exports.MODULE_INSTANCE = Symbol('MODULE_INSTANCE');
5
+ exports.MODULE_OPTIONS = Symbol('MODULE_OPTIONS');
6
+ //# sourceMappingURL=feishu.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feishu.constants.js","sourceRoot":"","sources":["../src/feishu.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC5C,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { FeishuBasePlus } from './feishu-base-plus';
2
+ import { NestjsLarkSdkModuleOptions } from './types';
3
+ export declare function getFeishuModuleInstanceToken(moduleName?: string): string | symbol;
4
+ export declare function getFeishuModuleOptionsToken(moduleName?: string): string | symbol;
5
+ export declare function getFeishuModuleInstance(options: NestjsLarkSdkModuleOptions): FeishuBasePlus;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFeishuModuleInstanceToken = getFeishuModuleInstanceToken;
4
+ exports.getFeishuModuleOptionsToken = getFeishuModuleOptionsToken;
5
+ exports.getFeishuModuleInstance = getFeishuModuleInstance;
6
+ const feishu_base_plus_1 = require("./feishu-base-plus");
7
+ const feishu_constants_1 = require("./feishu.constants");
8
+ function getFeishuModuleInstanceToken(moduleName) {
9
+ if (moduleName) {
10
+ return `${moduleName}`;
11
+ }
12
+ return feishu_constants_1.MODULE_INSTANCE;
13
+ }
14
+ function getFeishuModuleOptionsToken(moduleName) {
15
+ if (moduleName) {
16
+ return `${moduleName}_options`;
17
+ }
18
+ return feishu_constants_1.MODULE_OPTIONS;
19
+ }
20
+ function getFeishuModuleInstance(options) {
21
+ return new feishu_base_plus_1.FeishuBasePlus(options.LarkClientParams, options.LarkEventDispatcherParams);
22
+ }
23
+ //# sourceMappingURL=feishu.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feishu.utils.js","sourceRoot":"","sources":["../src/feishu.utils.ts"],"names":[],"mappings":";;AAIA,oEAOC;AAED,kEAOC;AAED,0DAKC;AA3BD,yDAAoD;AACpD,yDAAqE;AAGrE,SAAgB,4BAA4B,CAC1C,UAAmB;IAEnB,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,GAAG,UAAU,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,kCAAe,CAAC;AACzB,CAAC;AAED,SAAgB,2BAA2B,CACzC,UAAmB;IAEnB,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,GAAG,UAAU,UAAU,CAAC;IACjC,CAAC;IACD,OAAO,iCAAc,CAAC;AACxB,CAAC;AAED,SAAgB,uBAAuB,CAAC,OAAmC;IACzE,OAAO,IAAI,iCAAc,CACvB,OAAO,CAAC,gBAAgB,EACxB,OAAO,CAAC,yBAAyB,CAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { imChatCreateDataType, imChatCreateParamsType } from './im-base.type';
2
+ export declare const imChatCreateDataDefault: imChatCreateDataType;
3
+ export declare const imChatCreateParamsDefault: imChatCreateParamsType;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.imChatCreateParamsDefault = exports.imChatCreateDataDefault = void 0;
4
+ exports.imChatCreateDataDefault = {
5
+ avatar: 'default-avatar_44ae0ca3-e140-494b-956f-78091e348435',
6
+ description: '内部客户沟通群',
7
+ chat_mode: 'group',
8
+ chat_type: 'private',
9
+ external: false,
10
+ join_message_visibility: 'all_members',
11
+ leave_message_visibility: 'all_members',
12
+ membership_approval: 'no_approval_required',
13
+ };
14
+ exports.imChatCreateParamsDefault = {
15
+ user_id_type: 'open_id',
16
+ set_bot_manager: true,
17
+ };
18
+ //# sourceMappingURL=im-base.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"im-base.config.js","sourceRoot":"","sources":["../src/im-base.config.ts"],"names":[],"mappings":";;;AAGa,QAAA,uBAAuB,GAAyB;IAE3D,MAAM,EAAE,qDAAqD;IAC7D,WAAW,EAAE,SAAS;IACtB,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,KAAK;IACf,uBAAuB,EAAE,aAAa;IACtC,wBAAwB,EAAE,aAAa;IACvC,mBAAmB,EAAE,sBAAsB;CAC5C,CAAC;AACW,QAAA,yBAAyB,GAA2B;IAC/D,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,IAAI;CAEtB,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { FeishuBasePlus } from './feishu-base-plus';
2
+ import { imChatCreateDataType, imChatCreateParamsType } from './im-base.type';
3
+ export declare class ImBase {
4
+ private readonly logger;
5
+ feishuBaseInstance: FeishuBasePlus;
6
+ constructor(feishuBaseInstance: FeishuBasePlus);
7
+ getImMessageList(container_id: string, start_time: string): Promise<any[]>;
8
+ getImChatList(): Promise<{
9
+ chat_id?: string | undefined;
10
+ avatar?: string | undefined;
11
+ name?: string | undefined;
12
+ description?: string | undefined;
13
+ owner_id?: string | undefined;
14
+ owner_id_type?: string | undefined;
15
+ external?: boolean | undefined;
16
+ tenant_key?: string | undefined;
17
+ labels?: string[] | undefined;
18
+ chat_status?: "normal" | "dissolved" | "dissolved_save" | undefined;
19
+ }[]>;
20
+ chatCreate(imChatCreateData: imChatCreateDataType, imChatCreateParams: imChatCreateParamsType): Promise<{
21
+ code?: number | undefined;
22
+ msg?: string | undefined;
23
+ data?: {
24
+ chat_id?: string | undefined;
25
+ avatar?: string | undefined;
26
+ name?: string | undefined;
27
+ description?: string | undefined;
28
+ i18n_names?: {
29
+ zh_cn?: string | undefined;
30
+ en_us?: string | undefined;
31
+ ja_jp?: string | undefined;
32
+ } | undefined;
33
+ owner_id?: string | undefined;
34
+ owner_id_type?: string | undefined;
35
+ urgent_setting?: "all_members" | "only_owner" | undefined;
36
+ video_conference_setting?: "all_members" | "only_owner" | undefined;
37
+ pin_manage_setting?: "all_members" | "only_owner" | undefined;
38
+ add_member_permission?: string | undefined;
39
+ share_card_permission?: string | undefined;
40
+ at_all_permission?: string | undefined;
41
+ edit_permission?: string | undefined;
42
+ group_message_type?: string | undefined;
43
+ chat_mode?: string | undefined;
44
+ chat_type?: string | undefined;
45
+ chat_tag?: string | undefined;
46
+ external?: boolean | undefined;
47
+ tenant_key?: string | undefined;
48
+ join_message_visibility?: string | undefined;
49
+ leave_message_visibility?: string | undefined;
50
+ membership_approval?: string | undefined;
51
+ moderation_permission?: string | undefined;
52
+ labels?: string[] | undefined;
53
+ toolkit_ids?: string[] | undefined;
54
+ restricted_mode_setting?: {
55
+ status?: boolean | undefined;
56
+ screenshot_has_permission_setting?: "all_members" | "not_anyone" | undefined;
57
+ download_has_permission_setting?: "all_members" | "not_anyone" | undefined;
58
+ message_has_permission_setting?: "all_members" | "not_anyone" | undefined;
59
+ } | undefined;
60
+ hide_member_count_setting?: "all_members" | "only_owner" | undefined;
61
+ } | undefined;
62
+ }>;
63
+ getChatLink(chatId: string): Promise<{
64
+ code?: number | undefined;
65
+ msg?: string | undefined;
66
+ data?: {
67
+ share_link?: string | undefined;
68
+ expire_time?: string | undefined;
69
+ is_permanent?: boolean | undefined;
70
+ } | undefined;
71
+ }>;
72
+ getGroupMemberList(chatId: string): Promise<{
73
+ member_id_type?: string | undefined;
74
+ member_id?: string | undefined;
75
+ name?: string | undefined;
76
+ tenant_key?: string | undefined;
77
+ }[]>;
78
+ getUserByMobile(mobiles: string[]): Promise<{
79
+ union_id: string;
80
+ nickname: string;
81
+ name: string;
82
+ mobile: string;
83
+ user_id: string;
84
+ open_id: string;
85
+ }[]>;
86
+ batchUser(user_ids: string[], user_id_type?: 'open_id' | 'union_id' | 'user_id'): Promise<{
87
+ union_id: string;
88
+ nickname: string;
89
+ name: string;
90
+ mobile: string;
91
+ user_id: string;
92
+ open_id: string;
93
+ }[]>;
94
+ getUuid(content: string | object): string;
95
+ sendFeishuMessage(title: string, content: string, messageReceiveList: string[], type?: 'error' | 'info' | 'warn'): Promise<void>;
96
+ }