@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,262 @@
|
|
|
1
|
+
import { SerializationFormat } from '../../common/constants/http.constant';
|
|
2
|
+
import { TriggerTypeValue } from './triggers';
|
|
3
|
+
export type TriggerType = TriggerTypeValue;
|
|
4
|
+
/**
|
|
5
|
+
* Wire-level `trigger_type` union (schema-validated by
|
|
6
|
+
* `eaera_cms/core/rules/definitions.py:33-39`).
|
|
7
|
+
*
|
|
8
|
+
* Note this is **different** from the `source_type` value the engine matcher
|
|
9
|
+
* reads (`event_dto | cron | batch | stream | signal`). The canonical
|
|
10
|
+
* pair for event rules is `trigger_type: "event"` +
|
|
11
|
+
* `source_type: "event_dto"` — see `packs/registry.py:463-470` and the
|
|
12
|
+
* SDK `TRIGGER_TYPE` / `TRIGGER_MODE` constants in `triggers.ts`.
|
|
13
|
+
*
|
|
14
|
+
* Aliased to `TriggerType` via the `index.ts` barrel for backwards
|
|
15
|
+
* compatibility with consumers that imported it from this module.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* One row in `trigger.conditions[]` — the flat AND list the engine evaluates
|
|
19
|
+
* when `conditionType` is `'trigger_conds'` or omitted. The dashboard's visual
|
|
20
|
+
* tree builder (`LogicTree.vue`) emits these; backend-authored packs (`*.yaml`)
|
|
21
|
+
* emit them too. `field` is either a CH catalog key (`account_state.equity`),
|
|
22
|
+
* a dotted event-payload path (`deal.profit`), or a flat event field
|
|
23
|
+
* (`profit` — engine fallback).
|
|
24
|
+
*
|
|
25
|
+
* `operator` is one of the word forms exposed by the SDK
|
|
26
|
+
* (`CONDITION_OPERATORS`: `gt`/`gte`/`lt`/`lte`/`eq`/`ne`/`in`/`not_in`/
|
|
27
|
+
* `contains`/`startswith`/`endswith`/`is_null`/`is_not_null`) plus the
|
|
28
|
+
* cron-specific `sum_within_days` (carries a numeric `days` window).
|
|
29
|
+
*
|
|
30
|
+
* `value` shape depends on the operator — see
|
|
31
|
+
* `cms-sdk/src/services/rules/conditions.ts:CONDITION_OPERATOR_VALUE_KINDS`:
|
|
32
|
+
* - numeric operators → number
|
|
33
|
+
* - `in` / `not_in` → array of primitives
|
|
34
|
+
* - string operators → string (entity is coerced via `str()`)
|
|
35
|
+
* - `is_null` / `is_not_null` → ignored (send `null`)
|
|
36
|
+
* - `sum_within_days` → number (threshold), `days` is the window
|
|
37
|
+
*/
|
|
38
|
+
export interface TriggerConditionRow {
|
|
39
|
+
field: string;
|
|
40
|
+
operator: string;
|
|
41
|
+
value: unknown;
|
|
42
|
+
/** Cron-only: window size for `sum_within_days`. */
|
|
43
|
+
days?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface TriggerDefinition {
|
|
46
|
+
/**
|
|
47
|
+
* The backend SQL filter (`trigger_api.py:fire_signal`) and engine matcher
|
|
48
|
+
* (`engine.py:_match_trigger`) read `trigger.source_type`, NOT
|
|
49
|
+
* `trigger.trigger_type`. Builders in `triggers.ts` emit BOTH
|
|
50
|
+
* `sourceType` and `triggerType` (camelCase) so the CMS casing middleware
|
|
51
|
+
* produces both keys in the stored JSONB.
|
|
52
|
+
*
|
|
53
|
+
* IMPORTANT: for event rules the two values DIVERGE — see the canonical
|
|
54
|
+
* contract documented on `TRIGGER_MODE` / `TRIGGER_TYPE` in
|
|
55
|
+
* `cms-sdk/src/services/rules/triggers.ts`. `sourceType: 'event_dto'`
|
|
56
|
+
* (engine matcher), `triggerType: 'event'` (schema validator). Earlier
|
|
57
|
+
* SDK builds emitted both as `'event_dto'`, which drifted from the
|
|
58
|
+
* pack-authored contract.
|
|
59
|
+
*/
|
|
60
|
+
sourceType?: 'event_dto' | 'cron' | 'batch' | 'stream' | 'signal';
|
|
61
|
+
triggerType: TriggerType;
|
|
62
|
+
topic?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Top-level AND condition list. Backend reads this when
|
|
65
|
+
* `conditionType` is `'trigger_conds'` (or omitted). Dashboard tree
|
|
66
|
+
* builder emits here; the Fixed Rules editor's `trigger_conds` path
|
|
67
|
+
* goes through here too.
|
|
68
|
+
*/
|
|
69
|
+
conditions?: TriggerConditionRow[];
|
|
70
|
+
/**
|
|
71
|
+
* Type-specific trigger config ONLY — e.g. `signalName`, `topic`, `schedule`,
|
|
72
|
+
* `timezone`, `streamName`, `windowSeconds`, `contentTypes`, `eventTypes`,
|
|
73
|
+
* `promptName` (LLM rules), `queryTools` (LLM rules).
|
|
74
|
+
*
|
|
75
|
+
* There is **no `scope` concept** on a rule. A rule is scoped by `contentType`
|
|
76
|
+
* + trigger-source matching + the `conditionExpr`; do not write a `scope`
|
|
77
|
+
* (`groups`/`symbols`/`logins`/`emails`) key here — the backend ignores it.
|
|
78
|
+
*/
|
|
79
|
+
sourceConfig: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
/** Value-level constants for ConditionType — single source of truth. */
|
|
82
|
+
export declare const CONDITION_TYPE: {
|
|
83
|
+
readonly EXPRESSION: "expression";
|
|
84
|
+
readonly CODE: "code";
|
|
85
|
+
readonly LLM_AGENT: "llm_agent";
|
|
86
|
+
readonly TRIGGER_CONDS: "trigger_conds";
|
|
87
|
+
};
|
|
88
|
+
/** Condition type — derived from {@link CONDITION_TYPE}. */
|
|
89
|
+
export type ConditionType = (typeof CONDITION_TYPE)[keyof typeof CONDITION_TYPE];
|
|
90
|
+
/** Value-level constants for ExecutionType — single source of truth. */
|
|
91
|
+
export declare const EXECUTION_TYPE: {
|
|
92
|
+
readonly ACTION: "action";
|
|
93
|
+
readonly SET_FIELD: "set_field";
|
|
94
|
+
readonly NOTIFY: "notify";
|
|
95
|
+
readonly TRANSITION: "transition";
|
|
96
|
+
readonly HTTP_CALL: "http_call";
|
|
97
|
+
readonly CHAIN: "chain";
|
|
98
|
+
};
|
|
99
|
+
/** Execution type — derived from {@link EXECUTION_TYPE}. */
|
|
100
|
+
export type ExecutionType = (typeof EXECUTION_TYPE)[keyof typeof EXECUTION_TYPE];
|
|
101
|
+
/**
|
|
102
|
+
* One action invocation. The dispatcher reads `actionName` and a **nested**
|
|
103
|
+
* `params`; e.g. a group move is `{ actionName: 'change_group', params: { newGroup } }`
|
|
104
|
+
* and a leverage change is `{ actionName: 'change_leverage', params: { newLeverage } }`.
|
|
105
|
+
*/
|
|
106
|
+
export interface ActionExecutionParams {
|
|
107
|
+
actionName: string;
|
|
108
|
+
/** Action-specific payload (`{ newGroup }` / `{ newLeverage }`). */
|
|
109
|
+
params: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* One step in an ordered action chain. Each step dispatches via its own
|
|
113
|
+
* `type` (any `ExecutionType` except `chain`); an `action` step uses
|
|
114
|
+
* {@link ActionExecutionParams} as its `params`.
|
|
115
|
+
*/
|
|
116
|
+
export interface ChainStep {
|
|
117
|
+
type: Exclude<ExecutionType, typeof EXECUTION_TYPE.CHAIN>;
|
|
118
|
+
params: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Flat execution params stored on `ContentRule.executionParams`. The backend
|
|
122
|
+
* dispatcher (`dispatch_target`) selects behaviour by `executionType`:
|
|
123
|
+
*
|
|
124
|
+
* - `action` → `{ actionName, params }`
|
|
125
|
+
* - `set_field` → `{ field, value }`
|
|
126
|
+
* - `notify` → `{ data?, notificationType?, recipient? }`
|
|
127
|
+
* - `transition`→ `{ transitionName, params }`
|
|
128
|
+
* - `http_call` → `{ url, method?, params?, headers?, timeout? }`
|
|
129
|
+
* - `chain` → `{ steps: ChainStep[], stepParams?: Record<string, Record<string, unknown>> }`
|
|
130
|
+
*
|
|
131
|
+
* Action parameters are **nested** under `params` — `{ actionName, newGroup }`
|
|
132
|
+
* (flat) is silently dropped. See {@link ActionExecutionParams}.
|
|
133
|
+
*/
|
|
134
|
+
export interface ExecutionParams {
|
|
135
|
+
actionName?: string;
|
|
136
|
+
params?: Record<string, unknown>;
|
|
137
|
+
field?: string;
|
|
138
|
+
value?: unknown;
|
|
139
|
+
data?: Record<string, unknown>;
|
|
140
|
+
notificationType?: string;
|
|
141
|
+
recipient?: string;
|
|
142
|
+
transitionName?: string;
|
|
143
|
+
url?: string;
|
|
144
|
+
method?: string;
|
|
145
|
+
headers?: Record<string, string>;
|
|
146
|
+
timeout?: number;
|
|
147
|
+
steps?: ChainStep[];
|
|
148
|
+
stepParams?: Record<string, Record<string, unknown>>;
|
|
149
|
+
[key: string]: unknown;
|
|
150
|
+
}
|
|
151
|
+
/** POST /api/v1/rules body (flat — matches `create_trigger()`). */
|
|
152
|
+
export interface RuleCreatePayload {
|
|
153
|
+
name: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
/** `null`/omitted = global rule. Backend reads `contentType`, not `typeName`. */
|
|
156
|
+
contentType?: string | null;
|
|
157
|
+
trigger: TriggerDefinition;
|
|
158
|
+
/** Default `'expression'`. */
|
|
159
|
+
conditionType?: ConditionType;
|
|
160
|
+
/** Inline Python expression (conditionType=expression). */
|
|
161
|
+
conditionExpr?: string | null;
|
|
162
|
+
/** Full Python code block (conditionType=code). */
|
|
163
|
+
conditionCode?: string | null;
|
|
164
|
+
/** Default `'action'`. */
|
|
165
|
+
executionType?: ExecutionType;
|
|
166
|
+
executionParams?: ExecutionParams | null;
|
|
167
|
+
cronSchedule?: string | null;
|
|
168
|
+
cronTimeZone?: string | null;
|
|
169
|
+
/** Default `0`. */
|
|
170
|
+
priority?: number;
|
|
171
|
+
/** Default `true`. */
|
|
172
|
+
isActive?: boolean;
|
|
173
|
+
/** 1-3600, default 30. */
|
|
174
|
+
timeoutSeconds?: number;
|
|
175
|
+
}
|
|
176
|
+
/** PUT /api/v1/rules/{uuid} body (all optional, same flat keys). */
|
|
177
|
+
export interface RuleUpdatePayload {
|
|
178
|
+
name?: string;
|
|
179
|
+
description?: string;
|
|
180
|
+
contentType?: string | null;
|
|
181
|
+
trigger?: TriggerDefinition;
|
|
182
|
+
conditionType?: ConditionType;
|
|
183
|
+
conditionExpr?: string | null;
|
|
184
|
+
conditionCode?: string | null;
|
|
185
|
+
executionType?: ExecutionType;
|
|
186
|
+
executionParams?: ExecutionParams | null;
|
|
187
|
+
priority?: number;
|
|
188
|
+
isActive?: boolean;
|
|
189
|
+
timeoutSeconds?: number;
|
|
190
|
+
}
|
|
191
|
+
/** GET /api/v1/rules, GET /api/v1/rules/{uuid} (`ContentRuleResponse`). */
|
|
192
|
+
export interface ContentRule {
|
|
193
|
+
id: number;
|
|
194
|
+
uuid: string;
|
|
195
|
+
name: string;
|
|
196
|
+
description?: string | null;
|
|
197
|
+
/** Echoes `contentType` on the response. */
|
|
198
|
+
typeName?: string | null;
|
|
199
|
+
/** Default `'python'`. */
|
|
200
|
+
codeType: string;
|
|
201
|
+
/** AES-256-GCM encrypted. */
|
|
202
|
+
conditionCode?: string | null;
|
|
203
|
+
conditionType?: ConditionType;
|
|
204
|
+
conditionExpr?: string | null;
|
|
205
|
+
/** Inline trigger JSONB (`{ sourceType, sourceConfig, conditions, settings }`). */
|
|
206
|
+
trigger: Record<string, unknown>;
|
|
207
|
+
executionType: ExecutionType;
|
|
208
|
+
executionParams?: Record<string, unknown> | null;
|
|
209
|
+
priority: number;
|
|
210
|
+
isActive: boolean;
|
|
211
|
+
timeoutSeconds: number;
|
|
212
|
+
/** Cron: top-level normalized schedule. Dashboard emits via
|
|
213
|
+
* `trigger.sourceConfig.schedule`; the backend reads both. */
|
|
214
|
+
cronSchedule?: string | null;
|
|
215
|
+
cronTimezone?: string | null;
|
|
216
|
+
/** ISO 8601. */
|
|
217
|
+
nextTriggerAt?: string | null;
|
|
218
|
+
/** ISO 8601 — FEAT-004 sidebar "last triggered". */
|
|
219
|
+
lastFiredAt?: string | null;
|
|
220
|
+
packId?: string | null;
|
|
221
|
+
createdBy?: number | null;
|
|
222
|
+
updatedBy?: number | null;
|
|
223
|
+
createdAt?: string | null;
|
|
224
|
+
updatedAt?: string | null;
|
|
225
|
+
}
|
|
226
|
+
export interface ContentRuleListResponse {
|
|
227
|
+
items: ContentRule[];
|
|
228
|
+
/** `=== items.length` — the list endpoint does NOT paginate. */
|
|
229
|
+
total: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Signal-fire context (`POST /api/v1/rules/signals/fire`). Carries the target
|
|
233
|
+
* account + any extra payload the engine/condition evaluator reads. A `null`
|
|
234
|
+
* `contentUuid` means scan-mode (the LLM discovers candidates itself).
|
|
235
|
+
*/
|
|
236
|
+
export interface SignalFireContext {
|
|
237
|
+
/** Content type of the target (e.g. `'Mt5Account'`). */
|
|
238
|
+
typeName?: string;
|
|
239
|
+
/** Target account UUID, or `null` for scan-mode `llm_agent` rules. */
|
|
240
|
+
contentUuid?: string | null;
|
|
241
|
+
/** Extra payload (e.g. `{ serverName, login }`). */
|
|
242
|
+
data?: Record<string, unknown>;
|
|
243
|
+
}
|
|
244
|
+
/** `POST /api/v1/rules/signals/fire` response. */
|
|
245
|
+
export interface SignalFireResponse {
|
|
246
|
+
/** Number of rules that matched and were dispatched. */
|
|
247
|
+
triggeredCount: number;
|
|
248
|
+
/** UUIDs of the matched rules. */
|
|
249
|
+
matchedRules: string[];
|
|
250
|
+
}
|
|
251
|
+
/** Query params for GET /api/v1/rules (route-level Query() params; no limit/offset). */
|
|
252
|
+
export interface RuleListQuery {
|
|
253
|
+
sourceType?: string;
|
|
254
|
+
executionType?: ExecutionType;
|
|
255
|
+
/** contentType filter. */
|
|
256
|
+
typeName?: string;
|
|
257
|
+
isActive?: boolean;
|
|
258
|
+
/** UUID or slug (FEAT-008 v1.1). */
|
|
259
|
+
packId?: string;
|
|
260
|
+
format?: SerializationFormat;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=rules.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.type.d.ts","sourceRoot":"","sources":["../../../src/services/rules/rules.type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAg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C;AAED,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wFAAwF;AACxF,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { TriggerDefinition, TriggerType } from './rules.type';
|
|
2
|
+
/** Value-level constants for trigger modes (the *builder* view used by the
|
|
3
|
+
* dashboard UI). Each entry's string is the *backend* `source_type` value
|
|
4
|
+
* read off `ContentRule.trigger` by `engine.py:_match_trigger` and the SQL
|
|
5
|
+
* filter at `trigger_api.py:fire_signal`:
|
|
6
|
+
*
|
|
7
|
+
* - `SIGNAL` → `"signal"` (API pod, `POST /api/v1/rules/signals/fire`).
|
|
8
|
+
* - `CRON` → `"cron"` (cron evaluator pod).
|
|
9
|
+
* - `EVENT` → `"event_dto"` (NOT `"event"` — the engine matcher reads
|
|
10
|
+
* `source_type` as `"event_dto"`).
|
|
11
|
+
*
|
|
12
|
+
* Use {@link TRIGGER_TYPE} for the wire-level `trigger_type` value (which
|
|
13
|
+
* uses `"event"`, not `"event_dto"`). */
|
|
14
|
+
export declare const TRIGGER_MODE: {
|
|
15
|
+
readonly SIGNAL: "signal";
|
|
16
|
+
readonly CRON: "cron";
|
|
17
|
+
readonly EVENT: "event_dto";
|
|
18
|
+
};
|
|
19
|
+
/** The trigger modes the dashboard builders author — derived from {@link TRIGGER_MODE}. */
|
|
20
|
+
export type TriggerMode = (typeof TRIGGER_MODE)[keyof typeof TRIGGER_MODE];
|
|
21
|
+
/** Value-level constants for the *wire-level* `trigger_type` field (the
|
|
22
|
+
* schema-validated field on `TriggerDefinition`,
|
|
23
|
+
* `eaera_cms/core/rules/definitions.py:33-39`).
|
|
24
|
+
*
|
|
25
|
+
* For event rules the wire value is `"event"`, NOT `"event_dto"` — the
|
|
26
|
+
* latter is the `source_type` value. The two diverge on purpose; the
|
|
27
|
+
* pack loader emits `trigger_type: "event"` + `source_type: "event_dto"`
|
|
28
|
+
* (`packs/registry.py:463-470`).
|
|
29
|
+
*
|
|
30
|
+
* - `SIGNAL` → `"signal"`
|
|
31
|
+
* - `CRON` → `"cron"`
|
|
32
|
+
* - `EVENT` → `"event"`
|
|
33
|
+
* - `STREAM` → `"stream"` (backend-only — no SDK builder). */
|
|
34
|
+
export declare const TRIGGER_TYPE: {
|
|
35
|
+
readonly SIGNAL: "signal";
|
|
36
|
+
readonly CRON: "cron";
|
|
37
|
+
readonly EVENT: "event";
|
|
38
|
+
readonly STREAM: "stream";
|
|
39
|
+
};
|
|
40
|
+
/** The wire-level `trigger_type` union — derived from {@link TRIGGER_TYPE}. */
|
|
41
|
+
export type TriggerTypeValue = (typeof TRIGGER_TYPE)[keyof typeof TRIGGER_TYPE];
|
|
42
|
+
/** The Kafka `content.events` event types the trigger pod subscribes to.
|
|
43
|
+
*
|
|
44
|
+
* Authoritative list — `eaera-mt5/eaera_mt5/pipeline/event_publisher.py` (the
|
|
45
|
+
* four MT5 pipeline publishers) and `eaera-mt5/worker/sync/account_sync.py`
|
|
46
|
+
* (`_emit_account_upsert_events`). The CMS schema validator does not whitelist
|
|
47
|
+
* the value (any string is accepted), but the engine matcher and the
|
|
48
|
+
* `Mt5AccountSyncService` only act on these five. */
|
|
49
|
+
export declare const EVENT_TYPE: {
|
|
50
|
+
readonly DEAL_CLOSE: "deal_close";
|
|
51
|
+
readonly STATEMENT: "statement";
|
|
52
|
+
readonly POSITION: "position";
|
|
53
|
+
readonly ORDER: "order";
|
|
54
|
+
/** FEAT-009 identity-provisioning bridge — emitted by the MT5 `account_sync`
|
|
55
|
+
* worker whenever an account is upserted. The trigger service ALSO
|
|
56
|
+
* auto-upserts an `Mt5Account` content row on `(server_name, login)` via
|
|
57
|
+
* `Mt5AccountSyncService` before evaluating rules. Common use: provision
|
|
58
|
+
* a CMS user when the account email is present (the live `user_sync` rule
|
|
59
|
+
* uses `event: 'mt5_account_upsert'` + `trigger.conditions: [email contains '@']`). */
|
|
60
|
+
readonly MT5_ACCOUNT_UPSERT: "mt5_account_upsert";
|
|
61
|
+
};
|
|
62
|
+
/** Event type union — derived from {@link EVENT_TYPE}. */
|
|
63
|
+
export type EventType = (typeof EVENT_TYPE)[keyof typeof EVENT_TYPE];
|
|
64
|
+
/** A labelled option for the event-payload picker. */
|
|
65
|
+
export interface EventTypeOption {
|
|
66
|
+
label: string;
|
|
67
|
+
value: EventType;
|
|
68
|
+
/** Short human hint shown in tooltips / Data Set reference. */
|
|
69
|
+
hint?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Human labels for the {@link EVENT_TYPE} options. */
|
|
72
|
+
export declare const EVENT_TYPE_OPTIONS: readonly EventTypeOption[];
|
|
73
|
+
/** Helper: true iff the given string is a known event type. */
|
|
74
|
+
export declare const isKnownEventType: (raw: unknown) => raw is EventType;
|
|
75
|
+
/** Coerce an arbitrary event-type string (e.g. from a stored `sourceConfig.event`)
|
|
76
|
+
* to a known {@link EventType}. Falls back to {@link EVENT_TYPE.DEAL_CLOSE} for
|
|
77
|
+
* unknown / missing values so the rule editor always has a valid pick. */
|
|
78
|
+
export declare const coerceEventType: (raw: unknown) => EventType;
|
|
79
|
+
/** A labelled cron preset for the schedule picker. */
|
|
80
|
+
export interface CronPreset {
|
|
81
|
+
label: string;
|
|
82
|
+
value: string;
|
|
83
|
+
}
|
|
84
|
+
/** Human cron presets (standard 5-field expressions). */
|
|
85
|
+
export declare const CRON_PRESETS: readonly CronPreset[];
|
|
86
|
+
/** Default cron schedule when none is provided (skills' historical default). */
|
|
87
|
+
export declare const DEFAULT_CRON_SCHEDULE = "*/5 * * * *";
|
|
88
|
+
/** Default Kafka topic for event triggers. Sourced from `CONTENT_TYPE.MT5_ACCOUNT`. */
|
|
89
|
+
export declare const DEFAULT_EVENT_CONTENT_TYPE: "Mt5Account";
|
|
90
|
+
/** Build a signal trigger over the metric stream.
|
|
91
|
+
*
|
|
92
|
+
* Emits the canonical pair:
|
|
93
|
+
* - `triggerType: 'signal'` (schema-validated)
|
|
94
|
+
* - `sourceType: 'signal'` (engine matcher)
|
|
95
|
+
*
|
|
96
|
+
* Both are the same value for signal rules. */
|
|
97
|
+
export declare const buildSignalTrigger: (signalName: string) => TriggerDefinition;
|
|
98
|
+
/**
|
|
99
|
+
* Build a cron trigger. `schedule` is a standard 5-field cron expression;
|
|
100
|
+
* `extra` is merged into `sourceConfig` (e.g. skills pass `promptName` /
|
|
101
|
+
* `queryTools`).
|
|
102
|
+
*
|
|
103
|
+
* Emits the canonical pair:
|
|
104
|
+
* - `triggerType: 'cron'` (schema-validated)
|
|
105
|
+
* - `sourceType: 'cron'` (engine matcher)
|
|
106
|
+
*/
|
|
107
|
+
export declare const buildCronTrigger: (schedule: string, extra?: Record<string, unknown>, timezone?: string) => TriggerDefinition;
|
|
108
|
+
/**
|
|
109
|
+
* Build an event trigger on the Kafka `content.events` topic.
|
|
110
|
+
*
|
|
111
|
+
* Emits the canonical pair — NOT the same value on both fields:
|
|
112
|
+
* - `triggerType: 'event'` (schema-validated, `definitions.py:36`)
|
|
113
|
+
* - `sourceType: 'event_dto'` (engine matcher, `engine.py:369`)
|
|
114
|
+
*
|
|
115
|
+
* Earlier SDK builds emitted both as `"event_dto"`, which passed engine
|
|
116
|
+
* matching but drifted from the canonical pack-authored contract
|
|
117
|
+
* (`packs/registry.py:463-470`). This builder now emits the correct pair.
|
|
118
|
+
*
|
|
119
|
+
* The `event` (singular) and `eventTypes`/`contentTypes` (plural) shapes
|
|
120
|
+
* are both stored so the engine reads either form.
|
|
121
|
+
*/
|
|
122
|
+
export declare const buildEventTrigger: (event: EventType, contentType?: string, extra?: Record<string, unknown>) => TriggerDefinition;
|
|
123
|
+
/** Derive the builder trigger mode from a stored `ContentRule.trigger`.
|
|
124
|
+
*
|
|
125
|
+
* Accepts BOTH the camelCase fields the SDK writes (`sourceType`,
|
|
126
|
+
* `triggerType`) and the snake_case JSONB keys the backend reads
|
|
127
|
+
* (`source_type`, `trigger_type`) so rules authored before the trigger
|
|
128
|
+
* wire-shape fix still load in the Fixed Rules editor without showing up
|
|
129
|
+
* as the wrong mode.
|
|
130
|
+
*
|
|
131
|
+
* Both `source_type === "event_dto"` (engine matcher) and `trigger_type
|
|
132
|
+
* === "event"` (schema-validated) map to the builder's `EVENT` mode. */
|
|
133
|
+
export declare const triggerModeOf: (trigger: TriggerDefinition | Record<string, unknown> | null | undefined) => TriggerMode;
|
|
134
|
+
/** Read the cron `schedule` out of a stored `ContentRule.trigger`. */
|
|
135
|
+
export declare const scheduleOf: (trigger: TriggerDefinition | Record<string, unknown> | null | undefined) => string;
|
|
136
|
+
/** Read the signal `signalName` out of a stored `ContentRule.trigger`. */
|
|
137
|
+
export declare const signalNameOf: (trigger: TriggerDefinition | Record<string, unknown> | null | undefined) => string;
|
|
138
|
+
export type { TriggerType };
|
|
139
|
+
export { TRIGGER_TYPE as TRIGGER_TYPE_VALUE };
|
|
140
|
+
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../src/services/rules/triggers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEnE;;;;;;;;;;;0CAW0C;AAC1C,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,2FAA2F;AAC3F,MAAM,MAAM,WAAW,GAA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MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACnC,WAAW,MAAM,KAChB,iBAID,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,SAAS,EAChB,cAAa,MAAmC,EAChD,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KAClC,iBASD,CAAC;AAEH;;;;;;;;;yEASyE;AACzE,eAAO,MAAM,aAAa,GACxB,SAAS,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KACtE,WAoBF,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,UAAU,GACrB,SAAS,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KACtE,MAKF,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,YAAY,GACvB,SAAS,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KACtE,MAKF,CAAC;AAEF,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { $Fetch } from 'ofetch';
|
|
2
|
+
import { IPublicMarketsData } from './settings.type';
|
|
3
|
+
export interface ISettingsServiceOptions {
|
|
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 ISettingsService {
|
|
10
|
+
getMonitoredGroups(): Promise<string[]>;
|
|
11
|
+
setMonitoredGroups(groups: string[]): Promise<string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Anonymous UI defaults from `setting.public.markets` (api-inventory §5.7.5):
|
|
14
|
+
* the default MT5 server id + the curated common-symbol list (order is
|
|
15
|
+
* significant). Readable without a JWT — the backend returns the schema
|
|
16
|
+
* defaults when no record has been written yet.
|
|
17
|
+
*/
|
|
18
|
+
getPublicMarkets(): Promise<IPublicMarketsData>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Settings service. The CMS is the source of truth for monitored groups;
|
|
22
|
+
* the service reads/writes the generic setting
|
|
23
|
+
* `setting.dashboard.monitored_groups`.
|
|
24
|
+
*
|
|
25
|
+
* Endpoint contract (`eaera_cms/settings/routes.py`):
|
|
26
|
+
* GET /api/v1/settings/{typeName} → { typeName, displayName, data, exists }
|
|
27
|
+
* PUT /api/v1/settings/{typeName} → { ..., data } (body = key/value pairs)
|
|
28
|
+
*
|
|
29
|
+
* NOTE: the CT `setting.dashboard.monitored_groups` (schema `{ groups: string[] }`)
|
|
30
|
+
* must be registered in the CMS settings catalog for these calls to succeed.
|
|
31
|
+
*
|
|
32
|
+
* While `mock()` returns true, all methods resolve against the local fake
|
|
33
|
+
* dataset and never touch `api`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createSettingsService(opts: ISettingsServiceOptions): ISettingsService;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/settings/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOrC,OAAO,KAAK,EAGV,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,IAAI,EAAE,MAAM,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD;;;;;OAKG;IACH,gBAAgB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,GAAG,gBAAgB,CA+BrF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Fake monitored-groups set used while the settings endpoint is under development. */
|
|
2
|
+
export declare const MOCK_MONITORED_GROUPS: string[];
|
|
3
|
+
export declare function mockGetMonitoredGroups(): string[];
|
|
4
|
+
export declare function mockSetMonitoredGroups(groups: string[]): string[];
|
|
5
|
+
/** Fake public-markets payload (mirrors the schema defaults in api-inventory §5.7.5). */
|
|
6
|
+
export declare const MOCK_PUBLIC_MARKETS: {
|
|
7
|
+
readonly defaultServer: "live";
|
|
8
|
+
readonly commonSymbols: readonly ["EURUSD", "GBPUSD", "USDJPY", "XAUUSD", "XAGUSD", "BTCUSD", "ETHUSD"];
|
|
9
|
+
};
|
|
10
|
+
export declare function mockGetPublicMarkets(): {
|
|
11
|
+
defaultServer: string;
|
|
12
|
+
commonSymbols: string[];
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/services/settings/mock.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAIzC,CAAC;AAKF,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGjE;AAED,yFAAyF;AACzF,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,wBAAgB,oBAAoB,IAAI;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAKA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard settings types. v1 covers only monitored groups (FEAT-006),
|
|
3
|
+
* persisted as a generic CMS setting of type `setting.dashboard.monitored_groups`.
|
|
4
|
+
*
|
|
5
|
+
* All field names use camelCase to match the backend API response.
|
|
6
|
+
*/
|
|
7
|
+
/** Generic setting response envelope (`GET/PUT /api/v1/settings/{typeName}`). */
|
|
8
|
+
export interface ISettingResponse<T = Record<string, unknown>> {
|
|
9
|
+
typeName: string;
|
|
10
|
+
displayName?: string;
|
|
11
|
+
data: T;
|
|
12
|
+
/** `false` when the CT exists but no record has been written yet. */
|
|
13
|
+
exists: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Monitored-groups setting data. */
|
|
16
|
+
export interface IMonitoredGroupsData {
|
|
17
|
+
groups: string[];
|
|
18
|
+
}
|
|
19
|
+
/** Convenience alias for the monitored-groups setting envelope. */
|
|
20
|
+
export type IMonitoredGroupsResponse = ISettingResponse<IMonitoredGroupsData>;
|
|
21
|
+
/** Payload for PUT /api/v1/settings/{typeName} (key/value pairs). */
|
|
22
|
+
export interface IMonitoredGroupsPayload {
|
|
23
|
+
groups: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Public-markets setting data (api-inventory §5.7.5) — anonymous UI defaults.
|
|
27
|
+
*/
|
|
28
|
+
export interface IPublicMarketsData {
|
|
29
|
+
/** MT5 server id for anonymous symbol / chart / WS requests (e.g. `'live'`). */
|
|
30
|
+
defaultServer: string;
|
|
31
|
+
/**
|
|
32
|
+
* Curated symbol names for the anonymous markets strip. Order is
|
|
33
|
+
* significant (display order = array order).
|
|
34
|
+
*/
|
|
35
|
+
commonSymbols: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Convenience alias for the public-markets setting envelope. */
|
|
38
|
+
export type IPublicMarketsResponse = ISettingResponse<IPublicMarketsData>;
|
|
39
|
+
//# sourceMappingURL=settings.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.type.d.ts","sourceRoot":"","sources":["../../../src/services/settings/settings.type.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iFAAiF;AACjF,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC;IACR,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,qCAAqC;AACrC,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AAE9E,qEAAqE;AACrE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,iEAAiE;AACjE,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAC"}
|