@mattermost/types 10.4.0 → 10.5.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/client4.d.ts CHANGED
@@ -27,6 +27,7 @@ export type OptsSignalExt = {
27
27
  export type StatusOK = {
28
28
  status: 'OK';
29
29
  };
30
+ export declare const isStatusOK: (x: StatusOK | Record<string, unknown>) => x is StatusOK;
30
31
  export type FetchPaginatedThreadOptions = {
31
32
  fetchThreads?: boolean;
32
33
  collapsedThreads?: boolean;
package/lib/client4.js CHANGED
@@ -2,7 +2,7 @@
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.LogLevel = void 0;
5
+ exports.isStatusOK = exports.LogLevel = void 0;
6
6
  var LogLevel;
7
7
  (function (LogLevel) {
8
8
  LogLevel["Error"] = "ERROR";
@@ -10,3 +10,5 @@ var LogLevel;
10
10
  LogLevel["Info"] = "INFO";
11
11
  LogLevel["Debug"] = "DEBUG";
12
12
  })(LogLevel || (exports.LogLevel = LogLevel = {}));
13
+ const isStatusOK = (x) => (x === null || x === void 0 ? void 0 : x.status) === 'OK';
14
+ exports.isStatusOK = isStatusOK;
package/lib/config.d.ts CHANGED
@@ -120,6 +120,7 @@ export type ClientConfig = {
120
120
  FileLevel: string;
121
121
  FeatureFlagAppsEnabled: string;
122
122
  FeatureFlagCallsEnabled: string;
123
+ FeatureFlagCustomProfileAttributes: string;
123
124
  FeatureFlagWebSocketEventScope: string;
124
125
  ForgotPasswordLink: string;
125
126
  GiphySdkKey: string;
package/lib/files.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export type FileInfo = {
2
2
  id: string;
3
3
  user_id: string;
4
+ channel_id: string;
4
5
  create_at: number;
5
6
  update_at: number;
6
7
  delete_at: number;
package/lib/general.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import type { ClientConfig, ClientLicense } from './config';
2
+ import type { UserPropertyField } from './properties';
3
+ import type { IDMappedObjects } from './utilities';
2
4
  export type GeneralState = {
3
5
  config: Partial<ClientConfig>;
4
6
  firstAdminVisitMarketplaceStatus: boolean;
5
7
  firstAdminCompleteSetup: boolean;
6
8
  license: ClientLicense;
7
9
  serverVersion: string;
10
+ customProfileAttributes: IDMappedObjects<UserPropertyField>;
8
11
  };
9
12
  export type SystemSetting = {
10
13
  name: string;
package/lib/plugins.d.ts CHANGED
@@ -47,6 +47,7 @@ export type PluginSettingSection = {
47
47
  header?: string;
48
48
  footer?: string;
49
49
  custom?: boolean;
50
+ fallback?: boolean;
50
51
  };
51
52
  export type PluginSetting = {
52
53
  key: string;
@@ -0,0 +1,31 @@
1
+ export type PropertyField = {
2
+ id: string;
3
+ group_id: string;
4
+ name: string;
5
+ type: string;
6
+ attrs?: {
7
+ [key: string]: unknown;
8
+ };
9
+ target_id?: string;
10
+ target_type?: string;
11
+ create_at: number;
12
+ update_at: number;
13
+ delete_at: number;
14
+ };
15
+ export type PropertyValue<T> = {
16
+ id: string;
17
+ target_id: string;
18
+ target_type: string;
19
+ group_id: string;
20
+ value: T;
21
+ create_at: number;
22
+ update_at: number;
23
+ delete_at: number;
24
+ };
25
+ export type UserPropertyFieldType = 'text';
26
+ export type UserPropertyFieldGroupID = 'custom_profile_attributes';
27
+ export type UserPropertyField = PropertyField & {
28
+ type: UserPropertyFieldType;
29
+ group_id: UserPropertyFieldGroupID;
30
+ };
31
+ export type UserPropertyFieldPatch = Partial<Pick<UserPropertyField, 'name' | 'attrs' | 'type'>>;
@@ -0,0 +1,4 @@
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 });
@@ -20,6 +20,16 @@ export type RelationOneToManyUnique<E1 extends {
20
20
  export type IDMappedObjects<E extends {
21
21
  id: string;
22
22
  }> = RelationOneToOne<E, E>;
23
+ export type IDMappedCollection<T extends {
24
+ id: string;
25
+ }> = {
26
+ data: IDMappedObjects<T>;
27
+ order: Array<T['id']>;
28
+ errors?: RelationOneToOne<T, Error>;
29
+ warnings?: RelationOneToOne<T, {
30
+ [Key in keyof T]?: string;
31
+ }>;
32
+ };
23
33
  export type DeepPartial<T> = {
24
34
  [K in keyof T]?: (T[K] extends Set<any> ? T[K] : T[K] extends Map<any, any> ? T[K] : T[K] extends object ? DeepPartial<T[K]> : T[K] extends object | undefined ? DeepPartial<T[K]> : T[K]);
25
35
  };
@@ -31,7 +41,49 @@ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<
31
41
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
32
42
  }[Keys];
33
43
  export type Intersection<T1, T2> = Omit<Omit<T1 & T2, keyof (Omit<T1, keyof (T2)>)>, keyof (Omit<T2, keyof (T1)>)>;
44
+ /** https://stackoverflow.com/a/66605669 */
45
+ type Only<T, U> = {
46
+ [P in keyof T]: T[P];
47
+ } & {
48
+ [P in keyof U]?: never;
49
+ };
50
+ export type Either<T, U> = Only<T, U> | Only<U, T>;
34
51
  export type PartialExcept<T extends Record<string, unknown>, TKeysNotPartial extends keyof T> = Partial<T> & Pick<T, TKeysNotPartial>;
35
52
  export declare function isArrayOf<T>(v: unknown, check: (e: unknown) => boolean): v is T[];
36
53
  export declare function isStringArray(v: unknown): v is string[];
37
54
  export declare function isRecordOf<T>(v: unknown, check: (e: unknown) => boolean): v is Record<string, T>;
55
+ export declare const collectionFromArray: <T extends {
56
+ id: string;
57
+ }>(arr?: T[]) => IDMappedCollection<T>;
58
+ export declare const collectionToArray: <T extends {
59
+ id: string;
60
+ }>({ data, order }: IDMappedCollection<T>) => T[];
61
+ export declare const collectionReplaceItem: <T extends {
62
+ id: string;
63
+ }>(collection: IDMappedCollection<T>, item: T) => {
64
+ data: IDMappedObjects<T> & {
65
+ [x: string]: T;
66
+ };
67
+ order: T["id"][];
68
+ errors?: RelationOneToOne<T, Error> | undefined;
69
+ warnings?: RelationOneToOne<T, { [Key in keyof T]?: string | undefined; }> | undefined;
70
+ };
71
+ export declare const collectionAddItem: <T extends {
72
+ id: string;
73
+ }>(collection: IDMappedCollection<T>, item: T) => {
74
+ data: IDMappedObjects<T> & {
75
+ [x: string]: T;
76
+ };
77
+ order: string[];
78
+ errors?: RelationOneToOne<T, Error> | undefined;
79
+ warnings?: RelationOneToOne<T, { [Key in keyof T]?: string | undefined; }> | undefined;
80
+ };
81
+ export declare const collectionRemoveItem: <T extends {
82
+ id: string;
83
+ }>(collection: IDMappedCollection<T>, item: T) => {
84
+ data: IDMappedObjects<T>;
85
+ order: T["id"][];
86
+ errors?: RelationOneToOne<T, Error> | undefined;
87
+ warnings?: RelationOneToOne<T, { [Key in keyof T]?: string | undefined; }> | undefined;
88
+ };
89
+ export {};
package/lib/utilities.js CHANGED
@@ -2,6 +2,7 @@
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.collectionRemoveItem = exports.collectionAddItem = exports.collectionReplaceItem = exports.collectionToArray = exports.collectionFromArray = void 0;
5
6
  exports.isArrayOf = isArrayOf;
6
7
  exports.isStringArray = isStringArray;
7
8
  exports.isRecordOf = isRecordOf;
@@ -26,3 +27,30 @@ function isRecordOf(v, check) {
26
27
  }
27
28
  return true;
28
29
  }
30
+ const collectionFromArray = (arr = []) => {
31
+ return arr.reduce((current, item) => {
32
+ current.data = Object.assign(Object.assign({}, current.data), { [item.id]: item });
33
+ current.order.push(item.id);
34
+ return current;
35
+ }, { data: {}, order: [] });
36
+ };
37
+ exports.collectionFromArray = collectionFromArray;
38
+ const collectionToArray = ({ data, order }) => {
39
+ return order.map((id) => data[id]);
40
+ };
41
+ exports.collectionToArray = collectionToArray;
42
+ const collectionReplaceItem = (collection, item) => {
43
+ return Object.assign(Object.assign({}, collection), { data: Object.assign(Object.assign({}, collection.data), { [item.id]: item }) });
44
+ };
45
+ exports.collectionReplaceItem = collectionReplaceItem;
46
+ const collectionAddItem = (collection, item) => {
47
+ return Object.assign(Object.assign({}, collection), { data: Object.assign(Object.assign({}, collection.data), { [item.id]: item }), order: [...collection.order, item.id] });
48
+ };
49
+ exports.collectionAddItem = collectionAddItem;
50
+ const collectionRemoveItem = (collection, item) => {
51
+ const data = Object.assign({}, collection.data);
52
+ Reflect.deleteProperty(data, item.id);
53
+ const order = collection.order.filter((id) => id !== item.id);
54
+ return Object.assign(Object.assign({}, collection), { data, order });
55
+ };
56
+ exports.collectionRemoveItem = collectionRemoveItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattermost/types",
3
- "version": "10.4.0",
3
+ "version": "10.5.0",
4
4
  "description": "Shared type definitions used by the Mattermost web app",
5
5
  "keywords": [
6
6
  "mattermost"