mdt-client 31.0.11 → 31.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-client",
3
- "version": "31.0.11",
3
+ "version": "31.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,6 +57,7 @@ export declare type MithrilAttributes = _mithril.MithrilAttributes & {
57
57
  };
58
58
  export declare type MithrilVirtualElementKey = string | number;
59
59
  export declare type HTMLAnchorTarget = "_blank" | "_self" | "_parent" | "_top" | "framename";
60
+ export declare type HTMLString = string;
60
61
  export declare type KeyboardKeyCode = string;
61
62
  export declare type AnyError = any;
62
63
  export declare type FieldPath = string;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="../../../../mithril" />
2
2
  /// <reference types="mithril" />
3
- import { KeyboardKeyCode } from "../../../helpers/types";
3
+ import { KeyboardKeyCode } from "../../types";
4
4
  import { ComponentConfigParams } from "./modificatorsTypes";
5
5
  export declare function doesKeyPressed(keyCode: KeyboardKeyCode | KeyboardKeyCode[], e: KeyboardEvent): boolean;
6
6
  export declare function getFocusableComponentAttrs(): _mithril.MithrilAttributes;
@@ -0,0 +1,18 @@
1
+ declare type ValuedParams<F> = F extends (...args: infer A) => unknown ? A : never;
2
+ declare type ValuedExtract<F> = F extends (...args: any[]) => infer R ? R : F;
3
+ /**
4
+ * @example
5
+ const o = {
6
+ a1: getValued(123), // number
7
+ a2: getValued(() => 123), // number
8
+ a3: getValued(() => "str"), // string
9
+ a4: getValued((s: string) => `str:${s}`, "one"), // string
10
+ a5: getValued((s: string, n: number) => `str:${s}${n.toString()}`, "one", 123), // string
11
+ a6: getValued((s: string, n: string) => ({ name: s, value: n }), "one", "v"), // { name: string; value: string; }
12
+ a7: getValued((s: string, n: string) => ({ name: s, value: n }), "one", 123), // Error
13
+ a8: getValued("str", "one", 123), // Error
14
+ a9: getValued((s?: string, n?: string) => ({ name: s, value: n }), "one") // { name: string; value: string; }
15
+ };
16
+ */
17
+ export declare function getValued<F>(main: F, ...args: ValuedParams<F>): ValuedExtract<F>;
18
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { HierarchicalRecord, MdtRecord, RecordId } from "mdtScripts/common/Record";
2
- import { AnyObject, FieldCode, FieldId, ObjectCode } from "mdtScripts/helpers/types";
2
+ import { AnyObject, FieldCode, ObjectCode } from "mdtScripts/helpers/types";
3
3
  import { PermissionLevel } from "mdtScripts/security/PermissionLevel";
4
4
  export declare namespace ApiV1 {
5
5
  namespace Request {
@@ -149,7 +149,7 @@ export declare namespace ApiV1 {
149
149
  BaseLevel: PermissionLevel;
150
150
  Level: PermissionLevel;
151
151
  Fields: {
152
- [fieldId: FieldId]: {
152
+ [fieldId: number]: {
153
153
  Level: PermissionLevel;
154
154
  };
155
155
  };
@@ -167,6 +167,14 @@ export declare namespace ApiV1 {
167
167
  }
168
168
  type StorageProvider = "db";
169
169
  }
170
+ export namespace Template {
171
+ interface Preview {
172
+ Context: AnyObject;
173
+ Script: string;
174
+ Header: string;
175
+ Text: string;
176
+ }
177
+ }
170
178
  export {};
171
179
  }
172
180
  type AggregationType = "sum" | "avg" | "count" | "distinct" | "max" | "min";
@@ -58,6 +58,8 @@ export interface IFormControlFacade extends ParentCtrl {
58
58
  setControlOptions(findControl: (col: any) => boolean, controlOptions: any): any;
59
59
  /** Установить флаг доступности редактирования формы */
60
60
  setReadonly(readonly: boolean): void;
61
+ /** Проверка, доступна ли форма для редактирования */
62
+ isReadonly(): boolean;
61
63
  /** Изменить свойства существующей кнопки */
62
64
  updateCommand(findCondition: (button: ButtonFacade) => boolean, command: Partial<ButtonFacade>): void;
63
65
  /** Повторно инициализировать форму */
@@ -52,7 +52,7 @@ export interface FormViewSettings {
52
52
  }
53
53
  export interface IFormServiceFacade {
54
54
  /** Создать форму, привязанную объекту */
55
- create(tableCode: string, id: RecordId, options?: any, extOptions?: any): IFormControlFacade;
55
+ create(tableCode: string, id?: RecordId, options?: any, extOptions?: any): IFormControlFacade;
56
56
  /** Создать кастомную форму */
57
57
  createCustom(options: IFormOptions): IFormControlFacade;
58
58
  /** Подписаться на событие инициализации формы */
@@ -0,0 +1,38 @@
1
+ export interface IAppFacade {
2
+ /**
3
+ * Изменить логотип системы
4
+ *
5
+ * @param logo текст, ссылка или строка с svg
6
+ * @param type тип логотипа, по умолчанию svgOrText
7
+ *
8
+ * @example
9
+ * **Примеры**
10
+
11
+ * Установить текст в логотип:
12
+ * ```js
13
+ * App.setLogo("ICS");
14
+ * ```
15
+
16
+ * Установить svg в качестве логотипа:
17
+ * ```js
18
+ const svgIcsLogo = `<svg xmlns="http://www.w3.org/2000/svg" width="90" height="32" viewBox=" 0 0 102 32" fill="none"><g clip-path="url(#clip0)"><path d="M5.47418 8.14642H0.216797L1.54442 12.9067H5.47418V32H10.3067V13.8483V8.14642H5.47418Z" fill="#ffffff" /><path d="M52.7375 13.0113L54.0651 8.14642H44.1345C40.0985 8.14642 36.8591 11.3374 36.8591 15.313C36.8591 19.2362 40.0454 22.4272 44.0283 22.4795V22.5318H49.8167C51.0912 22.5318 52.1533 23.578 52.1533 24.8334C52.1533 26.0889 51.0912 27.1351 49.8167 27.1351H38.0805L36.7529 32H49.8167C53.8527 32 57.0921 28.809 57.0921 24.8334C57.0921 20.9102 53.8527 17.6669 49.8698 17.6669H44.1345C42.8599 17.6669 41.7979 16.6207 41.7979 15.3653C41.7979 14.1098 42.8599 13.0636 44.1345 13.0636H52.7375V13.0113Z" fill="#ffffff" /> <path d="M25.1225 8.14642C18.4313 8.14642 13.0146 13.4821 13.0146 20.0732C13.0146 26.6643 18.4313 32 25.1225 32H32.8227L33.991 27.0828H25.0163C21.0334 27.0828 17.8471 23.9442 17.8471 20.0209C17.8471 16.0976 21.0334 12.959 25.0163 12.959H32.7165L33.9379 8.19873L25.1225 8.14642Z" fill="#ffffff" /> <path d="M94.1056 27.135C90.3882 27.135 87.4143 24.1533 87.4143 20.5439V14.0051V12.8019H95.2739L96.6015 7.98943H87.4143V5.16467V0.0905457H82.4756V5.16467V7.93712V13.6389V15.9929V16.2544V20.4916C82.4756 26.8212 87.6799 31.9476 94.1056 31.9476H100.106L101.434 27.0827L94.1056 27.135Z" fill="#ffffff" /> <path d="M74.4046 8.0416H69.1472L67.9258 12.7495H74.4046V31.8429H79.2902V13.6911V8.0416H74.4046Z" fill="#ffffff" /> <path d="M10.3682 4.99186V0.179291L5.48254 0.179291V4.99186H10.3682Z" fill="#29ABE2" /> <path d="M79.2646 4.81256V0L74.3789 0V4.81256H79.2646Z" fill="#29ABE2" /> <path d="M60.4912 22.4797L61.7657 17.6671H66.6514L65.3769 22.4797H60.4912Z" fill="#29ABE2" /> </g> <defs> <clipPath id="clip0"> <rect width="102" height="32" fill="white" /> </clipPath> </defs> </svg>`
19
+ App.setLogo(svgIcsLogo);
20
+ * ```
21
+
22
+ * Установить ссылку на изображение:
23
+ * ```js
24
+ * App.setLogo("https://ics-it.ru/api/static?path=_logo.svg", "url");
25
+ * ```
26
+
27
+ * Отключить логотип:
28
+ * ```js
29
+ * App.setLogo(null);
30
+ * ```
31
+ */
32
+ setLogo(logo: string | false, type?: LogoType): void;
33
+ /**
34
+ * Изменить дополнительный логотип, справа от основного, аналогично {@link setLogo}
35
+ */
36
+ setSecondLogo(logo: string | false, type?: LogoType): void;
37
+ }
38
+ export declare type LogoType = "textOrSvg" | "url";
@@ -1,9 +1,91 @@
1
1
  /** @deprecated */
2
2
  export interface ILegacyFacade {
3
- /** @deprecated */
4
- LayoutBuilder: any;
5
- /** @deprecated */
6
3
  SchemaManagerInstance: any;
7
- /** @deprecated */
8
4
  SchemaManager: any;
5
+ NavigationManagerInstance: any;
6
+ DateTextFieldCtrl: any;
7
+ FormlessFieldCtrl: any;
8
+ MonthPicker: any;
9
+ UiMarked: any;
10
+ prop: any;
11
+ ImageService: any;
12
+ FormLayoutManager: any;
13
+ removeSpecial: any;
14
+ ServerErrorCtrl: any;
15
+ showErrors: any;
16
+ CheckboxListFieldCtrl: any;
17
+ SplitBlockCtrl: any;
18
+ SplitBlockSection: any;
19
+ pickRecordModal: any;
20
+ uiCtxEvent: any;
21
+ uiRedraw: any;
22
+ ApiAccessorInstance: any;
23
+ ApiAccessor: any;
24
+ clone: any;
25
+ mClassNames: any;
26
+ isDev: any;
27
+ ModuleService: any;
28
+ ApiServiceInstance: any;
29
+ SecurityManagerInstance: any;
30
+ FormControlManagerInstance: any;
31
+ RecordManagerInstance: any;
32
+ utils: any;
33
+ FormServiceInstance: any;
34
+ ListServiceInstance: any;
35
+ ui: any;
36
+ viewer: any;
37
+ deleteFromArray: any;
38
+ onDocumentVisibilityChange: any;
39
+ fireEvent: any;
40
+ combine: any;
41
+ app: any;
42
+ ContentListCtrl: any;
43
+ ListCtrl: any;
44
+ FormCtrl: any;
45
+ FieldCtrl: any;
46
+ FkPanels: any;
47
+ FramePage: any;
48
+ PageZones: any;
49
+ modules: {
50
+ pbi: {
51
+ PbiFrameCtrl: any;
52
+ };
53
+ etl: {
54
+ FormValueManager: any;
55
+ EtlPanel: any;
56
+ };
57
+ mapping: {
58
+ MappingListExtender: any;
59
+ MappingManager: any;
60
+ };
61
+ admin: {
62
+ DesignerHelper: any;
63
+ };
64
+ binding: {
65
+ UnbindingForm: any;
66
+ };
67
+ };
68
+ pageConfig: any;
69
+ view: any;
70
+ NavigationControlManager: any;
71
+ messages: any;
72
+ registerForm: any;
73
+ components: any;
74
+ FieldControlManagerInstance: any;
75
+ ServerMessageCtrl: any;
76
+ ContainerMixin: any;
77
+ SelectFieldCtrl: any;
78
+ FormFieldMode: any;
79
+ FormFieldCtrl: any;
80
+ FullPageForm: any;
81
+ LabelMode: any;
82
+ WarningText: any;
83
+ showError: any;
84
+ SelectMixin: any;
85
+ CacheManager: any;
86
+ ControlSize: any;
87
+ LayoutBuilder: any;
88
+ ServerMessageHelper: any;
89
+ showSidebar: any;
90
+ uiShow: any;
9
91
  }
@@ -21,10 +21,13 @@ import { IPageFacade } from "./IPageFacade";
21
21
  import { CommandManagerFacade } from "./services/CommandManagerFacade";
22
22
  import { IRecordManagerFacade } from "./record/IRecordManagerFacade";
23
23
  import { ILegacyFacade } from "./ILegacyFacade";
24
+ import { IAppFacade } from "./IAppFacade";
25
+ import { InternalModulesFacade } from "./internalModules/modulesFacadeTypes";
24
26
  export declare type ModulePackageInfo = {
25
27
  version: string;
26
28
  name?: string;
27
29
  };
30
+ export declare type ModuleCallback = () => Promise<void> | void;
28
31
  export interface IMDTFacade {
29
32
  /** Mithril библиотека */
30
33
  m: _mithril.MithrilStatic;
@@ -62,10 +65,13 @@ export interface IMDTFacade {
62
65
  Auth: IAuthFacade;
63
66
  /** Управление страницей */
64
67
  Page: IPageFacade;
68
+ /** Управление приложением */
69
+ App: IAppFacade;
65
70
  /** Управление командами */
66
71
  CommandManager: CommandManagerFacade;
67
72
  /** @deprecated */
68
73
  legacy: ILegacyFacade;
74
+ modules: InternalModulesFacade;
69
75
  /** Зарегистрировать модуль */
70
- registerModule(callback: () => void, moduleData: ModulePackageInfo): void;
76
+ registerModule(callback: ModuleCallback, moduleData: ModulePackageInfo): void;
71
77
  }
@@ -9,6 +9,7 @@ import { FieldCode, FieldPath, ViewElement } from "../../../../helpers/types";
9
9
  import { ILayoutColumnBase } from "../../../../views/list/IListView";
10
10
  import { ClassNamesArg } from "mdtScripts/helpers/utils/classNames";
11
11
  import { IColumnFacade } from "./Column/IColumnFacade";
12
+ import { RecordValueFacade } from "../record/IRecordFacade";
12
13
  export interface IListControlFacadeContstructor {
13
14
  new (listCtrl: any): IListControlFacade;
14
15
  }
@@ -54,19 +55,15 @@ export interface ColumnOptions<Control = any> {
54
55
  headerView: (control: Control) => ViewElement;
55
56
  headerStyle?: (control: Control) => ClassNamesArg;
56
57
  cellView: (ctx: {
57
- row: ColumnValueHandlerRowFacade;
58
+ row: RecordValueFacade;
58
59
  }, control: Control) => ViewElement;
59
60
  cellStyle?: (ctx: {
60
- row: ColumnValueHandlerRowFacade;
61
+ row: RecordValueFacade;
61
62
  }, control: Control) => ClassNamesArg;
62
63
  position?: (columns: IColumnFacade[]) => number;
63
64
  }
64
65
  export interface IColumnValueHandlerCtx {
65
- row: ColumnValueHandlerRowFacade;
66
+ row: RecordValueFacade;
66
67
  col: ILayoutColumnBase;
67
68
  idx?: number;
68
69
  }
69
- interface ColumnValueHandlerRowFacade {
70
- getValue: (path: FieldPath) => any;
71
- }
72
- export {};
@@ -1,5 +1,5 @@
1
1
  import { Field } from "../../../../../scripts/common/Field";
2
- import { ObjectCode, ViewControl } from "../../../../../scripts/helpers/types";
2
+ import { ObjectCode, ViewControl } from "../../../../helpers/types";
3
3
  import { MdtRecord } from "../utils/IApiFacade";
4
4
  import { IListControlFacade } from "./IListControlFacade";
5
5
  export interface IListInitOptions {
@@ -0,0 +1,9 @@
1
+ import { ViewControl } from "mdtScripts/helpers/types";
2
+ export interface ImportModuleFacade {
3
+ "mdt.import": {
4
+ ImportForm: ImportFormFacade;
5
+ };
6
+ }
7
+ export interface ImportFormFacade {
8
+ new (objectCode: string, options?: any): ViewControl;
9
+ }
@@ -0,0 +1,11 @@
1
+ import type { ImportModuleFacade } from "./importModuleFacade";
2
+ import { StatusModuleFacade } from "./statusFacade";
3
+ export interface InternalModulesFacade {
4
+ /**
5
+ * Возвращает фасад модуля. Если фасада нет или модуль не подключен, то метод выбрасывает ошибку.
6
+ * @throws {Error} - Выбрасывает ошибку, если имя не найдено
7
+ * @param moduleName - имя модуля
8
+ */
9
+ get<T extends keyof InternalModulesTypes>(moduleName: T): InternalModulesTypes[T];
10
+ }
11
+ export declare type InternalModulesTypes = ImportModuleFacade & StatusModuleFacade;
@@ -0,0 +1,13 @@
1
+ import { ObjectCode } from "../../../../helpers/types";
2
+ import { RecordFacade } from "../record/IRecordFacade";
3
+ export interface StatusModuleFacade {
4
+ "mdt.status": {
5
+ statusChangeHandler: (status: StatusCode, handler: ChangeStatusHandler) => void;
6
+ };
7
+ }
8
+ export declare type ChangeStatusHandler = ({ record, object }: StatusChangeHandlerContext) => void | Promise<void>;
9
+ export declare type StatusCode = string;
10
+ export interface StatusChangeHandlerContext {
11
+ record: RecordFacade;
12
+ object: ObjectCode;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { FieldCode, FieldPath, ObjectCode } from "../../../../helpers/types";
2
+ export declare type RecordFacade = RecordValueFacade & RecordChangesFacade;
3
+ export interface RecordValueFacade {
4
+ /** Получить значение записи по пути. */
5
+ getValue: (path: FieldPath) => any;
6
+ }
7
+ export interface RecordChangesFacade {
8
+ changes: RecordChanges;
9
+ }
10
+ export declare type RecordChanges = {
11
+ record: Record<FieldCode, any>;
12
+ table: ObjectCode;
13
+ };
@@ -2,17 +2,26 @@ import { BaseQuery } from "../../../../services/api/BaseQuery";
2
2
  import { FetchResult } from "../../../../datasources/FetchResult";
3
3
  import { ApiRequestOptions } from "../../../../services/api/ApiRequestOptions";
4
4
  import { RecordId } from "../../../../common/Record";
5
+ import { AnyObject } from "mdtScripts/helpers/types";
5
6
  export interface QueryParams {
6
7
  [param: string]: string | number;
7
8
  }
8
9
  export interface IApiFacade {
9
10
  /** Отправить запрос на получение данных по объекту */
10
11
  fetch<R = FetchResult>(objectCode: string, query?: BaseQuery): Promise<R>;
12
+ /** Отправить запрос к функции */
13
+ fetchFunction<R extends FetchResult = FetchResult>(objectCode: string, params?: AnyObject, query?: BaseQuery): Promise<R>;
11
14
  /** Отправить запрос на получение одной записи из объекта */
12
15
  fetchRecord<R = FetchResult>(objectCode: string, query?: BaseQuery): Promise<R>;
13
- /** Отправить запрос к функции */
16
+ /**
17
+ * @deprecated
18
+ * Отправить запрос к функции
19
+ */
14
20
  fetchFromFunction<R extends FetchResult = FetchResult>(objectCode: string, query?: BaseQuery, params?: any[]): Promise<R>;
15
- /** Отправить запрос на получение одной записи из функции */
21
+ /**
22
+ * @deprecated
23
+ * Отправить запрос на получение одной записи из функции
24
+ */
16
25
  fetchRecordFromFunction<R = any>(objectCode: string, query?: BaseQuery, params?: any[]): Promise<R>;
17
26
  /** Отправить запрос к хранимой процедуре */
18
27
  executeStoredProcedure<Result = any>(objectCode: string, params: any): PromiseLike<Result>;
@@ -1,10 +1,11 @@
1
- import { AnyObject } from "../../../../helpers/types";
2
1
  import { KeyStorage } from "../../../../helpers/utils/keyStorage/KeyStorage";
3
2
  import { FormatOptions } from "../../../../helpers/formatOptions";
4
3
  import { IListButtonExtendPipelineService } from "../services/IListButtonExtendPipelineService";
4
+ import { getValued } from "mdtScripts/helpers/utils/valued/getValued";
5
+ import { AnyObject } from "mdtScripts/helpers/types";
5
6
  export interface IUtilsFacade {
6
7
  ListButtonExtendPipelineService: IListButtonExtendPipelineService;
7
- getText(textCode: string, args?: AnyObject): string;
8
+ getText(textCode: string, args?: AnyObject, complex?: true): string;
8
9
  format(value: any, options?: FormatOptions): any;
9
10
  guid(): string;
10
11
  getStorageItem<T>(key: string, defaultValue?: T): KeyStorage<T>;
@@ -14,4 +15,5 @@ export interface IUtilsFacade {
14
15
  * Увеличить лимит времени загрузки можно с помощью глобальной переменной mdt.file.download.timeLimit
15
16
  */
16
17
  downloadFile(url: string): void;
18
+ getValued: typeof getValued;
17
19
  }