@mattermost/types 10.2.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 CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Audit } from './audits';
3
2
  import type { Compliance } from './compliance';
4
3
  import type { AdminConfig, ClientLicense, EnvironmentConfig } from './config';
package/lib/apps.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProductScope } from './products';
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/config.d.ts CHANGED
@@ -210,6 +210,7 @@ export type ClientConfig = {
210
210
  UniqueEmojiReactionLimitPerPost: string;
211
211
  UsersStatusAndProfileFetchingPollIntervalMilliseconds: string;
212
212
  YoutubeReferrerPolicy: 'true' | 'false';
213
+ ScheduledPosts: string;
213
214
  };
214
215
  export type License = {
215
216
  id: string;
@@ -386,6 +387,7 @@ export type ServiceSettings = {
386
387
  RefreshPostStatsRunTime: string;
387
388
  MaximumPayloadSizeBytes: number;
388
389
  EnableAPIPostDeletion: boolean;
390
+ EnableDesktopLandingPage: boolean;
389
391
  MaximumURLLength: number;
390
392
  };
391
393
  export type TeamSettings = {
@@ -727,6 +729,7 @@ export type NativeAppSettings = {
727
729
  AppDownloadLink: string;
728
730
  AndroidAppDownloadLink: string;
729
731
  IosAppDownloadLink: string;
732
+ MobileExternalBrowser: boolean;
730
733
  };
731
734
  export type ClusterSettings = {
732
735
  Enable: boolean;
@@ -770,6 +773,7 @@ export type CacheSettings = {
770
773
  RedisAddress: string;
771
774
  RedisPassword: string;
772
775
  RedisDB: number;
776
+ DisableClientCache: boolean;
773
777
  };
774
778
  export type ElasticsearchSettings = {
775
779
  ConnectionURL: string;
@@ -1,23 +1,19 @@
1
1
  export type PostAction = {
2
- id?: string;
2
+ id: string;
3
3
  type?: string;
4
- name?: string;
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 { PostAction } from './integration_actions';
1
+ import { type PostAction } from './integration_actions';
2
2
  export type MessageAttachment = {
3
- id: number;
4
- fallback: string;
5
- color: string;
6
- pretext: string;
7
- author_name: string;
8
- author_link: string;
9
- author_icon: string;
10
- title: string;
11
- title_link: string;
12
- text: string;
13
- fields: MessageAttachmentField[];
14
- image_url: string;
15
- thumb_url: string;
16
- footer: string;
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: boolean;
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 { RelationOneToOne, RelationOneToMany, IDMappedObjects } from './utilities';
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, any>;
54
+ props: Record<string, unknown>;
54
55
  hashtags: string;
55
56
  pending_post_id: string;
56
57
  reply_count: number;
@@ -152,7 +153,7 @@ export declare type TeamsUsageResponse = {
152
153
  export type PostAnalytics = {
153
154
  channel_id: string;
154
155
  post_id: string;
155
- user_actual_id: string;
156
+ [TrackPropertyUser]: string;
156
157
  root_id: string;
157
158
  priority?: PostPriority | '';
158
159
  requested_ack?: boolean;
package/lib/products.d.ts CHANGED
@@ -5,3 +5,4 @@
5
5
  export type ProductIdentifier = null | string;
6
6
  /** @see {@link ProductIdentifier} */
7
7
  export type ProductScope = ProductIdentifier | ProductIdentifier[];
8
+ export declare function isProductScope(v: unknown): v is ProductScope;
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
+ }
@@ -2,9 +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.isRemoteClusterPatch = void 0;
5
+ exports.isRemoteClusterPatch = isRemoteClusterPatch;
6
6
  function isRemoteClusterPatch(x) {
7
7
  return ((x.display_name !== undefined && x.display_name !== '') ||
8
8
  x.default_team_id !== undefined);
9
9
  }
10
- exports.isRemoteClusterPatch = isRemoteClusterPatch;
@@ -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
+ }
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.threadIsSynthetic = exports.UserThreadType = void 0;
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;
@@ -32,3 +32,6 @@ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<
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
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.2.0",
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
  }