@zeitvu97/cms-sdk 0.1.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/LICENSE +21 -0
- package/README.md +478 -0
- package/dist/chunks/_shared-48T7q0V3.js +26 -0
- package/dist/chunks/_shared-48T7q0V3.js.map +1 -0
- package/dist/chunks/auth.constant-DO7ZmsKg.js +68 -0
- package/dist/chunks/auth.constant-DO7ZmsKg.js.map +1 -0
- package/dist/chunks/mt5Retcode-DlZLQOLA.js +178 -0
- package/dist/chunks/mt5Retcode-DlZLQOLA.js.map +1 -0
- package/dist/chunks/storage.constant--64BDSPW.js +44 -0
- package/dist/chunks/storage.constant--64BDSPW.js.map +1 -0
- package/dist/common/constants/auth.constant.d.ts +54 -0
- package/dist/common/constants/auth.constant.d.ts.map +1 -0
- package/dist/common/constants/bars.constant.d.ts +15 -0
- package/dist/common/constants/bars.constant.d.ts.map +1 -0
- package/dist/common/constants/content-types.constant.d.ts +29 -0
- package/dist/common/constants/content-types.constant.d.ts.map +1 -0
- package/dist/common/constants/content.constant.d.ts +114 -0
- package/dist/common/constants/content.constant.d.ts.map +1 -0
- package/dist/common/constants/executions.constant.d.ts +56 -0
- package/dist/common/constants/executions.constant.d.ts.map +1 -0
- package/dist/common/constants/gov.constant.d.ts +118 -0
- package/dist/common/constants/gov.constant.d.ts.map +1 -0
- package/dist/common/constants/history.constant.d.ts +108 -0
- package/dist/common/constants/history.constant.d.ts.map +1 -0
- package/dist/common/constants/http.constant.d.ts +46 -0
- package/dist/common/constants/http.constant.d.ts.map +1 -0
- package/dist/common/constants/index.d.ts +16 -0
- package/dist/common/constants/index.d.ts.map +1 -0
- package/dist/common/constants/kalshi.constant.d.ts +35 -0
- package/dist/common/constants/kalshi.constant.d.ts.map +1 -0
- package/dist/common/constants/llm.constant.d.ts +37 -0
- package/dist/common/constants/llm.constant.d.ts.map +1 -0
- package/dist/common/constants/mt5-action.constant.d.ts +131 -0
- package/dist/common/constants/mt5-action.constant.d.ts.map +1 -0
- package/dist/common/constants/mt5.constant.d.ts +254 -0
- package/dist/common/constants/mt5.constant.d.ts.map +1 -0
- package/dist/common/constants/notifications.constant.d.ts +45 -0
- package/dist/common/constants/notifications.constant.d.ts.map +1 -0
- package/dist/common/constants/people.constant.d.ts +269 -0
- package/dist/common/constants/people.constant.d.ts.map +1 -0
- package/dist/common/constants/rules.constant.d.ts +14 -0
- package/dist/common/constants/rules.constant.d.ts.map +1 -0
- package/dist/common/constants/settings.constant.d.ts +17 -0
- package/dist/common/constants/settings.constant.d.ts.map +1 -0
- package/dist/common/constants/sort.constant.d.ts +14 -0
- package/dist/common/constants/sort.constant.d.ts.map +1 -0
- package/dist/common/constants/storage.constant.d.ts +74 -0
- package/dist/common/constants/storage.constant.d.ts.map +1 -0
- package/dist/common/helpers/format.d.ts +7 -0
- package/dist/common/helpers/format.d.ts.map +1 -0
- package/dist/common/helpers/format.js +20 -0
- package/dist/common/helpers/format.js.map +1 -0
- package/dist/common/helpers/mt5Retcode.d.ts +18 -0
- package/dist/common/helpers/mt5Retcode.d.ts.map +1 -0
- package/dist/common/helpers/mt5Retcode.js +2 -0
- package/dist/common/helpers/mt5Retcode.js.map +1 -0
- package/dist/common/utils/case.d.ts +12 -0
- package/dist/common/utils/case.d.ts.map +1 -0
- package/dist/common/utils/clone.d.ts +9 -0
- package/dist/common/utils/clone.d.ts.map +1 -0
- package/dist/composables/cbsStateKey.d.ts +27 -0
- package/dist/composables/cbsStateKey.d.ts.map +1 -0
- package/dist/core/createApi.d.ts +69 -0
- package/dist/core/createApi.d.ts.map +1 -0
- package/dist/core/createCmsSDK.d.ts +19 -0
- package/dist/core/createCmsSDK.d.ts.map +1 -0
- package/dist/core/credentials/TokenManager.d.ts +38 -0
- package/dist/core/credentials/TokenManager.d.ts.map +1 -0
- package/dist/core/credentials/credential.type.d.ts +16 -0
- package/dist/core/credentials/credential.type.d.ts.map +1 -0
- package/dist/core/credentials/resolveStorage.d.ts +6 -0
- package/dist/core/credentials/resolveStorage.d.ts.map +1 -0
- package/dist/core/credentials/storages/cookieStorage.d.ts +18 -0
- package/dist/core/credentials/storages/cookieStorage.d.ts.map +1 -0
- package/dist/core/credentials/storages/localStorageAdapter.d.ts +8 -0
- package/dist/core/credentials/storages/localStorageAdapter.d.ts.map +1 -0
- package/dist/core/credentials/storages/memoryStorage.d.ts +7 -0
- package/dist/core/credentials/storages/memoryStorage.d.ts.map +1 -0
- package/dist/core/errors.d.ts +26 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/sdk.type.d.ts +115 -0
- package/dist/core/sdk.type.d.ts.map +1 -0
- package/dist/core/ws/createEaeraWebSocket.d.ts +21 -0
- package/dist/core/ws/createEaeraWebSocket.d.ts.map +1 -0
- package/dist/core/ws/index.d.ts +4 -0
- package/dist/core/ws/index.d.ts.map +1 -0
- package/dist/core/ws/ws.constants.d.ts +246 -0
- package/dist/core/ws/ws.constants.d.ts.map +1 -0
- package/dist/core/ws/ws.events.d.ts +264 -0
- package/dist/core/ws/ws.events.d.ts.map +1 -0
- package/dist/core/ws/ws.type.d.ts +225 -0
- package/dist/core/ws/ws.type.d.ts.map +1 -0
- package/dist/index.d.ts +130 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8416 -0
- package/dist/index.js.map +1 -0
- package/dist/nuxt.d.ts +49 -0
- package/dist/nuxt.d.ts.map +1 -0
- package/dist/nuxt.js +47 -0
- package/dist/nuxt.js.map +1 -0
- package/dist/runtime/plugin.d.ts +6 -0
- package/dist/runtime/plugin.js +188 -0
- package/dist/runtime/plugin.js.map +1 -0
- package/dist/server/auth/cbs-callback.post.js +42 -0
- package/dist/server/auth/cbs-callback.post.js.map +1 -0
- package/dist/server/auth/cbs-start.post.js +34 -0
- package/dist/server/auth/cbs-start.post.js.map +1 -0
- package/dist/server/auth/idp-callback.get.js +52 -0
- package/dist/server/auth/idp-callback.get.js.map +1 -0
- package/dist/server/auth/idp-link.post.js +38 -0
- package/dist/server/auth/idp-link.post.js.map +1 -0
- package/dist/server/auth/idp-login.get.js +42 -0
- package/dist/server/auth/idp-login.get.js.map +1 -0
- package/dist/server/auth/idp-unlink.delete.js +38 -0
- package/dist/server/auth/idp-unlink.delete.js.map +1 -0
- package/dist/server/auth/login.post.js +42 -0
- package/dist/server/auth/login.post.js.map +1 -0
- package/dist/server/auth/logout.post.js +31 -0
- package/dist/server/auth/logout.post.js.map +1 -0
- package/dist/server/auth/refresh.post.js +46 -0
- package/dist/server/auth/refresh.post.js.map +1 -0
- package/dist/server/clear-token.delete.js +12 -0
- package/dist/server/clear-token.delete.js.map +1 -0
- package/dist/server/persist.post.js +31 -0
- package/dist/server/persist.post.js.map +1 -0
- package/dist/server/set-token.post.js +27 -0
- package/dist/server/set-token.post.js.map +1 -0
- package/dist/services/auth/auth.type.d.ts +66 -0
- package/dist/services/auth/auth.type.d.ts.map +1 -0
- package/dist/services/auth/index.d.ts +127 -0
- package/dist/services/auth/index.d.ts.map +1 -0
- package/dist/services/auth/mock.d.ts +13 -0
- package/dist/services/auth/mock.d.ts.map +1 -0
- package/dist/services/bars/bars.type.d.ts +78 -0
- package/dist/services/bars/bars.type.d.ts.map +1 -0
- package/dist/services/bars/index.d.ts +24 -0
- package/dist/services/bars/index.d.ts.map +1 -0
- package/dist/services/bars/mock.d.ts +23 -0
- package/dist/services/bars/mock.d.ts.map +1 -0
- package/dist/services/content/content.type.d.ts +832 -0
- package/dist/services/content/content.type.d.ts.map +1 -0
- package/dist/services/content/filter.d.ts +46 -0
- package/dist/services/content/filter.d.ts.map +1 -0
- package/dist/services/content/index.d.ts +35 -0
- package/dist/services/content/index.d.ts.map +1 -0
- package/dist/services/content/mock.d.ts +16 -0
- package/dist/services/content/mock.d.ts.map +1 -0
- package/dist/services/content-types/content-types.type.d.ts +70 -0
- package/dist/services/content-types/content-types.type.d.ts.map +1 -0
- package/dist/services/content-types/index.d.ts +18 -0
- package/dist/services/content-types/index.d.ts.map +1 -0
- package/dist/services/content-types/mock.d.ts +15 -0
- package/dist/services/content-types/mock.d.ts.map +1 -0
- package/dist/services/executions/executions.type.d.ts +67 -0
- package/dist/services/executions/executions.type.d.ts.map +1 -0
- package/dist/services/executions/index.d.ts +30 -0
- package/dist/services/executions/index.d.ts.map +1 -0
- package/dist/services/executions/mock.d.ts +29 -0
- package/dist/services/executions/mock.d.ts.map +1 -0
- package/dist/services/gov/gov.type.d.ts +740 -0
- package/dist/services/gov/gov.type.d.ts.map +1 -0
- package/dist/services/gov/index.d.ts +84 -0
- package/dist/services/gov/index.d.ts.map +1 -0
- package/dist/services/history/history.type.d.ts +167 -0
- package/dist/services/history/history.type.d.ts.map +1 -0
- package/dist/services/history/index.d.ts +38 -0
- package/dist/services/history/index.d.ts.map +1 -0
- package/dist/services/history/mock.d.ts +21 -0
- package/dist/services/history/mock.d.ts.map +1 -0
- package/dist/services/kalshi/index.d.ts +19 -0
- package/dist/services/kalshi/index.d.ts.map +1 -0
- package/dist/services/kalshi/kalshi.type.d.ts +99 -0
- package/dist/services/kalshi/kalshi.type.d.ts.map +1 -0
- package/dist/services/kalshi/mock.d.ts +5 -0
- package/dist/services/kalshi/mock.d.ts.map +1 -0
- package/dist/services/llm/index.d.ts +38 -0
- package/dist/services/llm/index.d.ts.map +1 -0
- package/dist/services/llm/llm.type.d.ts +106 -0
- package/dist/services/llm/llm.type.d.ts.map +1 -0
- package/dist/services/notifications/index.d.ts +38 -0
- package/dist/services/notifications/index.d.ts.map +1 -0
- package/dist/services/notifications/mock.d.ts +39 -0
- package/dist/services/notifications/mock.d.ts.map +1 -0
- package/dist/services/notifications/notifications.type.d.ts +75 -0
- package/dist/services/notifications/notifications.type.d.ts.map +1 -0
- package/dist/services/people/_invoke.d.ts +26 -0
- package/dist/services/people/_invoke.d.ts.map +1 -0
- package/dist/services/people/copilot/index.d.ts +132 -0
- package/dist/services/people/copilot/index.d.ts.map +1 -0
- package/dist/services/people/identity/actions.d.ts +116 -0
- package/dist/services/people/identity/actions.d.ts.map +1 -0
- package/dist/services/people/identity/ct.types.d.ts +133 -0
- package/dist/services/people/identity/ct.types.d.ts.map +1 -0
- package/dist/services/people/identity/index.d.ts +14 -0
- package/dist/services/people/identity/index.d.ts.map +1 -0
- package/dist/services/people/identity/projections.d.ts +63 -0
- package/dist/services/people/identity/projections.d.ts.map +1 -0
- package/dist/services/people/index.d.ts +31 -0
- package/dist/services/people/index.d.ts.map +1 -0
- package/dist/services/people/legal/actions.d.ts +161 -0
- package/dist/services/people/legal/actions.d.ts.map +1 -0
- package/dist/services/people/legal/ct.types.d.ts +186 -0
- package/dist/services/people/legal/ct.types.d.ts.map +1 -0
- package/dist/services/people/legal/index.d.ts +15 -0
- package/dist/services/people/legal/index.d.ts.map +1 -0
- package/dist/services/people/packops/index.d.ts +70 -0
- package/dist/services/people/packops/index.d.ts.map +1 -0
- package/dist/services/people/packops/packops.type.d.ts +183 -0
- package/dist/services/people/packops/packops.type.d.ts.map +1 -0
- package/dist/services/people/perms/actions.d.ts +214 -0
- package/dist/services/people/perms/actions.d.ts.map +1 -0
- package/dist/services/people/perms/ct.types.d.ts +140 -0
- package/dist/services/people/perms/ct.types.d.ts.map +1 -0
- package/dist/services/people/perms/index.d.ts +14 -0
- package/dist/services/people/perms/index.d.ts.map +1 -0
- package/dist/services/people/perms/projections.d.ts +47 -0
- package/dist/services/people/perms/projections.d.ts.map +1 -0
- package/dist/services/people/process/actions.d.ts +154 -0
- package/dist/services/people/process/actions.d.ts.map +1 -0
- package/dist/services/people/process/ct.types.d.ts +304 -0
- package/dist/services/people/process/ct.types.d.ts.map +1 -0
- package/dist/services/people/process/index.d.ts +12 -0
- package/dist/services/people/process/index.d.ts.map +1 -0
- package/dist/services/people/shared.types.d.ts +36 -0
- package/dist/services/people/shared.types.d.ts.map +1 -0
- package/dist/services/rules/conditions.d.ts +264 -0
- package/dist/services/rules/conditions.d.ts.map +1 -0
- package/dist/services/rules/index.d.ts +49 -0
- package/dist/services/rules/index.d.ts.map +1 -0
- package/dist/services/rules/llm-rule.constant.d.ts +84 -0
- package/dist/services/rules/llm-rule.constant.d.ts.map +1 -0
- package/dist/services/rules/mock.d.ts +20 -0
- package/dist/services/rules/mock.d.ts.map +1 -0
- package/dist/services/rules/rules.type.d.ts +262 -0
- package/dist/services/rules/rules.type.d.ts.map +1 -0
- package/dist/services/rules/triggers.d.ts +140 -0
- package/dist/services/rules/triggers.d.ts.map +1 -0
- package/dist/services/settings/index.d.ts +36 -0
- package/dist/services/settings/index.d.ts.map +1 -0
- package/dist/services/settings/mock.d.ts +14 -0
- package/dist/services/settings/mock.d.ts.map +1 -0
- package/dist/services/settings/settings.type.d.ts +39 -0
- package/dist/services/settings/settings.type.d.ts.map +1 -0
- package/dist/stores/auth.d.ts +192 -0
- package/dist/stores/auth.d.ts.map +1 -0
- package/dist/stores/bars.d.ts +288 -0
- package/dist/stores/bars.d.ts.map +1 -0
- package/dist/stores/content.d.ts +4101 -0
- package/dist/stores/content.d.ts.map +1 -0
- package/dist/stores/executions.d.ts +249 -0
- package/dist/stores/executions.d.ts.map +1 -0
- package/dist/stores/gov.d.ts +238 -0
- package/dist/stores/gov.d.ts.map +1 -0
- package/dist/stores/history.d.ts +833 -0
- package/dist/stores/history.d.ts.map +1 -0
- package/dist/stores/index.d.ts +15 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/kalshi.d.ts +728 -0
- package/dist/stores/kalshi.d.ts.map +1 -0
- package/dist/stores/llm-providers.d.ts +97 -0
- package/dist/stores/llm-providers.d.ts.map +1 -0
- package/dist/stores/llm.d.ts +102 -0
- package/dist/stores/llm.d.ts.map +1 -0
- package/dist/stores/people.d.ts +596 -0
- package/dist/stores/people.d.ts.map +1 -0
- package/dist/stores/persist.d.ts +58 -0
- package/dist/stores/persist.d.ts.map +1 -0
- package/dist/stores/rules.d.ts +485 -0
- package/dist/stores/rules.d.ts.map +1 -0
- package/dist/stores/settings.d.ts +36 -0
- package/dist/stores/settings.d.ts.map +1 -0
- package/dist/stores/ws.d.ts +66 -0
- package/dist/stores/ws.d.ts.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { ExecutionType } from './rules.type';
|
|
2
|
+
export type ConditionValueType = 'float' | 'integer' | 'string';
|
|
3
|
+
/** ClickHouse metric tables the CMS evaluator resolves condition fields from.
|
|
4
|
+
* Mirrors the L1–L3a tables in `eaera_mt5/models` + the `deal` table. */
|
|
5
|
+
export type ConditionTable = 'account_state' | 'account_metric_by_deal' | 'account_symbol_metric_by_deal' | 'account_metric_daily' | 'position_metric_by_deal' | 'deal';
|
|
6
|
+
export interface ConditionField {
|
|
7
|
+
/** Backend key, e.g. `account_state.equity`. */
|
|
8
|
+
key: string;
|
|
9
|
+
/** Human label, e.g. `Account Equity`. */
|
|
10
|
+
label: string;
|
|
11
|
+
table: ConditionTable;
|
|
12
|
+
column: string;
|
|
13
|
+
valueType: ConditionValueType;
|
|
14
|
+
description: string;
|
|
15
|
+
unit: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const CONDITION_FIELDS: readonly ConditionField[];
|
|
18
|
+
/** Comparison operators the condition builder emits into `trigger.conditions[]`.
|
|
19
|
+
*
|
|
20
|
+
* These are the **word forms** the CMS condition evaluator expects on the wire
|
|
21
|
+
* (`eaera_cms/core/rules/conditions.py:_apply_operator`). The evaluator also
|
|
22
|
+
* accepts the JSON-Logic symbol aliases (`==`, `!=`, `>`, `>=`, `<`, `<=`),
|
|
23
|
+
* but the canonical contract uses the word forms — see the FEAT-006 testing
|
|
24
|
+
* guide and `risk-rules-api-guide.md` §4.E.a.
|
|
25
|
+
*
|
|
26
|
+
* Operator kind, per the backend `value` semantics:
|
|
27
|
+
* - `gt`, `gte`, `lt`, `lte` — numeric (`account_state.*`,
|
|
28
|
+
* `account_metric_by_deal.*`)
|
|
29
|
+
* - `eq`, `ne` — any (string / number / boolean)
|
|
30
|
+
* - `in`, `not_in` — value MUST be a JSON list
|
|
31
|
+
* - `contains`, `startswith`, `endswith` — string substring/affix;
|
|
32
|
+
* backend coerces entity via `str()`
|
|
33
|
+
* - `is_null`, `is_not_null` — `value` is IGNORED by the backend;
|
|
34
|
+
* UI should hide the value input
|
|
35
|
+
* - `sum_within_days` — CH-windowed SUM; carries a sibling
|
|
36
|
+
* `days` window (defaults to 30).
|
|
37
|
+
* Special — see {@link SUM_WITHIN_DAYS}
|
|
38
|
+
* constant; not in {@link CONDITION_OPERATORS}.
|
|
39
|
+
*
|
|
40
|
+
* The UI renders the friendlier symbol for the 6 numeric word-forms via
|
|
41
|
+
* {@link CONDITION_OPERATOR_LABELS}; the others have explicit text labels
|
|
42
|
+
* (see {@link CONDITION_OPERATOR_LABELS} + {@link CONDITION_OPERATOR_LABELS_TEXT}).
|
|
43
|
+
*/
|
|
44
|
+
export declare const CONDITION_OPERATORS: readonly ["gt", "gte", "lt", "lte", "eq", "ne", "in", "not_in", "contains", "startswith", "endswith", "is_null", "is_not_null"];
|
|
45
|
+
export type ConditionOperator = (typeof CONDITION_OPERATORS)[number];
|
|
46
|
+
/** The CH-windowed SUM operator — special, NOT a member of
|
|
47
|
+
* {@link CONDITION_OPERATORS} because it carries a sibling `days` key.
|
|
48
|
+
* Authored through the rule YAML/expression path or directly via the API.
|
|
49
|
+
* The dashboard does not surface this in the standard operator dropdown. */
|
|
50
|
+
export declare const SUM_WITHIN_DAYS: "sum_within_days";
|
|
51
|
+
export type SumWithinDaysOperator = typeof SUM_WITHIN_DAYS;
|
|
52
|
+
/** Symbol label shown in the UI for each numeric word-form operator. */
|
|
53
|
+
export declare const CONDITION_OPERATOR_LABELS: Record<ConditionOperator, string>;
|
|
54
|
+
/** Per-operator value-type metadata. Drives the dashboard's value-input widget:
|
|
55
|
+
* - `number` → numeric input
|
|
56
|
+
* - `string` → single-line text input (substrings/affixes)
|
|
57
|
+
* - `list` → JSON-array editor (CSV/JSON toggle recommended)
|
|
58
|
+
* - `none` → value is ignored by the backend; UI should hide the input
|
|
59
|
+
*/
|
|
60
|
+
export type ConditionOperatorValueKind = 'number' | 'string' | 'list' | 'none';
|
|
61
|
+
export declare const CONDITION_OPERATOR_VALUE_KINDS: Record<ConditionOperator, ConditionOperatorValueKind>;
|
|
62
|
+
/** Symbol form → word form. The backend accepts both on the wire; the dashboard
|
|
63
|
+
* canonicalises to the word form on save and on load (`useRuleBuilder`
|
|
64
|
+
* `_normalizeOperator`). */
|
|
65
|
+
export declare const CONDITION_OPERATOR_SYMBOL_TO_WORD: Record<string, ConditionOperator>;
|
|
66
|
+
/** Normalise any operator string (symbol, word, or unknown) to a word form.
|
|
67
|
+
* Unknown inputs are returned as-is so the backend's `eq`-fallback semantics
|
|
68
|
+
* remain the source of truth. */
|
|
69
|
+
export declare const normalizeConditionOperator: (raw: unknown) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Allowed MT5 leverage values for the `change_leverage` action. MT5 accepts a
|
|
72
|
+
* constrained integer set; the rule builder offers these as a select rather
|
|
73
|
+
* than a free-text input. The MT5 worker coerces the value to a positive int
|
|
74
|
+
* (`worker/tasks/dispatcher.py:_change_leverage`); this list mirrors the
|
|
75
|
+
* common broker-configured leverages.
|
|
76
|
+
*/
|
|
77
|
+
export declare const LEVERAGE_OPTIONS: readonly [1, 5, 10, 20, 25, 30, 40, 50, 100, 200, 300, 400, 500, 1000];
|
|
78
|
+
export type LeverageOption = (typeof LEVERAGE_OPTIONS)[number];
|
|
79
|
+
/**
|
|
80
|
+
* Builder action kinds → CMS action wiring. The fixed-rule action chain maps
|
|
81
|
+
* a UI `kind` to its `actionName` + nested `params` key. Kept here so the FE
|
|
82
|
+
* serializer (and the docs) stay in sync with the worker dispatcher contract.
|
|
83
|
+
*
|
|
84
|
+
* Specialized kinds (`move`, `leverage`, `tag`, `setField`) have dedicated UI
|
|
85
|
+
* inputs. The `custom` kind is a fallback for any action not in this list — it
|
|
86
|
+
* renders the `actionName` as read-only and exposes raw `params` as JSON.
|
|
87
|
+
*/
|
|
88
|
+
/** Value-level constants for action kinds — single source of truth. */
|
|
89
|
+
export declare const ACTION_KIND: {
|
|
90
|
+
readonly MOVE: "move";
|
|
91
|
+
readonly LEVERAGE: "leverage";
|
|
92
|
+
readonly TAG: "tag";
|
|
93
|
+
readonly SET_FIELD: "setField";
|
|
94
|
+
readonly DISABLE_TRADE: "disableTrade";
|
|
95
|
+
readonly ENABLE_TRADE: "enableTrade";
|
|
96
|
+
readonly GENERATE_REPORT: "generateReport";
|
|
97
|
+
readonly GENERATE_AI_SUMMARY: "generateAiSummary";
|
|
98
|
+
readonly PROVISION_USER: "provisionUser";
|
|
99
|
+
readonly CUSTOM: "custom";
|
|
100
|
+
};
|
|
101
|
+
/** Action kind type — derived from {@link ACTION_KIND}. */
|
|
102
|
+
export type RuleActionKind = (typeof ACTION_KIND)[keyof typeof ACTION_KIND];
|
|
103
|
+
export interface ActionKindDef {
|
|
104
|
+
kind: RuleActionKind;
|
|
105
|
+
actionName: string;
|
|
106
|
+
/** Nested `params` key the worker dispatcher reads (camelCase; the CMS
|
|
107
|
+
* casing middleware converts to snake_case before the worker sees it). */
|
|
108
|
+
paramKey?: string;
|
|
109
|
+
/** Default codeRef (pack handler path) for actions that require one. */
|
|
110
|
+
defaultCodeRef?: string;
|
|
111
|
+
/** Human label shown in the UI kind selector. */
|
|
112
|
+
label: string;
|
|
113
|
+
}
|
|
114
|
+
export declare const ACTION_KINDS: readonly ActionKindDef[];
|
|
115
|
+
/** Lookup an ActionKindDef by backend actionName. Returns undefined for unknown names. */
|
|
116
|
+
export declare const actionDefByActionName: (actionName: string) => ActionKindDef | undefined;
|
|
117
|
+
/** Per-action `result.output` field shapes — the authoritative reference for
|
|
118
|
+
* what the CMS completion handler stores at `execution.result.output` after a
|
|
119
|
+
* successful action.
|
|
120
|
+
*
|
|
121
|
+
* When the history/detection feeds fetch with `?exclude_params=true`, the
|
|
122
|
+
* `params` JSONB is dropped entirely. The dashboard reads action details from
|
|
123
|
+
* `result.output` (and `operationName`) instead. This map tells the dashboard
|
|
124
|
+
* which keys to expect per action.
|
|
125
|
+
*
|
|
126
|
+
* Source: `eaera-mt5/worker/tasks/dispatcher.py` (worker return shape) +
|
|
127
|
+
* `eaera-mt5/eaera_mt5/handlers/*.py` (handler ActionResult.output) +
|
|
128
|
+
* `eaera-cms/eaera_cms/core/content/completion.py:427`
|
|
129
|
+
* (`execution.result = {"success": True, "output": res.output}`).
|
|
130
|
+
*
|
|
131
|
+
* Each entry lists the keys the output dict carries. The values are always
|
|
132
|
+
* primitives (string / number / boolean / string[]). */
|
|
133
|
+
export interface ActionResultField {
|
|
134
|
+
/** Key in `result.output`. */
|
|
135
|
+
key: string;
|
|
136
|
+
/** Human label. */
|
|
137
|
+
label: string;
|
|
138
|
+
/** Value type. */
|
|
139
|
+
type: 'string' | 'number' | 'boolean' | 'string[]';
|
|
140
|
+
}
|
|
141
|
+
export declare const ACTION_RESULT_FIELDS: Record<string, readonly ActionResultField[]>;
|
|
142
|
+
/** Extract a flat `{key: value}` dict from `result.output` for a given action.
|
|
143
|
+
* Returns `{}` when output is missing or not an object. */
|
|
144
|
+
export declare const resultOutputOf: (result: Record<string, unknown> | null | undefined, actionName: string) => Record<string, unknown>;
|
|
145
|
+
/** Lookup an ActionKindDef by UI kind. Returns undefined for 'custom'. */
|
|
146
|
+
export declare const actionDefByKind: (kind: RuleActionKind) => ActionKindDef | undefined;
|
|
147
|
+
/** FE-only action step view-model. The single canonical shape used by both
|
|
148
|
+
* the Fixed Rules editor and the LLM-rule (skill) editor. The dashboard
|
|
149
|
+
* imports this from the SDK so the two editors serialize identically and
|
|
150
|
+
* never diverge on what an action looks like. */
|
|
151
|
+
export interface RuleActionView {
|
|
152
|
+
/** Local UI key — never sent to the backend. */
|
|
153
|
+
id: string;
|
|
154
|
+
/** FE-only action kind; maps 1:1 to {@link RuleActionKind}. */
|
|
155
|
+
kind: RuleActionKind;
|
|
156
|
+
/** Target group for `kind === 'move'`. */
|
|
157
|
+
targetGroup?: string;
|
|
158
|
+
/** Tags array for `kind === 'tag'`. */
|
|
159
|
+
tags?: string[];
|
|
160
|
+
/** Tag mode for `kind === 'tag'`. */
|
|
161
|
+
tagMode?: 'append' | 'replace' | 'remove';
|
|
162
|
+
/** Field name for `kind === 'setField'` / `kind === 'provisionUser'`. */
|
|
163
|
+
field?: string;
|
|
164
|
+
/** Value for `kind === 'leverage'` (numeric) or `kind === 'setField'`
|
|
165
|
+
* (stringified). */
|
|
166
|
+
value?: number | string;
|
|
167
|
+
/** Report period start (ISO `YYYY-MM-DD`) for `kind === 'generateReport'`. */
|
|
168
|
+
dateFrom?: string;
|
|
169
|
+
/** Report period end (ISO `YYYY-MM-DD`) for `kind === 'generateReport'`. */
|
|
170
|
+
dateTo?: string;
|
|
171
|
+
/** Reason string for `kind === 'disableTrade' | 'enableTrade'`. */
|
|
172
|
+
reason?: string;
|
|
173
|
+
/** Backend actionName — auto-populated for specialized kinds; required for `custom`. */
|
|
174
|
+
actionName?: string;
|
|
175
|
+
/** Backend codeRef (handler path). Preserved on load, emitted on save. */
|
|
176
|
+
codeRef?: string;
|
|
177
|
+
/** Raw params object — used by `custom` and preserved for round-tripping. */
|
|
178
|
+
params?: Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
/** Serialize the per-kind `params` payload for the CMS dispatcher.
|
|
181
|
+
* Mirrors the historical `useRuleBuilder._serializeActionParams`.
|
|
182
|
+
*
|
|
183
|
+
* Critical contract:
|
|
184
|
+
* - The dispatcher passes `params` through `ctx.data` to the worker handler.
|
|
185
|
+
* - The MT5 worker reads snake_case keys (`from_time`, `new_group`,
|
|
186
|
+
* `new_leverage`, …) and the CMS casing middleware converts our
|
|
187
|
+
* camelCase keys to snake_case on the way in.
|
|
188
|
+
* - Empty / zero required fields are omitted so the worker doesn't pick
|
|
189
|
+
* up its default-0 placeholder and silently fail. The rule can be
|
|
190
|
+
* saved with empty inputs; the action will then fail gracefully at
|
|
191
|
+
* fire time with a clear error.
|
|
192
|
+
* - Do NOT emit `login` / `serverName` placeholders — the runtime context
|
|
193
|
+
* (trigger event or fire payload) carries those.
|
|
194
|
+
*/
|
|
195
|
+
export declare const serializeActionParams: (action: RuleActionView) => Record<string, unknown>;
|
|
196
|
+
/** Serialize a single action view into the CMS wire shape
|
|
197
|
+
* `{ actionName, codeRef?, params }` — used for both single-step and chain
|
|
198
|
+
* rule executionParams. */
|
|
199
|
+
export declare const serializeAction: (action: RuleActionView) => {
|
|
200
|
+
actionName: string;
|
|
201
|
+
codeRef?: string;
|
|
202
|
+
params: Record<string, unknown>;
|
|
203
|
+
};
|
|
204
|
+
/** Build the `executionParams` payload from a list of actions.
|
|
205
|
+
*
|
|
206
|
+
* - 0 actions → `executionType: 'action'` with empty params.
|
|
207
|
+
* - 1 action, kind `SET_FIELD` → `executionType: 'set_field'` with
|
|
208
|
+
* `executionParams: { field, value }`. The CMS dispatcher (`_dispatch_target`'s
|
|
209
|
+
* `set_field` branch) only takes this dedicated path — emitting it as a
|
|
210
|
+
* plain `action` would land on the action-executor path, which requires a
|
|
211
|
+
* `code_ref` that `set_field` does not have.
|
|
212
|
+
* - 1 action, any other kind → `executionType: 'action'` with the
|
|
213
|
+
* `serializeAction(...)` shape (actionName + optional codeRef + params).
|
|
214
|
+
* - 2+ actions → `executionType: 'chain'` with `executionParams.steps[]`.
|
|
215
|
+
*/
|
|
216
|
+
export declare const actionsToExecutionParams: (actions: RuleActionView[]) => {
|
|
217
|
+
executionType: ExecutionType;
|
|
218
|
+
executionParams: Record<string, unknown>;
|
|
219
|
+
};
|
|
220
|
+
/** Read the action list back from a stored `ContentRule.executionParams`.
|
|
221
|
+
* Supports `set_field`, single-step `action`, and multi-step `chain`
|
|
222
|
+
* payloads. */
|
|
223
|
+
export declare const actionsFromExecution: (rule: {
|
|
224
|
+
executionType: ExecutionType | string;
|
|
225
|
+
executionParams?: Record<string, unknown> | null;
|
|
226
|
+
}) => RuleActionView[];
|
|
227
|
+
/**
|
|
228
|
+
* Event-payload fields for `triggerType === 'event'` rules. The CMS
|
|
229
|
+
* condition evaluator resolves dotted paths from the Kafka event payload
|
|
230
|
+
* (`event.data.*`) with a fallback to flat fields
|
|
231
|
+
* (`eaera_cms/core/rules/conditions.py:_resolve_field`). These are NOT
|
|
232
|
+
* ClickHouse metric fields — they come from the event itself.
|
|
233
|
+
*
|
|
234
|
+
* The dashboard tree builder emits these verbatim so the engine can resolve
|
|
235
|
+
* them at fire time. Source: `eaera-mt5/reference-v0/ch/ddl.py` payload
|
|
236
|
+
* schemas + `eaera-mt5/worker/tasks/realtime.py` event shapes.
|
|
237
|
+
*/
|
|
238
|
+
/** Top-level key of the event payload each field belongs to. */
|
|
239
|
+
export declare const EVENT_PAYLOAD_SOURCE: {
|
|
240
|
+
readonly DEAL: "deal";
|
|
241
|
+
readonly POSITION: "position";
|
|
242
|
+
readonly ORDER: "order";
|
|
243
|
+
};
|
|
244
|
+
export type EventPayloadSource = (typeof EVENT_PAYLOAD_SOURCE)[keyof typeof EVENT_PAYLOAD_SOURCE];
|
|
245
|
+
export interface EventPayloadField {
|
|
246
|
+
/** Backend dotted-path key, e.g. `deal.profit`. */
|
|
247
|
+
key: string;
|
|
248
|
+
/** Human label, e.g. `Deal Profit`. */
|
|
249
|
+
label: string;
|
|
250
|
+
/** Which event payload this field is sourced from. */
|
|
251
|
+
source: EventPayloadSource;
|
|
252
|
+
valueType: ConditionValueType;
|
|
253
|
+
unit: string;
|
|
254
|
+
}
|
|
255
|
+
export declare const EVENT_PAYLOAD_FIELDS: readonly EventPayloadField[];
|
|
256
|
+
/**
|
|
257
|
+
* Filter the event-payload catalog to a subset appropriate for an event type.
|
|
258
|
+
* The dashboard uses this to narrow the metric dropdown so a `deal_close`
|
|
259
|
+
* rule can only select `deal.*` fields, etc. Returns all fields if the event
|
|
260
|
+
* type doesn't have a known narrowing (e.g. `statement` falls back to CH
|
|
261
|
+
* catalog fields).
|
|
262
|
+
*/
|
|
263
|
+
export declare const eventPayloadFieldsFor: (_eventType: string | null | undefined) => readonly EventPayloadField[];
|
|
264
|
+
//# sourceMappingURL=conditions.d.ts.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Response, RuleCreatePayload, RuleListQuery, RuleUpdatePayload, SignalFireContext, SignalFireResponse } from './rules.type';
|
|
3
|
+
export interface IRulesServiceOptions {
|
|
4
|
+
/** The CMS `$Fetch` instance (one of `sdk.apis`). */
|
|
5
|
+
api: $Fetch;
|
|
6
|
+
/** Lazy flag — when true, the service returns fake data. */
|
|
7
|
+
mock: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface IRulesService {
|
|
10
|
+
list(query?: RuleListQuery): Promise<ContentRuleListResponse>;
|
|
11
|
+
detail(uuid: string): Promise<ContentRule>;
|
|
12
|
+
create(payload: RuleCreatePayload): Promise<ContentRule>;
|
|
13
|
+
update(uuid: string, payload: RuleUpdatePayload): Promise<ContentRule>;
|
|
14
|
+
remove(uuid: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Manually fire a signal rule (`POST /api/v1/rules/signals/fire`). Runs
|
|
17
|
+
* synchronously in the API pod — the canonical way to verify an action
|
|
18
|
+
* handler works without scheduling cron (cron + action is currently broken
|
|
19
|
+
* backend-side; see `risk-rules-api-guide.md` §8.F).
|
|
20
|
+
*
|
|
21
|
+
* Pass `options.timeoutMs` to override the SDK-wide 30s HTTP timeout
|
|
22
|
+
* (the API pod runs the rule synchronously and a multi-step action chain
|
|
23
|
+
* can exceed 30s on real traffic — the dashboard's "Fire now" dialog
|
|
24
|
+
* raises the ceiling to 120s by default).
|
|
25
|
+
*/
|
|
26
|
+
signalFire(signalName: string, context: SignalFireContext, options?: {
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
}): Promise<SignalFireResponse>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Content-rules service. CRUD over `/api/v1/rules`. Serves both FEAT-002
|
|
32
|
+
* (`conditionType: 'llm_agent'` skills) and FEAT-004 (expression/chain).
|
|
33
|
+
*
|
|
34
|
+
* Endpoint contract (`eaera_cms/core/rules/routes.py`):
|
|
35
|
+
* GET /api/v1/rules → list (no pagination; `total === items.length`)
|
|
36
|
+
* GET /api/v1/rules/{uuid} → single rule
|
|
37
|
+
* POST /api/v1/rules → create (flat payload)
|
|
38
|
+
* PUT /api/v1/rules/{uuid} → update
|
|
39
|
+
* DELETE /api/v1/rules/{uuid} → remove
|
|
40
|
+
* POST /api/v1/rules/signals/fire → fire a signal rule synchronously
|
|
41
|
+
*
|
|
42
|
+
* The route accepts the flat `RuleCreatePayload` (`TriggerCreateRequest`,
|
|
43
|
+
* `extra: allow`) and the service reads flat top-level keys. See rules.type.ts.
|
|
44
|
+
*
|
|
45
|
+
* While `mock()` returns true, all methods resolve against the local fake
|
|
46
|
+
* dataset and never touch `api`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createRulesService(opts: IRulesServiceOptions): IRulesService;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUrC,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,IAAI,EAAE,MAAM,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACvE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;;;;;;;;;OAUG;IACH,UAAU,CACR,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,aAAa,CA4C5E"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for `conditionType: 'llm_agent'` rule configuration.
|
|
3
|
+
*
|
|
4
|
+
* The `llm_agent` rule is composed of two parts:
|
|
5
|
+
* - **Prompt** — the user-facing Skill entity (`/api/v1/llm/prompts`).
|
|
6
|
+
* Owned by the Skills page. The rule references it via
|
|
7
|
+
* `trigger.sourceConfig.promptName`.
|
|
8
|
+
* - **Rule** — the `ContentRule` (owned by the Fixed Rules editor).
|
|
9
|
+
* Carries trigger mode, read-only MCP `queryTools` allowlist,
|
|
10
|
+
* `executionParams.llmEval` knobs (`maxIterations` / `budgetUsd`),
|
|
11
|
+
* and the `executionType`/`executionParams` shape (single action or
|
|
12
|
+
* action chain — same shape the fixed-rule builder emits).
|
|
13
|
+
*
|
|
14
|
+
* Reference: `risk-rules-api-guide.md` §7.B (LLM evaluator behaviour),
|
|
15
|
+
* §7.B Sample 7B.5 (canonical llm_agent payload), §8.B (rule editor knobs).
|
|
16
|
+
*/
|
|
17
|
+
/** The full read-only MCP tool set the evaluator accepts. The dashboard
|
|
18
|
+
* only ever offers these — the engine rejects anything else with
|
|
19
|
+
* `tool '…' is not available (read-only)`. */
|
|
20
|
+
export declare const LLM_QUERY_TOOL: {
|
|
21
|
+
readonly CONTENT_QUERY: "content_query";
|
|
22
|
+
readonly CONTENT_GET: "content_get";
|
|
23
|
+
readonly EXECUTE_REPORT: "execute_report";
|
|
24
|
+
readonly GET_SCHEMA: "get_schema";
|
|
25
|
+
readonly LIST_CTS: "list_cts";
|
|
26
|
+
readonly CH_QUERY: "ch_query";
|
|
27
|
+
};
|
|
28
|
+
/** Read-only MCP tool union — derived from {@link LLM_QUERY_TOOL}. */
|
|
29
|
+
export type LlmQueryTool = (typeof LLM_QUERY_TOOL)[keyof typeof LLM_QUERY_TOOL];
|
|
30
|
+
/** Human-labelled option for the queryTools multi-select. */
|
|
31
|
+
export interface LlmQueryToolOption {
|
|
32
|
+
label: string;
|
|
33
|
+
value: LlmQueryTool;
|
|
34
|
+
/** Short hint shown under the label — explains what the tool does. */
|
|
35
|
+
hint: string;
|
|
36
|
+
}
|
|
37
|
+
/** All {@link LlmQueryTool} options in the canonical order. */
|
|
38
|
+
export declare const LLM_QUERY_TOOL_OPTIONS: readonly LlmQueryToolOption[];
|
|
39
|
+
/** The minimum allowlist the engine recommends for scan-mode rules. */
|
|
40
|
+
export declare const DEFAULT_LLM_QUERY_TOOLS: readonly LlmQueryTool[];
|
|
41
|
+
/** Per-rule LLM-eval knobs. Bounds are enforced by
|
|
42
|
+
* `eaera_cms/core/rules/llm_evaluator.py`: `maxIterations` defaults to 5
|
|
43
|
+
* and is hard-capped at 20; `budgetUsd` defaults to 1.0 and is enforced
|
|
44
|
+
* before every LLM call; `maxTokens` caps the per-completion token output
|
|
45
|
+
* (no temperature — the backend does not accept it). */
|
|
46
|
+
export declare const LLM_EVAL_BOUNDS: {
|
|
47
|
+
readonly maxIterations: {
|
|
48
|
+
readonly min: 1;
|
|
49
|
+
readonly default: 5;
|
|
50
|
+
readonly max: 20;
|
|
51
|
+
};
|
|
52
|
+
readonly budgetUsd: {
|
|
53
|
+
readonly min: 0;
|
|
54
|
+
readonly default: 1;
|
|
55
|
+
};
|
|
56
|
+
readonly maxTokens: {
|
|
57
|
+
readonly min: 1;
|
|
58
|
+
readonly default: 1024;
|
|
59
|
+
readonly max: 32000;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/** Shape of `executionParams.llmEval` — the engine reads both fields at
|
|
63
|
+
* `LLMConditionEvaluator.run_iteration()` time. */
|
|
64
|
+
export interface LlmEval {
|
|
65
|
+
maxIterations: number;
|
|
66
|
+
budgetUsd: number;
|
|
67
|
+
/** Max tokens per completion. */
|
|
68
|
+
maxTokens?: number;
|
|
69
|
+
}
|
|
70
|
+
/** Read `executionParams.llmEval` from a stored rule, with defaults. */
|
|
71
|
+
export declare const llmEvalOf: (executionParams: Record<string, unknown> | null | undefined) => LlmEval;
|
|
72
|
+
/** Read `trigger.sourceConfig.queryTools` from a stored trigger.
|
|
73
|
+
*
|
|
74
|
+
* ⚠️ **Advisory only.** The dashboard persists the per-rule allowlist
|
|
75
|
+
* here, but `LLMConditionEvaluator` (`eaera-cms/core/rules/llm_evaluator.py`)
|
|
76
|
+
* uses its own hardcoded `_readonly_tool_names()` set today — the per-rule
|
|
77
|
+
* value is NOT yet honoured by the engine. The UI shows the checkbox grid
|
|
78
|
+
* and persists the choice so it's ready for the day the backend wires it
|
|
79
|
+
* through; until then, restricting this list has no runtime effect on the
|
|
80
|
+
* agent. Do not promise the user otherwise in the UI copy. */
|
|
81
|
+
export declare const queryToolsOf: (trigger: Record<string, unknown> | null | undefined) => LlmQueryTool[];
|
|
82
|
+
/** Read `trigger.sourceConfig.promptName` from a stored trigger. */
|
|
83
|
+
export declare const promptNameOf: (trigger: Record<string, unknown> | null | undefined) => string;
|
|
84
|
+
//# sourceMappingURL=llm-rule.constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-rule.constant.d.ts","sourceRoot":"","sources":["../../../src/services/rules/llm-rule.constant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;+CAE+C;AAC/C,eAAO,MAAM,cAAc;;;;;;;CAOjB,CAAC;AAEX,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEhF,6DAA6D;AAC7D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;IACpB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,EAAE,SAAS,kBAAkB,EA+B/D,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,EAAE,SAAS,YAAY,EAG1D,CAAC;AAEF;;;;yDAIyD;AACzD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;CAIlB,CAAC;AAEX;oDACoD;AACpD,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wEAAwE;AACxE,eAAO,MAAM,SAAS,GAAI,iBAAiB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG,OAYvF,CAAC;AAEF;;;;;;;;+DAQ+D;AAC/D,eAAO,MAAM,YAAY,GACvB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAClD,YAAY,EAOd,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG,MAIlF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContentRule, RuleCreatePayload, RuleListQuery } from './rules.type';
|
|
2
|
+
/**
|
|
3
|
+
* Fake rules dataset used while the CMS rules endpoints are under
|
|
4
|
+
* development. Covers both FEAT-002 (`llmAgent`) and FEAT-004
|
|
5
|
+
* (expression/chain) rule shapes.
|
|
6
|
+
*
|
|
7
|
+
* Field names use camelCase to match the backend API response. Action
|
|
8
|
+
* parameters are nested under `params` and `conditionExpr` references the
|
|
9
|
+
* real condition-field catalog (`account_state.*` / `account_metric_by_deal.*`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const MOCK_RULES: ContentRule[];
|
|
12
|
+
export declare function mockRuleList(query?: RuleListQuery): {
|
|
13
|
+
items: ContentRule[];
|
|
14
|
+
total: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function mockRuleDetail(uuid: string): ContentRule | undefined;
|
|
17
|
+
export declare function mockRuleCreate(payload: RuleCreatePayload): ContentRule;
|
|
18
|
+
export declare function mockRuleUpdate(uuid: string, patch: Partial<RuleCreatePayload>): ContentRule | undefined;
|
|
19
|
+
export declare function mockRuleRemove(uuid: string): boolean;
|
|
20
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/services/rules/mock.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElF;;;;;;;;GAQG;AAEH,eAAO,MAAM,UAAU,EAAE,WAAW,EAuHnC,CAAC;AAOF,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG;IACnD,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAUA;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEpE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAuBtE;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAChC,WAAW,GAAG,SAAS,CAkBzB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKpD"}
|