@urugus/slack-cli 0.2.2 → 0.2.4
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.
- package/.claude/settings.local.json +2 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +7 -4
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/unread.d.ts.map +1 -1
- package/dist/commands/unread.js +17 -21
- package/dist/commands/unread.js.map +1 -1
- package/dist/utils/config/config-file-manager.d.ts +13 -0
- package/dist/utils/config/config-file-manager.d.ts.map +1 -0
- package/dist/utils/config/config-file-manager.js +85 -0
- package/dist/utils/config/config-file-manager.js.map +1 -0
- package/dist/utils/config/profile-manager.d.ts +16 -0
- package/dist/utils/config/profile-manager.d.ts.map +1 -0
- package/dist/utils/config/profile-manager.js +64 -0
- package/dist/utils/config/profile-manager.js.map +1 -0
- package/dist/utils/config/token-crypto-service.d.ts +11 -0
- package/dist/utils/config/token-crypto-service.d.ts.map +1 -0
- package/dist/utils/config/token-crypto-service.js +111 -0
- package/dist/utils/config/token-crypto-service.js.map +1 -0
- package/dist/utils/format-utils.d.ts.map +1 -1
- package/dist/utils/format-utils.js +2 -1
- package/dist/utils/format-utils.js.map +1 -1
- package/dist/utils/formatters/base-formatter.d.ts +23 -0
- package/dist/utils/formatters/base-formatter.d.ts.map +1 -0
- package/dist/utils/formatters/base-formatter.js +26 -0
- package/dist/utils/formatters/base-formatter.js.map +1 -0
- package/dist/utils/formatters/channel-formatters.d.ts +4 -13
- package/dist/utils/formatters/channel-formatters.d.ts.map +1 -1
- package/dist/utils/formatters/channel-formatters.js +18 -26
- package/dist/utils/formatters/channel-formatters.js.map +1 -1
- package/dist/utils/formatters/channels-list-formatters.d.ts +3 -10
- package/dist/utils/formatters/channels-list-formatters.d.ts.map +1 -1
- package/dist/utils/formatters/channels-list-formatters.js +15 -22
- package/dist/utils/formatters/channels-list-formatters.js.map +1 -1
- package/dist/utils/formatters/message-formatters.d.ts +9 -0
- package/dist/utils/formatters/message-formatters.d.ts.map +1 -0
- package/dist/utils/formatters/message-formatters.js +72 -0
- package/dist/utils/formatters/message-formatters.js.map +1 -0
- package/dist/utils/mention-utils.d.ts +17 -0
- package/dist/utils/mention-utils.d.ts.map +1 -0
- package/dist/utils/mention-utils.js +45 -0
- package/dist/utils/mention-utils.js.map +1 -0
- package/dist/utils/option-parsers.d.ts +47 -0
- package/dist/utils/option-parsers.d.ts.map +1 -0
- package/dist/utils/option-parsers.js +75 -0
- package/dist/utils/option-parsers.js.map +1 -0
- package/dist/utils/profile-config-refactored.d.ts +20 -0
- package/dist/utils/profile-config-refactored.d.ts.map +1 -0
- package/dist/utils/profile-config-refactored.js +174 -0
- package/dist/utils/profile-config-refactored.js.map +1 -0
- package/dist/utils/slack-operations/message-operations.d.ts.map +1 -1
- package/dist/utils/slack-operations/message-operations.js +3 -2
- package/dist/utils/slack-operations/message-operations.js.map +1 -1
- package/dist/utils/slack-patterns.d.ts +6 -0
- package/dist/utils/slack-patterns.d.ts.map +1 -0
- package/dist/utils/slack-patterns.js +11 -0
- package/dist/utils/slack-patterns.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/channels.ts +7 -4
- package/src/commands/unread.ts +18 -21
- package/src/utils/config/config-file-manager.ts +56 -0
- package/src/utils/config/profile-manager.ts +79 -0
- package/src/utils/config/token-crypto-service.ts +80 -0
- package/src/utils/format-utils.ts +3 -1
- package/src/utils/formatters/base-formatter.ts +34 -0
- package/src/utils/formatters/channel-formatters.ts +25 -23
- package/src/utils/formatters/channels-list-formatters.ts +27 -31
- package/src/utils/formatters/message-formatters.ts +85 -0
- package/src/utils/mention-utils.ts +47 -0
- package/src/utils/option-parsers.ts +100 -0
- package/src/utils/profile-config-refactored.ts +161 -0
- package/src/utils/slack-operations/message-operations.ts +3 -2
- package/src/utils/slack-patterns.ts +9 -0
- package/tests/commands/unread.test.ts +112 -0
- package/tests/utils/config/config-file-manager.test.ts +118 -0
- package/tests/utils/config/profile-manager.test.ts +266 -0
- package/tests/utils/config/token-crypto-service.test.ts +98 -0
- package/tests/utils/mention-utils.test.ts +100 -0
- package/tests/utils/slack-operations/message-operations.test.ts +126 -0
|
@@ -3,14 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ChannelCountFormatter = exports.ChannelJsonFormatter = exports.ChannelSimpleFormatter = exports.ChannelTableFormatter = void 0;
|
|
7
6
|
exports.createChannelFormatter = createChannelFormatter;
|
|
8
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const
|
|
8
|
+
const base_formatter_1 = require("./base-formatter");
|
|
10
9
|
const channel_formatter_1 = require("../channel-formatter");
|
|
11
10
|
const date_utils_1 = require("../date-utils");
|
|
12
|
-
class ChannelTableFormatter extends
|
|
13
|
-
format(channels) {
|
|
11
|
+
class ChannelTableFormatter extends base_formatter_1.AbstractFormatter {
|
|
12
|
+
format({ channels }) {
|
|
14
13
|
console.log(chalk_1.default.bold('Channel Unread Last Message'));
|
|
15
14
|
console.log('─'.repeat(50));
|
|
16
15
|
channels.forEach((channel) => {
|
|
@@ -22,29 +21,25 @@ class ChannelTableFormatter extends output_formatter_1.BaseFormatter {
|
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
format(channels) {
|
|
24
|
+
class ChannelSimpleFormatter extends base_formatter_1.AbstractFormatter {
|
|
25
|
+
format({ channels }) {
|
|
28
26
|
channels.forEach((channel) => {
|
|
29
27
|
const channelName = (0, channel_formatter_1.formatChannelName)(channel.name);
|
|
30
28
|
console.log(`${channelName} (${channel.unread_count || 0})`);
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const output = channels.map((channel) => ({
|
|
32
|
+
class ChannelJsonFormatter extends base_formatter_1.JsonFormatter {
|
|
33
|
+
transform({ channels }) {
|
|
34
|
+
return channels.map((channel) => ({
|
|
38
35
|
channel: (0, channel_formatter_1.formatChannelName)(channel.name),
|
|
39
36
|
channelId: channel.id,
|
|
40
37
|
unreadCount: channel.unread_count || 0,
|
|
41
38
|
}));
|
|
42
|
-
console.log(JSON.stringify(output, null, 2));
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
format(channels) {
|
|
41
|
+
class ChannelCountFormatter extends base_formatter_1.AbstractFormatter {
|
|
42
|
+
format({ channels }) {
|
|
48
43
|
let totalUnread = 0;
|
|
49
44
|
channels.forEach((channel) => {
|
|
50
45
|
const count = channel.unread_count || 0;
|
|
@@ -55,19 +50,16 @@ class ChannelCountFormatter extends output_formatter_1.BaseFormatter {
|
|
|
55
50
|
console.log(chalk_1.default.bold(`Total: ${totalUnread} unread messages`));
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
|
-
|
|
53
|
+
const channelFormatterFactory = (0, base_formatter_1.createFormatterFactory)({
|
|
54
|
+
table: new ChannelTableFormatter(),
|
|
55
|
+
simple: new ChannelSimpleFormatter(),
|
|
56
|
+
json: new ChannelJsonFormatter(),
|
|
57
|
+
count: new ChannelCountFormatter(),
|
|
58
|
+
});
|
|
59
59
|
function createChannelFormatter(format, countOnly) {
|
|
60
60
|
if (countOnly) {
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
switch (format) {
|
|
64
|
-
case 'json':
|
|
65
|
-
return new ChannelJsonFormatter();
|
|
66
|
-
case 'simple':
|
|
67
|
-
return new ChannelSimpleFormatter();
|
|
68
|
-
case 'table':
|
|
69
|
-
default:
|
|
70
|
-
return new ChannelTableFormatter();
|
|
61
|
+
return channelFormatterFactory.create('count');
|
|
71
62
|
}
|
|
63
|
+
return channelFormatterFactory.create(format);
|
|
72
64
|
}
|
|
73
65
|
//# sourceMappingURL=channel-formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-formatters.js","sourceRoot":"","sources":["../../../src/utils/formatters/channel-formatters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channel-formatters.js","sourceRoot":"","sources":["../../../src/utils/formatters/channel-formatters.ts"],"names":[],"mappings":";;;;;AAiEA,wDAKC;AAtED,kDAA0B;AAC1B,qDAA4F;AAE5F,4DAAyD;AACzD,8CAAqD;AAOrD,MAAM,qBAAsB,SAAQ,kCAA0C;IAC5E,MAAM,CAAC,EAAE,QAAQ,EAA2B;QAC1C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,WAAW,GAAG,IAAA,qCAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,iCAAoB,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACzF,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,sBAAuB,SAAQ,kCAA0C;IAC7E,MAAM,CAAC,EAAE,QAAQ,EAA2B;QAC1C,QAAQ,CAAC,OAAO,CAAC,CAAC,O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C,IAAI,EAAE,IAAI,oBAAoB,EAAE;IAChC,KAAK,EAAE,IAAI,qBAAqB,EAAE;CACnC,CAAC,CAAC;AAEH,SAAgB,sBAAsB,CAAC,MAAc,EAAE,SAAkB;IACvE,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,uBAAuB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { BaseFormatter } from './output-formatter';
|
|
2
1
|
import { ChannelInfo } from '../channel-formatter';
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
export interface ChannelsListFormatterOptions {
|
|
3
|
+
channels: ChannelInfo[];
|
|
5
4
|
}
|
|
6
|
-
export declare
|
|
7
|
-
format(channels: ChannelInfo[]): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class ChannelsJsonFormatter extends BaseFormatter<ChannelInfo> {
|
|
10
|
-
format(channels: ChannelInfo[]): void;
|
|
11
|
-
}
|
|
12
|
-
export declare function createChannelsListFormatter(format: string): BaseFormatter<ChannelInfo>;
|
|
5
|
+
export declare function createChannelsListFormatter(format: string): import("./base-formatter").BaseFormatter<ChannelsListFormatterOptions>;
|
|
13
6
|
//# sourceMappingURL=channels-list-formatters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels-list-formatters.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/channels-list-formatters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channels-list-formatters.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/channels-list-formatters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AA+CD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,0EAEzD"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChannelsJsonFormatter = exports.ChannelsSimpleFormatter = exports.ChannelsTableFormatter = void 0;
|
|
4
3
|
exports.createChannelsListFormatter = createChannelsListFormatter;
|
|
5
|
-
const
|
|
6
|
-
class ChannelsTableFormatter extends
|
|
7
|
-
format(channels) {
|
|
4
|
+
const base_formatter_1 = require("./base-formatter");
|
|
5
|
+
class ChannelsTableFormatter extends base_formatter_1.AbstractFormatter {
|
|
6
|
+
format({ channels }) {
|
|
8
7
|
// Print table header
|
|
9
8
|
console.log('Name Type Members Created Description');
|
|
10
9
|
console.log('─'.repeat(65));
|
|
@@ -19,35 +18,29 @@ class ChannelsTableFormatter extends output_formatter_1.BaseFormatter {
|
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
format(channels) {
|
|
21
|
+
class ChannelsSimpleFormatter extends base_formatter_1.AbstractFormatter {
|
|
22
|
+
format({ channels }) {
|
|
25
23
|
channels.forEach((channel) => console.log(channel.name));
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.log(JSON.stringify(channels.map((channel) => ({
|
|
26
|
+
class ChannelsJsonFormatter extends base_formatter_1.JsonFormatter {
|
|
27
|
+
transform({ channels }) {
|
|
28
|
+
return channels.map((channel) => ({
|
|
32
29
|
id: channel.id,
|
|
33
30
|
name: channel.name,
|
|
34
31
|
type: channel.type,
|
|
35
32
|
members: channel.members,
|
|
36
33
|
created: channel.created + 'T00:00:00Z',
|
|
37
34
|
purpose: channel.purpose,
|
|
38
|
-
}))
|
|
35
|
+
}));
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
|
|
38
|
+
const channelsListFormatterFactory = (0, base_formatter_1.createFormatterFactory)({
|
|
39
|
+
table: new ChannelsTableFormatter(),
|
|
40
|
+
simple: new ChannelsSimpleFormatter(),
|
|
41
|
+
json: new ChannelsJsonFormatter(),
|
|
42
|
+
});
|
|
42
43
|
function createChannelsListFormatter(format) {
|
|
43
|
-
|
|
44
|
-
case 'json':
|
|
45
|
-
return new ChannelsJsonFormatter();
|
|
46
|
-
case 'simple':
|
|
47
|
-
return new ChannelsSimpleFormatter();
|
|
48
|
-
case 'table':
|
|
49
|
-
default:
|
|
50
|
-
return new ChannelsTableFormatter();
|
|
51
|
-
}
|
|
44
|
+
return channelsListFormatterFactory.create(format);
|
|
52
45
|
}
|
|
53
46
|
//# sourceMappingURL=channels-list-formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels-list-formatters.js","sourceRoot":"","sources":["../../../src/utils/formatters/channels-list-formatters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channels-list-formatters.js","sourceRoot":"","sources":["../../../src/utils/formatters/channels-list-formatters.ts"],"names":[],"mappings":";;AAoDA,kEAEC;AAtDD,qDAA4F;AAO5F,MAAM,sBAAuB,SAAQ,kCAA+C;IAClF,MAAM,CAAC,EAAE,QAAQ,EAAgC;QAC/C,qBAAqB;QACrB,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5B,qBAAqB;QACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACrD,MAA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SAAgB,2BAA2B,CAAC,MAAc;IACxD,OAAO,4BAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface MessageFormatterOptions {
|
|
2
|
+
channel: any;
|
|
3
|
+
messages: any[];
|
|
4
|
+
users: Map<string, string>;
|
|
5
|
+
countOnly: boolean;
|
|
6
|
+
format: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function createMessageFormatter(format: string): import("./base-formatter").BaseFormatter<MessageFormatterOptions>;
|
|
9
|
+
//# sourceMappingURL=message-formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-formatters.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/message-formatters.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAsED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,qEAEpD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createMessageFormatter = createMessageFormatter;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const base_formatter_1 = require("./base-formatter");
|
|
9
|
+
const date_utils_1 = require("../date-utils");
|
|
10
|
+
const format_utils_1 = require("../format-utils");
|
|
11
|
+
const channel_formatter_1 = require("../channel-formatter");
|
|
12
|
+
class TableMessageFormatter extends base_formatter_1.AbstractFormatter {
|
|
13
|
+
format(options) {
|
|
14
|
+
const { channel, messages, users, countOnly } = options;
|
|
15
|
+
const channelName = (0, channel_formatter_1.formatChannelName)(channel.name);
|
|
16
|
+
console.log(chalk_1.default.bold(`${channelName}: ${channel.unread_count || 0} unread messages`));
|
|
17
|
+
if (!countOnly && messages.length > 0) {
|
|
18
|
+
console.log('');
|
|
19
|
+
messages.forEach((message) => {
|
|
20
|
+
const timestamp = (0, date_utils_1.formatSlackTimestamp)(message.ts);
|
|
21
|
+
const author = message.user ? users.get(message.user) || message.user : 'unknown';
|
|
22
|
+
console.log(`${chalk_1.default.gray(timestamp)} ${chalk_1.default.cyan(author)}`);
|
|
23
|
+
const text = message.text ? (0, format_utils_1.formatMessageWithMentions)(message.text, users) : '(no text)';
|
|
24
|
+
console.log(text);
|
|
25
|
+
console.log('');
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class SimpleMessageFormatter extends base_formatter_1.AbstractFormatter {
|
|
31
|
+
format(options) {
|
|
32
|
+
const { channel, messages, users, countOnly } = options;
|
|
33
|
+
const channelName = (0, channel_formatter_1.formatChannelName)(channel.name);
|
|
34
|
+
console.log(`${channelName} (${channel.unread_count || 0})`);
|
|
35
|
+
if (!countOnly && messages.length > 0) {
|
|
36
|
+
messages.forEach((message) => {
|
|
37
|
+
const timestamp = (0, date_utils_1.formatSlackTimestamp)(message.ts);
|
|
38
|
+
const author = message.user ? users.get(message.user) || message.user : 'unknown';
|
|
39
|
+
const text = message.text ? (0, format_utils_1.formatMessageWithMentions)(message.text, users) : '(no text)';
|
|
40
|
+
console.log(`[${timestamp}] ${author}: ${text}`);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class JsonMessageFormatter extends base_formatter_1.JsonFormatter {
|
|
46
|
+
transform(options) {
|
|
47
|
+
const { channel, messages, users, countOnly } = options;
|
|
48
|
+
const channelName = (0, channel_formatter_1.formatChannelName)(channel.name);
|
|
49
|
+
const output = {
|
|
50
|
+
channel: channelName,
|
|
51
|
+
channelId: channel.id,
|
|
52
|
+
unreadCount: channel.unread_count || 0,
|
|
53
|
+
};
|
|
54
|
+
if (!countOnly && messages.length > 0) {
|
|
55
|
+
output.messages = messages.map((message) => ({
|
|
56
|
+
timestamp: (0, date_utils_1.formatSlackTimestamp)(message.ts),
|
|
57
|
+
author: message.user ? users.get(message.user) || message.user : 'unknown',
|
|
58
|
+
text: message.text || '(no text)',
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
return output;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const messageFormatterFactory = (0, base_formatter_1.createFormatterFactory)({
|
|
65
|
+
table: new TableMessageFormatter(),
|
|
66
|
+
simple: new SimpleMessageFormatter(),
|
|
67
|
+
json: new JsonMessageFormatter(),
|
|
68
|
+
});
|
|
69
|
+
function createMessageFormatter(format) {
|
|
70
|
+
return messageFormatterFactory.create(format);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=message-formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-formatters.js","sourceRoot":"","sources":["../../../src/utils/formatters/message-formatters.ts"],"names":[],"mappings":";;;;;AAkFA,wDAEC;AApFD,kDAA0B;AAC1B,qDAA4F;AAC5F,8CAAqD;AACrD,kDAA4D;AAC5D,4DAAyD;AAUzD,MAAM,qBAAsB,SAAQ,kCAA0C;IAC5E,MAAM,CAAC,OAAgC;QACrC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QACxD,MAAM,WAAW,GAAG,IAAA,qCAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEpD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,GAAG,WAAW,KAAK,OAAO,CAAC,YAAY,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAExF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AC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBAC1E,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,WAAW;aAClC,CAAC,CAAC,CAAC;QACN,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,uBAAuB,GAAG,IAAA,uCAAsB,EAA0B;IAC9E,KAAK,EAAE,IAAI,qBAAqB,EAAE;IAClC,MAAM,EAAE,IAAI,sBAAsB,EAAE;IACpC,IAAI,EAAE,IAAI,oBAAoB,EAAE;CACjC,CAAC,CAAC;AAEH,SAAgB,sBAAsB,CAAC,MAAc;IACnD,OAAO,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts all user IDs from mentions in a text
|
|
3
|
+
* @param text - The text containing Slack mentions
|
|
4
|
+
* @returns Array of unique user IDs found in mentions
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractUserIdsFromMentions(text: string): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Extracts all unique user IDs from an array of messages
|
|
9
|
+
* Includes both message authors and mentioned users
|
|
10
|
+
* @param messages - Array of messages to extract user IDs from
|
|
11
|
+
* @returns Array of unique user IDs
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractAllUserIds(messages: Array<{
|
|
14
|
+
user?: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
}>): string[];
|
|
17
|
+
//# sourceMappingURL=mention-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-utils.d.ts","sourceRoot":"","sources":["../../src/utils/mention-utils.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAYjE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,EAAE,CAmB7F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractUserIdsFromMentions = extractUserIdsFromMentions;
|
|
4
|
+
exports.extractAllUserIds = extractAllUserIds;
|
|
5
|
+
const slack_patterns_1 = require("./slack-patterns");
|
|
6
|
+
/**
|
|
7
|
+
* Extracts all user IDs from mentions in a text
|
|
8
|
+
* @param text - The text containing Slack mentions
|
|
9
|
+
* @returns Array of unique user IDs found in mentions
|
|
10
|
+
*/
|
|
11
|
+
function extractUserIdsFromMentions(text) {
|
|
12
|
+
const userIds = [];
|
|
13
|
+
const matches = text.matchAll(slack_patterns_1.USER_MENTION_PATTERN);
|
|
14
|
+
for (const match of matches) {
|
|
15
|
+
const userId = match[1];
|
|
16
|
+
if (userId) {
|
|
17
|
+
userIds.push(userId);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return userIds;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Extracts all unique user IDs from an array of messages
|
|
24
|
+
* Includes both message authors and mentioned users
|
|
25
|
+
* @param messages - Array of messages to extract user IDs from
|
|
26
|
+
* @returns Array of unique user IDs
|
|
27
|
+
*/
|
|
28
|
+
function extractAllUserIds(messages) {
|
|
29
|
+
const userIds = new Set();
|
|
30
|
+
for (const message of messages) {
|
|
31
|
+
// Add message author
|
|
32
|
+
if (message.user) {
|
|
33
|
+
userIds.add(message.user);
|
|
34
|
+
}
|
|
35
|
+
// Add mentioned users
|
|
36
|
+
if (message.text) {
|
|
37
|
+
const mentionedIds = extractUserIdsFromMentions(message.text);
|
|
38
|
+
for (const id of mentionedIds) {
|
|
39
|
+
userIds.add(id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Array.from(userIds);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=mention-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-utils.js","sourceRoot":"","sources":["../../src/utils/mention-utils.ts"],"names":[],"mappings":";;AAOA,gEAYC;AAQD,8CAmBC;AA9CD,qDAAwD;AAExD;;;;GAIG;AACH,SAAgB,0BAA0B,CAAC,IAAY;IACrD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,qCAAoB,CAAC,CAAC;IAEpD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,QAAiD;IACjF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,qBAAqB;QACrB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,sBAAsB;QACtB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC9D,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common option parsing utilities to reduce duplication
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse format option with default value
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseFormat(format?: string, defaultFormat?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Parse limit option with default value
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseLimit(limit: string | undefined, defaultLimit: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Parse boolean option with default value
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseBoolean(value?: boolean, defaultValue?: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Parse count option with default value
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseCount(count: string | undefined, defaultCount: number, min?: number, max?: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Parse profile option
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseProfile(profile?: string): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Common option defaults
|
|
26
|
+
*/
|
|
27
|
+
export declare const OPTION_DEFAULTS: {
|
|
28
|
+
readonly format: "table";
|
|
29
|
+
readonly limit: 100;
|
|
30
|
+
readonly countOnly: false;
|
|
31
|
+
readonly includeArchived: false;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Parse common list options
|
|
35
|
+
*/
|
|
36
|
+
export interface ListOptions {
|
|
37
|
+
format?: string;
|
|
38
|
+
limit?: string;
|
|
39
|
+
countOnly?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface ParsedListOptions {
|
|
42
|
+
format: string;
|
|
43
|
+
limit: number;
|
|
44
|
+
countOnly: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function parseListOptions(options: ListOptions, defaults?: Partial<ParsedListOptions>): ParsedListOptions;
|
|
47
|
+
//# sourceMappingURL=option-parsers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"option-parsers.d.ts","sourceRoot":"","sources":["../../src/utils/option-parsers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,SAAU,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,YAAY,UAAQ,GAAG,OAAO,CAE3E;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjE;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACpC,iBAAiB,CAanB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Common option parsing utilities to reduce duplication
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OPTION_DEFAULTS = void 0;
|
|
7
|
+
exports.parseFormat = parseFormat;
|
|
8
|
+
exports.parseLimit = parseLimit;
|
|
9
|
+
exports.parseBoolean = parseBoolean;
|
|
10
|
+
exports.parseCount = parseCount;
|
|
11
|
+
exports.parseProfile = parseProfile;
|
|
12
|
+
exports.parseListOptions = parseListOptions;
|
|
13
|
+
/**
|
|
14
|
+
* Parse format option with default value
|
|
15
|
+
*/
|
|
16
|
+
function parseFormat(format, defaultFormat = 'table') {
|
|
17
|
+
return format || defaultFormat;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse limit option with default value
|
|
21
|
+
*/
|
|
22
|
+
function parseLimit(limit, defaultLimit) {
|
|
23
|
+
return parseInt(limit || defaultLimit.toString(), 10);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse boolean option with default value
|
|
27
|
+
*/
|
|
28
|
+
function parseBoolean(value, defaultValue = false) {
|
|
29
|
+
return value !== undefined ? value : defaultValue;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse count option with default value
|
|
33
|
+
*/
|
|
34
|
+
function parseCount(count, defaultCount, min, max) {
|
|
35
|
+
const parsed = parseInt(count || defaultCount.toString(), 10);
|
|
36
|
+
if (isNaN(parsed)) {
|
|
37
|
+
return defaultCount;
|
|
38
|
+
}
|
|
39
|
+
if (min !== undefined && parsed < min) {
|
|
40
|
+
return min;
|
|
41
|
+
}
|
|
42
|
+
if (max !== undefined && parsed > max) {
|
|
43
|
+
return max;
|
|
44
|
+
}
|
|
45
|
+
return parsed;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse profile option
|
|
49
|
+
*/
|
|
50
|
+
function parseProfile(profile) {
|
|
51
|
+
return profile;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Common option defaults
|
|
55
|
+
*/
|
|
56
|
+
exports.OPTION_DEFAULTS = {
|
|
57
|
+
format: 'table',
|
|
58
|
+
limit: 100,
|
|
59
|
+
countOnly: false,
|
|
60
|
+
includeArchived: false,
|
|
61
|
+
};
|
|
62
|
+
function parseListOptions(options, defaults) {
|
|
63
|
+
const mergedDefaults = {
|
|
64
|
+
format: exports.OPTION_DEFAULTS.format,
|
|
65
|
+
limit: exports.OPTION_DEFAULTS.limit,
|
|
66
|
+
countOnly: exports.OPTION_DEFAULTS.countOnly,
|
|
67
|
+
...defaults,
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
format: parseFormat(options.format, mergedDefaults.format),
|
|
71
|
+
limit: parseLimit(options.limit, mergedDefaults.limit),
|
|
72
|
+
countOnly: parseBoolean(options.countOnly, mergedDefaults.countOnly),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=option-parsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"option-parsers.js","sourceRoot":"","sources":["../../src/utils/option-parsers.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAKH,kCAEC;AAKD,gCAEC;AAKD,oCAEC;AAKD,gCAqBC;AAKD,oCAEC;AA2BD,4CAgBC;AA/FD;;GAEG;AACH,SAAgB,WAAW,CAAC,MAAe,EAAE,aAAa,GAAG,OAAO;IAClE,OAAO,MAAM,IAAI,aAAa,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAyB,EAAE,YAAoB;IACxE,OAAO,QAAQ,CAAC,KAAK,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAe,EAAE,YAAY,GAAG,KAAK;IAChE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CACxB,KA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Profile } from '../types/config';
|
|
2
|
+
export declare class ProfileConfigManager {
|
|
3
|
+
private fileManager;
|
|
4
|
+
private cryptoService;
|
|
5
|
+
private profileManager;
|
|
6
|
+
constructor(_options?: ConfigOptions);
|
|
7
|
+
setToken(token: string, profile?: string): Promise<void>;
|
|
8
|
+
getConfig(profile?: string): Promise<Config | null>;
|
|
9
|
+
listProfiles(): Promise<Profile[]>;
|
|
10
|
+
useProfile(profile: string): Promise<void>;
|
|
11
|
+
getCurrentProfile(): Promise<string>;
|
|
12
|
+
clearConfig(profile?: string): Promise<void>;
|
|
13
|
+
maskToken(token: string): string;
|
|
14
|
+
migrateIfNeeded(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare const profileConfig: {
|
|
17
|
+
getCurrentProfile: () => string;
|
|
18
|
+
getToken: (_profile?: string) => string | undefined;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=profile-config-refactored.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-config-refactored.d.ts","sourceRoot":"","sources":["../../src/utils/profile-config-refactored.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAOtE,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,cAAc,CAAiB;gBAE3B,QAAQ,GAAE,aAAkB;IAQlC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxD,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAcnD,YAAY,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAiBlC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1C,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgClD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAY1B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAwBvC;AAGD,eAAO,MAAM,aAAa;6BACD,MAAM;0BAGP,MAAM,KAAG,MAAM,GAAG,SAAS;CAKlD,CAAC"}
|