@mattermost/types 10.1.0 → 10.3.0
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/lib/admin.d.ts +0 -1
- package/lib/apps.d.ts +2 -1
- package/lib/apps.js +229 -0
- package/lib/channels.d.ts +1 -0
- package/lib/client4.d.ts +4 -0
- package/lib/config.d.ts +13 -0
- package/lib/integration_actions.d.ts +3 -7
- package/lib/integration_actions.js +53 -0
- package/lib/message_attachments.d.ts +17 -18
- package/lib/message_attachments.js +89 -0
- package/lib/posts.d.ts +5 -3
- package/lib/products.d.ts +1 -0
- package/lib/products.js +8 -0
- package/lib/remote_clusters.d.ts +35 -0
- package/lib/remote_clusters.js +9 -0
- package/lib/schedule_post.d.ts +27 -0
- package/lib/schedule_post.js +51 -0
- package/lib/shared_channels.d.ts +15 -0
- package/lib/shared_channels.js +4 -0
- package/lib/store.d.ts +2 -0
- package/lib/threads.js +2 -2
- package/lib/utilities.d.ts +4 -0
- package/lib/utilities.js +24 -0
- package/package.json +2 -2
package/lib/admin.d.ts
CHANGED
package/lib/apps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProductScope } from './products';
|
|
2
2
|
export declare enum Permission {
|
|
3
3
|
UserJoinedChannelNotification = "user_joined_channel_notification",
|
|
4
4
|
ActAsBot = "act_as_bot",
|
|
@@ -56,6 +56,7 @@ export type AppBinding = {
|
|
|
56
56
|
form?: AppForm;
|
|
57
57
|
submit?: AppCall;
|
|
58
58
|
};
|
|
59
|
+
export declare function isAppBinding(obj: unknown): obj is AppBinding;
|
|
59
60
|
export type AppCallValues = {
|
|
60
61
|
[name: string]: any;
|
|
61
62
|
};
|
package/lib/apps.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// See LICENSE.txt for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.Locations = exports.Permission = void 0;
|
|
6
|
+
exports.isAppBinding = isAppBinding;
|
|
7
|
+
const products_1 = require("./products");
|
|
8
|
+
const utilities_1 = require("./utilities");
|
|
6
9
|
var Permission;
|
|
7
10
|
(function (Permission) {
|
|
8
11
|
Permission["UserJoinedChannelNotification"] = "user_joined_channel_notification";
|
|
@@ -19,3 +22,229 @@ var Locations;
|
|
|
19
22
|
Locations["Command"] = "/command";
|
|
20
23
|
Locations["InPost"] = "/in_post";
|
|
21
24
|
})(Locations || (exports.Locations = Locations = {}));
|
|
25
|
+
function isAppBinding(obj) {
|
|
26
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const binding = obj;
|
|
30
|
+
if (typeof binding.app_id !== 'string' || typeof binding.label !== 'string') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (binding.location !== undefined && typeof binding.location !== 'string') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (binding.supported_product_ids !== undefined && !(0, products_1.isProductScope)(binding.supported_product_ids)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (binding.icon !== undefined && typeof binding.icon !== 'string') {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (binding.hint !== undefined && typeof binding.hint !== 'string') {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (binding.description !== undefined && typeof binding.description !== 'string') {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (binding.role_id !== undefined && typeof binding.role_id !== 'string') {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (binding.depends_on_team !== undefined && typeof binding.depends_on_team !== 'boolean') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (binding.depends_on_channel !== undefined && typeof binding.depends_on_channel !== 'boolean') {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (binding.depends_on_user !== undefined && typeof binding.depends_on_user !== 'boolean') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (binding.depends_on_post !== undefined && typeof binding.depends_on_post !== 'boolean') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (binding.bindings !== undefined && !(0, utilities_1.isArrayOf)(binding.bindings, isAppBinding)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (binding.form !== undefined && !isAppForm(binding.form)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (binding.submit !== undefined && !isAppCall(binding.submit)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
function isAppCall(obj) {
|
|
75
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const call = obj;
|
|
79
|
+
if (typeof call.path !== 'string') {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (call.expand !== undefined && !isAppExpand(call.expand)) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// Here we're assuming that 'state' can be of any type, so no type check for 'state'
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
function isAppExpand(v) {
|
|
89
|
+
if (typeof v !== 'object' || v === null) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const expand = v;
|
|
93
|
+
if (expand.app !== undefined && typeof expand.app !== 'string') {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (expand.acting_user !== undefined && typeof expand.acting_user !== 'string') {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (expand.acting_user_access_token !== undefined && typeof expand.acting_user_access_token !== 'string') {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
if (expand.channel !== undefined && typeof expand.channel !== 'string') {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (expand.config !== undefined && typeof expand.config !== 'string') {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (expand.mentioned !== undefined && typeof expand.mentioned !== 'string') {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (expand.parent_post !== undefined && typeof expand.parent_post !== 'string') {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (expand.post !== undefined && typeof expand.post !== 'string') {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (expand.root_post !== undefined && typeof expand.root_post !== 'string') {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
if (expand.team !== undefined && typeof expand.team !== 'string') {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (expand.user !== undefined && typeof expand.user !== 'string') {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (expand.locale !== undefined && typeof expand.locale !== 'string') {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
function isAppForm(v) {
|
|
132
|
+
if (typeof v !== 'object' || v === null) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
const form = v;
|
|
136
|
+
if (form.title !== undefined && typeof form.title !== 'string') {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
if (form.header !== undefined && typeof form.header !== 'string') {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
if (form.footer !== undefined && typeof form.footer !== 'string') {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (form.icon !== undefined && typeof form.icon !== 'string') {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (form.submit_buttons !== undefined && typeof form.submit_buttons !== 'string') {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (form.cancel_button !== undefined && typeof form.cancel_button !== 'boolean') {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (form.submit_on_cancel !== undefined && typeof form.submit_on_cancel !== 'boolean') {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (form.fields !== undefined && !(0, utilities_1.isArrayOf)(form.fields, isAppField)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (form.source !== undefined && !isAppCall(form.source)) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (form.submit !== undefined && !isAppCall(form.submit)) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
if (form.depends_on !== undefined && !(0, utilities_1.isStringArray)(form.depends_on)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
function isAppFormValue(v) {
|
|
172
|
+
if (typeof v === 'string') {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (typeof v === 'boolean') {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (v === null) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return isAppSelectOption(v);
|
|
182
|
+
}
|
|
183
|
+
function isAppSelectOption(v) {
|
|
184
|
+
if (typeof v !== 'object' || v === null) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const option = v;
|
|
188
|
+
if (typeof option.label !== 'string' || typeof option.value !== 'string') {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (option.icon_data !== undefined && typeof option.icon_data !== 'string') {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
function isAppField(v) {
|
|
197
|
+
if (typeof v !== 'object' || v === null) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
const field = v;
|
|
201
|
+
if (typeof field.name !== 'string' || typeof field.type !== 'string') {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (field.is_required !== undefined && typeof field.is_required !== 'boolean') {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
if (field.readonly !== undefined && typeof field.readonly !== 'boolean') {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
if (field.value !== undefined && !isAppFormValue(field.value)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (field.description !== undefined && typeof field.description !== 'string') {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
if (field.label !== undefined && typeof field.label !== 'string') {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (field.hint !== undefined && typeof field.hint !== 'string') {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (field.position !== undefined && typeof field.position !== 'number') {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (field.modal_label !== undefined && typeof field.modal_label !== 'string') {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (field.refresh !== undefined && typeof field.refresh !== 'boolean') {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
if (field.options !== undefined && !(0, utilities_1.isArrayOf)(field.options, isAppSelectOption)) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (field.multiselect !== undefined && typeof field.multiselect !== 'boolean') {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (field.lookup !== undefined && !isAppCall(field.lookup)) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (field.subtype !== undefined && typeof field.subtype !== 'string') {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (field.min_length !== undefined && typeof field.min_length !== 'number') {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
if (field.max_length !== undefined && typeof field.max_length !== 'number') {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
return true;
|
|
250
|
+
}
|
package/lib/channels.d.ts
CHANGED
package/lib/client4.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export type Options = {
|
|
|
19
19
|
body?: any;
|
|
20
20
|
signal?: RequestInit['signal'];
|
|
21
21
|
ignoreStatus?: boolean; /** If true, status codes > 300 are ignored and don't cause an error */
|
|
22
|
+
duplex?: 'half'; /** Optional, but required for node clients. Must be 'half' for half-duplex fetch; 'full' is reserved for future use. See https://fetch.spec.whatwg.org/#dom-requestinit-duplex */
|
|
23
|
+
};
|
|
24
|
+
export type OptsSignalExt = {
|
|
25
|
+
signal?: AbortSignal;
|
|
22
26
|
};
|
|
23
27
|
export type StatusOK = {
|
|
24
28
|
status: 'OK';
|
package/lib/config.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export type ClientConfig = {
|
|
|
61
61
|
EnableCustomTermsOfService: string;
|
|
62
62
|
EnableDeveloper: string;
|
|
63
63
|
EnableDiagnostics: string;
|
|
64
|
+
EnableDesktopLandingPage: 'true' | 'false';
|
|
64
65
|
EnableEmailBatching: string;
|
|
65
66
|
EnableEmailInvitations: string;
|
|
66
67
|
EnableEmojiPicker: string;
|
|
@@ -209,6 +210,7 @@ export type ClientConfig = {
|
|
|
209
210
|
UniqueEmojiReactionLimitPerPost: string;
|
|
210
211
|
UsersStatusAndProfileFetchingPollIntervalMilliseconds: string;
|
|
211
212
|
YoutubeReferrerPolicy: 'true' | 'false';
|
|
213
|
+
ScheduledPosts: string;
|
|
212
214
|
};
|
|
213
215
|
export type License = {
|
|
214
216
|
id: string;
|
|
@@ -384,6 +386,8 @@ export type ServiceSettings = {
|
|
|
384
386
|
UniqueEmojiReactionLimitPerPost: number;
|
|
385
387
|
RefreshPostStatsRunTime: string;
|
|
386
388
|
MaximumPayloadSizeBytes: number;
|
|
389
|
+
EnableAPIPostDeletion: boolean;
|
|
390
|
+
EnableDesktopLandingPage: boolean;
|
|
387
391
|
MaximumURLLength: number;
|
|
388
392
|
};
|
|
389
393
|
export type TeamSettings = {
|
|
@@ -488,6 +492,12 @@ export type WranglerSettings = {
|
|
|
488
492
|
MoveThreadFromDirectMessageChannelEnable: boolean;
|
|
489
493
|
MoveThreadFromGroupMessageChannelEnable: boolean;
|
|
490
494
|
};
|
|
495
|
+
export type ConnectedWorkspacesSettings = {
|
|
496
|
+
EnableSharedChannels: boolean;
|
|
497
|
+
EnableRemoteClusterService: boolean;
|
|
498
|
+
DisableSharedChannelsStatusSync: boolean;
|
|
499
|
+
MaxPostsPerSync: number;
|
|
500
|
+
};
|
|
491
501
|
export type FileSettings = {
|
|
492
502
|
EnableFileAttachments: boolean;
|
|
493
503
|
EnableMobileUpload: boolean;
|
|
@@ -719,6 +729,7 @@ export type NativeAppSettings = {
|
|
|
719
729
|
AppDownloadLink: string;
|
|
720
730
|
AndroidAppDownloadLink: string;
|
|
721
731
|
IosAppDownloadLink: string;
|
|
732
|
+
MobileExternalBrowser: boolean;
|
|
722
733
|
};
|
|
723
734
|
export type ClusterSettings = {
|
|
724
735
|
Enable: boolean;
|
|
@@ -762,6 +773,7 @@ export type CacheSettings = {
|
|
|
762
773
|
RedisAddress: string;
|
|
763
774
|
RedisPassword: string;
|
|
764
775
|
RedisDB: number;
|
|
776
|
+
DisableClientCache: boolean;
|
|
765
777
|
};
|
|
766
778
|
export type ElasticsearchSettings = {
|
|
767
779
|
ConnectionURL: string;
|
|
@@ -930,6 +942,7 @@ export type AdminConfig = {
|
|
|
930
942
|
ImportSettings: ImportSettings;
|
|
931
943
|
ExportSettings: ExportSettings;
|
|
932
944
|
WranglerSettings: WranglerSettings;
|
|
945
|
+
ConnectedWorkspacesSettings: ConnectedWorkspacesSettings;
|
|
933
946
|
};
|
|
934
947
|
export type ReplicaLagSetting = {
|
|
935
948
|
DataSource: string;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
export type PostAction = {
|
|
2
|
-
id
|
|
2
|
+
id: string;
|
|
3
3
|
type?: string;
|
|
4
|
-
name
|
|
4
|
+
name: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
style?: string;
|
|
7
7
|
data_source?: string;
|
|
8
8
|
options?: PostActionOption[];
|
|
9
9
|
default_option?: string;
|
|
10
|
-
integration?: PostActionIntegration;
|
|
11
10
|
cookie?: string;
|
|
12
11
|
};
|
|
12
|
+
export declare function isPostAction(v: unknown): v is PostAction;
|
|
13
13
|
export type PostActionOption = {
|
|
14
14
|
text: string;
|
|
15
15
|
value: string;
|
|
16
16
|
};
|
|
17
|
-
export type PostActionIntegration = {
|
|
18
|
-
url?: string;
|
|
19
|
-
context?: Record<string, any>;
|
|
20
|
-
};
|
|
21
17
|
export type PostActionResponse = {
|
|
22
18
|
status: string;
|
|
23
19
|
trigger_id: string;
|
|
@@ -2,3 +2,56 @@
|
|
|
2
2
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
3
|
// See LICENSE.txt for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isPostAction = isPostAction;
|
|
6
|
+
const utilities_1 = require("./utilities");
|
|
7
|
+
function isPostAction(v) {
|
|
8
|
+
if (typeof v !== 'object' || !v) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (!('id' in v)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (typeof v.id !== 'string') {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (!('name' in v)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (typeof v.name !== 'string') {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if ('type' in v && typeof v.type !== 'string') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if ('disabled' in v && typeof v.disabled !== 'boolean') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if ('style' in v && typeof v.style !== 'string') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if ('data_source' in v && typeof v.data_source !== 'string') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if ('options' in v && !(0, utilities_1.isArrayOf)(v.options, isPostActionOption)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if ('default_option' in v && typeof v.default_option !== 'string') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if ('cookie' in v && typeof v.cookie !== 'string') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function isPostActionOption(v) {
|
|
47
|
+
if (typeof v !== 'object' || !v) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if ('text' in v && typeof v.text !== 'string') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if ('value' in v && typeof v.value !== 'string') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PostAction } from './integration_actions';
|
|
2
2
|
export type MessageAttachment = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
footer_icon: string;
|
|
18
|
-
timestamp: number | string;
|
|
3
|
+
fallback?: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
pretext?: string;
|
|
6
|
+
author_name?: string;
|
|
7
|
+
author_link?: string;
|
|
8
|
+
author_icon?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
title_link?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
fields?: MessageAttachmentField[] | null;
|
|
13
|
+
image_url?: string;
|
|
14
|
+
thumb_url?: string;
|
|
15
|
+
footer?: string;
|
|
16
|
+
footer_icon?: string;
|
|
19
17
|
actions?: PostAction[];
|
|
20
18
|
};
|
|
19
|
+
export declare function isMessageAttachmentArray(v: unknown): v is MessageAttachment[];
|
|
21
20
|
export type MessageAttachmentField = {
|
|
22
21
|
title: string;
|
|
23
22
|
value: any;
|
|
24
|
-
short
|
|
23
|
+
short?: boolean;
|
|
25
24
|
};
|
|
@@ -2,3 +2,92 @@
|
|
|
2
2
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
3
|
// See LICENSE.txt for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isMessageAttachmentArray = isMessageAttachmentArray;
|
|
6
|
+
const integration_actions_1 = require("./integration_actions");
|
|
7
|
+
const utilities_1 = require("./utilities");
|
|
8
|
+
function isMessageAttachmentArray(v) {
|
|
9
|
+
return (0, utilities_1.isArrayOf)(v, isMessageAttachment);
|
|
10
|
+
}
|
|
11
|
+
function isMessageAttachment(v) {
|
|
12
|
+
if (typeof v !== 'object' || !v) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if ('fallback' in v && typeof v.fallback !== 'string') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
// We may consider adding more validation to what color may be
|
|
19
|
+
if ('color' in v && typeof v.color !== 'string') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if ('pretext' in v && typeof v.pretext !== 'string') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if ('author_name' in v && typeof v.author_name !== 'string') {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
// Where it is used, we are calling isUrlSafe. We could consider calling it here
|
|
29
|
+
if ('author_link' in v && typeof v.author_link !== 'string') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// We may need more validation since this is going to be passed to an img src prop
|
|
33
|
+
if ('author_icon' in v && typeof v.author_icon !== 'string') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if ('title' in v && typeof v.title !== 'string') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Where it is used, we are calling isUrlSafe. We could consider calling it here
|
|
40
|
+
if ('title_link' in v && typeof v.title_link !== 'string') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if ('text' in v && typeof v.text !== 'string') {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// We may need more validation since this is going to be passed to an img src prop
|
|
47
|
+
if ('image_url' in v && typeof v.image_url !== 'string') {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
// We may need more validation since this is going to be passed to an img src prop
|
|
51
|
+
if ('thumb_url' in v && typeof v.thumb_url !== 'string') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// We are truncating if the size is more than some constant. We could check this here
|
|
55
|
+
if ('footer' in v && typeof v.footer !== 'string') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// We may need more validation since this is going to be passed to an img src prop
|
|
59
|
+
if ('footer_icon' in v && typeof v.footer_icon !== 'string') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if ('fields' in v && v.fields !== null && !(0, utilities_1.isArrayOf)(v.fields, isMessageAttachmentField)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if ('actions' in v && !(0, utilities_1.isArrayOf)(v.actions, integration_actions_1.isPostAction)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
function isMessageAttachmentField(v) {
|
|
71
|
+
if (typeof v !== 'object') {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (!v) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!('title' in v)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (typeof v.title !== 'string') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (!('value' in v)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (typeof v.value === 'object' && v.value && 'toString' in v.value && typeof v.value.toString !== 'function') {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if ('short' in v && typeof v.short !== 'boolean') {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
package/lib/posts.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { TrackPropertyUser } from 'mattermost-webapp/src/packages/mattermost-redux/src/constants/telemetry';
|
|
1
2
|
import type { Channel, ChannelType } from './channels';
|
|
2
3
|
import type { CustomEmoji } from './emojis';
|
|
3
4
|
import type { FileInfo } from './files';
|
|
4
5
|
import type { Reaction } from './reactions';
|
|
5
6
|
import type { TeamType } from './teams';
|
|
6
7
|
import type { UserProfile } from './users';
|
|
7
|
-
import type
|
|
8
|
+
import { type RelationOneToOne, type RelationOneToMany, type IDMappedObjects } from './utilities';
|
|
8
9
|
export type PostType = 'system_add_remove' | 'system_add_to_channel' | 'system_add_to_team' | 'system_channel_deleted' | 'system_channel_restored' | 'system_displayname_change' | 'system_convert_channel' | 'system_ephemeral' | 'system_header_change' | 'system_join_channel' | 'system_join_leave' | 'system_leave_channel' | 'system_purpose_change' | 'system_remove_from_channel' | 'system_combined_user_activity' | 'system_fake_parent_deleted' | 'system_generic' | 'reminder' | 'system_wrangler' | '';
|
|
9
10
|
export type PostEmbedType = 'image' | 'link' | 'message_attachment' | 'opengraph' | 'permalink';
|
|
10
11
|
export type PostEmbed = {
|
|
@@ -50,7 +51,7 @@ export type Post = {
|
|
|
50
51
|
original_id: string;
|
|
51
52
|
message: string;
|
|
52
53
|
type: PostType;
|
|
53
|
-
props: Record<string,
|
|
54
|
+
props: Record<string, unknown>;
|
|
54
55
|
hashtags: string;
|
|
55
56
|
pending_post_id: string;
|
|
56
57
|
reply_count: number;
|
|
@@ -65,6 +66,7 @@ export type Post = {
|
|
|
65
66
|
message_source?: string;
|
|
66
67
|
is_following?: boolean;
|
|
67
68
|
exists?: boolean;
|
|
69
|
+
remote_id?: string;
|
|
68
70
|
};
|
|
69
71
|
export type PostState = 'DELETED';
|
|
70
72
|
export declare enum PostPriority {
|
|
@@ -151,7 +153,7 @@ export declare type TeamsUsageResponse = {
|
|
|
151
153
|
export type PostAnalytics = {
|
|
152
154
|
channel_id: string;
|
|
153
155
|
post_id: string;
|
|
154
|
-
|
|
156
|
+
[TrackPropertyUser]: string;
|
|
155
157
|
root_id: string;
|
|
156
158
|
priority?: PostPriority | '';
|
|
157
159
|
requested_ack?: boolean;
|
package/lib/products.d.ts
CHANGED
package/lib/products.js
CHANGED
|
@@ -2,3 +2,11 @@
|
|
|
2
2
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
3
|
// See LICENSE.txt for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isProductScope = isProductScope;
|
|
6
|
+
const utilities_1 = require("./utilities");
|
|
7
|
+
function isProductScope(v) {
|
|
8
|
+
if (v === null || typeof v === 'string') {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return (0, utilities_1.isArrayOf)(v, (e) => e === null || typeof v === 'string');
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type RemoteClusterInvite = {
|
|
2
|
+
remote_id: string;
|
|
3
|
+
remote_team_id: string;
|
|
4
|
+
site_url: string;
|
|
5
|
+
token: string;
|
|
6
|
+
};
|
|
7
|
+
export type RemoteClusterAcceptInvite = {
|
|
8
|
+
name: string;
|
|
9
|
+
display_name: string;
|
|
10
|
+
default_team_id: string;
|
|
11
|
+
invite: string;
|
|
12
|
+
password: string;
|
|
13
|
+
};
|
|
14
|
+
export type RemoteClusterPatch = Pick<RemoteCluster, 'display_name' | 'default_team_id'>;
|
|
15
|
+
export declare function isRemoteClusterPatch(x: Partial<RemoteClusterPatch>): x is RemoteClusterPatch;
|
|
16
|
+
export type RemoteCluster = {
|
|
17
|
+
remote_id: string;
|
|
18
|
+
remote_team_id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
display_name: string;
|
|
21
|
+
site_url: string;
|
|
22
|
+
create_at: number;
|
|
23
|
+
delete_at: number;
|
|
24
|
+
last_ping_at: number;
|
|
25
|
+
token?: string;
|
|
26
|
+
remote_token?: string;
|
|
27
|
+
topics: string;
|
|
28
|
+
creator_id: string;
|
|
29
|
+
plugin_id: string;
|
|
30
|
+
options: number;
|
|
31
|
+
default_team_id: string;
|
|
32
|
+
};
|
|
33
|
+
export type RemoteClusterWithPassword = RemoteCluster & {
|
|
34
|
+
password: string;
|
|
35
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
|
+
// See LICENSE.txt for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isRemoteClusterPatch = isRemoteClusterPatch;
|
|
6
|
+
function isRemoteClusterPatch(x) {
|
|
7
|
+
return ((x.display_name !== undefined && x.display_name !== '') ||
|
|
8
|
+
x.default_team_id !== undefined);
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Draft } from './drafts';
|
|
2
|
+
import type { Post } from './posts';
|
|
3
|
+
export type ScheduledPostErrorCode = 'unknown' | 'channel_archived' | 'channel_not_found' | 'user_missing' | 'user_deleted' | 'no_channel_permission' | 'no_channel_member' | 'thread_deleted' | 'unable_to_send' | 'invalid_post';
|
|
4
|
+
export type SchedulingInfo = {
|
|
5
|
+
scheduled_at: number;
|
|
6
|
+
processed_at?: number;
|
|
7
|
+
error_code?: ScheduledPostErrorCode;
|
|
8
|
+
};
|
|
9
|
+
export type ScheduledPost = Omit<Draft, 'delete_at'> & SchedulingInfo & {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
export type ScheduledPostsState = {
|
|
13
|
+
byId: {
|
|
14
|
+
[scheduledPostId: string]: ScheduledPost | undefined;
|
|
15
|
+
};
|
|
16
|
+
byTeamId: {
|
|
17
|
+
[teamId: string]: string[];
|
|
18
|
+
};
|
|
19
|
+
errorsByTeamId: {
|
|
20
|
+
[teamId: string]: string[];
|
|
21
|
+
};
|
|
22
|
+
byChannelOrThreadId: {
|
|
23
|
+
[channelId: string]: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare function scheduledPostFromPost(post: Post, schedulingInfo: SchedulingInfo): ScheduledPost;
|
|
27
|
+
export declare function scheduledPostToPost(scheduledPost: ScheduledPost): Post;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
|
+
// See LICENSE.txt for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.scheduledPostFromPost = scheduledPostFromPost;
|
|
6
|
+
exports.scheduledPostToPost = scheduledPostToPost;
|
|
7
|
+
function scheduledPostFromPost(post, schedulingInfo) {
|
|
8
|
+
return {
|
|
9
|
+
id: '',
|
|
10
|
+
scheduled_at: schedulingInfo.scheduled_at,
|
|
11
|
+
create_at: 0,
|
|
12
|
+
update_at: post.update_at,
|
|
13
|
+
user_id: post.user_id,
|
|
14
|
+
channel_id: post.channel_id,
|
|
15
|
+
root_id: post.root_id,
|
|
16
|
+
message: post.message,
|
|
17
|
+
props: post.props,
|
|
18
|
+
metadata: post.metadata,
|
|
19
|
+
priority: post.metadata.priority,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function scheduledPostToPost(scheduledPost) {
|
|
23
|
+
const post = {
|
|
24
|
+
edit_at: 0,
|
|
25
|
+
hashtags: '',
|
|
26
|
+
is_pinned: false,
|
|
27
|
+
original_id: '',
|
|
28
|
+
pending_post_id: '',
|
|
29
|
+
reply_count: 0,
|
|
30
|
+
type: '',
|
|
31
|
+
id: scheduledPost.id,
|
|
32
|
+
create_at: scheduledPost.create_at,
|
|
33
|
+
update_at: scheduledPost.update_at,
|
|
34
|
+
delete_at: 0,
|
|
35
|
+
user_id: scheduledPost.user_id,
|
|
36
|
+
channel_id: scheduledPost.channel_id,
|
|
37
|
+
root_id: scheduledPost.root_id,
|
|
38
|
+
message: scheduledPost.message,
|
|
39
|
+
props: scheduledPost.props,
|
|
40
|
+
metadata: {
|
|
41
|
+
embeds: [],
|
|
42
|
+
emojis: [],
|
|
43
|
+
files: [],
|
|
44
|
+
images: {},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
if (scheduledPost.metadata) {
|
|
48
|
+
post.metadata = scheduledPost.metadata;
|
|
49
|
+
}
|
|
50
|
+
return post;
|
|
51
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SharedChannelRemote = {
|
|
2
|
+
id: string;
|
|
3
|
+
channel_id: string;
|
|
4
|
+
creator_id: string;
|
|
5
|
+
create_at: number;
|
|
6
|
+
update_at: number;
|
|
7
|
+
delete_at: number;
|
|
8
|
+
is_invite_accepted: boolean;
|
|
9
|
+
is_invite_confirmed: boolean;
|
|
10
|
+
remote_id: string;
|
|
11
|
+
last_post_update_at: number;
|
|
12
|
+
last_post_id: string;
|
|
13
|
+
last_post_create_at: number;
|
|
14
|
+
last_post_create_id: string;
|
|
15
|
+
};
|
package/lib/store.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { PostsState } from './posts';
|
|
|
17
17
|
import type { PreferenceType } from './preferences';
|
|
18
18
|
import type { AdminRequestsStatuses, ChannelsRequestsStatuses, FilesRequestsStatuses, GeneralRequestsStatuses, PostsRequestsStatuses, RolesRequestsStatuses, TeamsRequestsStatuses, UsersRequestsStatuses } from './requests';
|
|
19
19
|
import type { Role } from './roles';
|
|
20
|
+
import type { ScheduledPostsState } from './schedule_post';
|
|
20
21
|
import type { SchemesState } from './schemes';
|
|
21
22
|
import type { SearchState } from './search';
|
|
22
23
|
import type { TeamsState } from './teams';
|
|
@@ -66,6 +67,7 @@ export type GlobalState = {
|
|
|
66
67
|
cloud: CloudState;
|
|
67
68
|
hostedCustomer: HostedCustomerState;
|
|
68
69
|
usage: CloudUsage;
|
|
70
|
+
scheduledPosts: ScheduledPostsState;
|
|
69
71
|
};
|
|
70
72
|
errors: any[];
|
|
71
73
|
requests: {
|
package/lib/threads.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
3
|
// See LICENSE.txt for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
5
|
+
exports.UserThreadType = void 0;
|
|
6
|
+
exports.threadIsSynthetic = threadIsSynthetic;
|
|
6
7
|
var UserThreadType;
|
|
7
8
|
(function (UserThreadType) {
|
|
8
9
|
UserThreadType["Synthetic"] = "S"; // derived from post
|
|
@@ -10,4 +11,3 @@ var UserThreadType;
|
|
|
10
11
|
function threadIsSynthetic(thread) {
|
|
11
12
|
return thread.type === UserThreadType.Synthetic;
|
|
12
13
|
}
|
|
13
|
-
exports.threadIsSynthetic = threadIsSynthetic;
|
package/lib/utilities.d.ts
CHANGED
|
@@ -31,3 +31,7 @@ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<
|
|
|
31
31
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
|
32
32
|
}[Keys];
|
|
33
33
|
export type Intersection<T1, T2> = Omit<Omit<T1 & T2, keyof (Omit<T1, keyof (T2)>)>, keyof (Omit<T2, keyof (T1)>)>;
|
|
34
|
+
export type PartialExcept<T extends Record<string, unknown>, TKeysNotPartial extends keyof T> = Partial<T> & Pick<T, TKeysNotPartial>;
|
|
35
|
+
export declare function isArrayOf<T>(v: unknown, check: (e: unknown) => boolean): v is T[];
|
|
36
|
+
export declare function isStringArray(v: unknown): v is string[];
|
|
37
|
+
export declare function isRecordOf<T>(v: unknown, check: (e: unknown) => boolean): v is Record<string, T>;
|
package/lib/utilities.js
CHANGED
|
@@ -2,3 +2,27 @@
|
|
|
2
2
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
3
|
// See LICENSE.txt for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isArrayOf = isArrayOf;
|
|
6
|
+
exports.isStringArray = isStringArray;
|
|
7
|
+
exports.isRecordOf = isRecordOf;
|
|
8
|
+
function isArrayOf(v, check) {
|
|
9
|
+
if (!Array.isArray(v)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return v.every(check);
|
|
13
|
+
}
|
|
14
|
+
function isStringArray(v) {
|
|
15
|
+
return isArrayOf(v, (e) => typeof e === 'string');
|
|
16
|
+
}
|
|
17
|
+
function isRecordOf(v, check) {
|
|
18
|
+
if (typeof v !== 'object' || !v) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (!(Object.keys(v).every((k) => typeof k === 'string'))) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (!(Object.values(v).every(check))) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattermost/types",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "Shared type definitions used by the Mattermost web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mattermost"
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"build": "tsc --build --verbose",
|
|
41
41
|
"check": "eslint --ext .js,.jsx,.tsx,.ts ./src --quiet",
|
|
42
42
|
"run": "tsc --watch --preserveWatchOutput",
|
|
43
|
-
"clean": "rm -rf lib *.tsbuildinfo"
|
|
43
|
+
"clean": "rm -rf lib node_modules *.tsbuildinfo"
|
|
44
44
|
}
|
|
45
45
|
}
|