@evergis/react 4.0.64 → 4.0.66

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.
@@ -10,8 +10,13 @@ export * from './useChartData';
10
10
  export * from './useDashboardHeader';
11
11
  export * from './useDataSources';
12
12
  export * from './useDiffPage';
13
+ export * from './useAfterSave';
14
+ export * from './useBeforeSave';
13
15
  export * from './useExpandableContainers';
14
16
  export * from './useExportPdf';
17
+ export * from './useFeatureSaveHooks';
18
+ export * from './useFeatureSaveHooks.utils';
19
+ export * from './useSavePrototypeBuilder';
15
20
  export * from './useWidgetFilters';
16
21
  export * from './useGetConfigLayer';
17
22
  export * from './useGlobalContext';
@@ -0,0 +1,3 @@
1
+ import { TaskPrototypeDto } from '@evergis/api';
2
+ import { ConfigRelatedResource, SaveHookInput } from '../types';
3
+ export declare const useAfterSave: (hook: ConfigRelatedResource | undefined, buildPrototype: (hook: ConfigRelatedResource, input: SaveHookInput) => TaskPrototypeDto) => (input: SaveHookInput) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { TaskPrototypeDto } from '@evergis/api';
2
+ import { ConfigRelatedResource, SaveHookInput } from '../types';
3
+ export declare const useBeforeSave: (hook: ConfigRelatedResource | undefined, buildPrototype: (hook: ConfigRelatedResource, input: SaveHookInput) => TaskPrototypeDto) => (input: SaveHookInput) => Promise<boolean>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Орchestrator-хук для серверных `beforeSave` / `afterSave` python-скриптов,
3
+ * описанных в `layerInfo.configuration.editConfiguration.options` слоя.
4
+ *
5
+ * - `runBeforeSave(input)` — `Promise<boolean>`, resolves `false` если
6
+ * серверная проверка не прошла; сохранение должно быть отменено.
7
+ * - `runAfterSave(input)` — fire-and-forget после успешного save.
8
+ *
9
+ * Активируется только если у потребителя в GlobalProvider переданы
10
+ * `api`, `notification` и `t`, а приложение обёрнуто в
11
+ * `<ServerNotificationsProvider>` (для SignalR-подписки на прогресс).
12
+ */
13
+ export declare const useFeatureSaveHooks: () => {
14
+ readonly runBeforeSave: (input: import('../types').SaveHookInput) => Promise<boolean>;
15
+ readonly runAfterSave: (input: import('../types').SaveHookInput) => Promise<void>;
16
+ };
@@ -0,0 +1,4 @@
1
+ import { ConfigRelatedResource } from '../types';
2
+ export declare const SAVE_HOOK_RESULT_DURATION = 4000;
3
+ export declare const isHookActive: (hook?: ConfigRelatedResource) => hook is ConfigRelatedResource;
4
+ export declare const createSaveNotificationId: () => string;
@@ -0,0 +1,3 @@
1
+ import { TaskPrototypeDto } from '@evergis/api';
2
+ import { ConfigRelatedResource, SaveHookInput } from '../types';
3
+ export declare const useSavePrototypeBuilder: () => (hook: ConfigRelatedResource, input: SaveHookInput) => TaskPrototypeDto;
@@ -59,6 +59,28 @@ export interface ConfigRelatedResource {
59
59
  fileName?: string;
60
60
  methodName?: string;
61
61
  }
62
+ /**
63
+ * Конфигурация `editConfiguration.options` слоя. Описывает серверные
64
+ * python-скрипты, выполняемые до и после сохранения объекта в FeatureCard.
65
+ *
66
+ * - `beforeSave` — синхронная серверная валидация перед сохранением.
67
+ * Save ждёт `Completed`; при `Error` сохранение отменяется.
68
+ * - `afterSave` — fire-and-forget действие после успешного сохранения.
69
+ *
70
+ * Используется хуком `useFeatureSaveHooks`.
71
+ */
72
+ export interface EditConfigurationOptions {
73
+ beforeSave?: ConfigRelatedResource;
74
+ afterSave?: ConfigRelatedResource;
75
+ }
76
+ /**
77
+ * Вход для `runBeforeSave` / `runAfterSave` хуков `useFeatureSaveHooks`.
78
+ * `featureId` равен `null` при создании нового объекта.
79
+ */
80
+ export interface SaveHookInput {
81
+ featureId: number | string | null;
82
+ changedProperties: Record<string, unknown>;
83
+ }
62
84
  export interface ConfigControl extends Pick<ConfigOptions, "relatedDataSource" | "minValue" | "maxValue" | "step" | "label" | "placeholder" | "width" | "variants"> {
63
85
  type: "dropdown" | "checkbox" | "chips" | "string";
64
86
  attributeName?: string;
@@ -1,4 +1,5 @@
1
1
  export * from './constants';
2
2
  export * from './usePythonTask';
3
3
  export * from './usePythonSandbox';
4
+ export * from './useRemoteTask';
4
5
  export * from './types';
@@ -0,0 +1,16 @@
1
+ import { RemoteTaskStatus, TaskPrototypeDto } from '@evergis/api';
2
+ export interface RemoteTaskUpdate {
3
+ status: RemoteTaskStatus;
4
+ log?: string;
5
+ }
6
+ export interface RemoteTaskResult {
7
+ taskId: string;
8
+ status: RemoteTaskStatus.Completed | RemoteTaskStatus.Error;
9
+ log?: string;
10
+ }
11
+ export interface UseRemoteTaskOptions {
12
+ onUpdate?: (update: RemoteTaskUpdate) => void;
13
+ }
14
+ export declare const useRemoteTask: ({ onUpdate }?: UseRemoteTaskOptions) => {
15
+ runTask: (prototype: TaskPrototypeDto) => Promise<RemoteTaskResult>;
16
+ };