@reyaxyz/strategy-format 0.0.0-stage → 0.3.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.md +1 -0
- package/README.md +50 -2
- package/dist/en.json +212 -0
- package/dist/hash.d.ts +8 -0
- package/dist/hash.js +30 -0
- package/dist/index.d.ts +1814 -0
- package/dist/index.js +55 -0
- package/dist/lines.d.ts +138 -0
- package/dist/lines.js +516 -0
- package/dist/lines.json +287 -0
- package/dist/read.d.ts +21 -0
- package/dist/read.js +330 -0
- package/dist/schema/source.json +9 -0
- package/dist/schema/workflow-v3.accepted-kinds.json +226 -0
- package/dist/schema/workflow-v3.schema.json +1758 -0
- package/dist/sentences.d.ts +23 -0
- package/dist/sentences.js +553 -0
- package/dist/types.d.ts +242 -0
- package/dist/types.js +5 -0
- package/package.json +43 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.WHAT_IF_RESPONSES = exports.whatIfLine = exports.gradedFigure = exports.READ_OUTS = exports.END_REASONS = exports.PAPER_LINES = exports.endedLine = exports.ENTRY_DROPPED = exports.ACTIVITY_NOT_LISTED = exports.ACTIVITY_CODES = exports.activityLine = exports.NEEDS_YOU_CODES = exports.needsYouLine = exports.FOLLOW_ONS = exports.LINES = exports.lineId = exports.line = exports.sentences = exports.schemaSource = exports.acceptedKinds = exports.workflowV3Schema = exports.versionHash = exports.canonical = exports.MAX_DOCUMENT_BYTES = exports.readStrategy = void 0;
|
|
21
|
+
const workflow_v3_schema_json_1 = __importDefault(require("./schema/workflow-v3.schema.json"));
|
|
22
|
+
const workflow_v3_accepted_kinds_json_1 = __importDefault(require("./schema/workflow-v3.accepted-kinds.json"));
|
|
23
|
+
const source_json_1 = __importDefault(require("./schema/source.json"));
|
|
24
|
+
var read_1 = require("./read");
|
|
25
|
+
Object.defineProperty(exports, "readStrategy", { enumerable: true, get: function () { return read_1.readStrategy; } });
|
|
26
|
+
Object.defineProperty(exports, "MAX_DOCUMENT_BYTES", { enumerable: true, get: function () { return read_1.MAX_DOCUMENT_BYTES; } });
|
|
27
|
+
var hash_1 = require("./hash");
|
|
28
|
+
Object.defineProperty(exports, "canonical", { enumerable: true, get: function () { return hash_1.canonical; } });
|
|
29
|
+
Object.defineProperty(exports, "versionHash", { enumerable: true, get: function () { return hash_1.versionHash; } });
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
31
|
+
// Plain assignments, which Node 22's CommonJS lexer finds for an ES module's named import; a
|
|
32
|
+
// re-export of the JSON default compiles to a getter it misses (tests/esm.test.ts).
|
|
33
|
+
exports.workflowV3Schema = workflow_v3_schema_json_1.default;
|
|
34
|
+
exports.acceptedKinds = workflow_v3_accepted_kinds_json_1.default;
|
|
35
|
+
exports.schemaSource = source_json_1.default;
|
|
36
|
+
var sentences_1 = require("./sentences");
|
|
37
|
+
Object.defineProperty(exports, "sentences", { enumerable: true, get: function () { return sentences_1.sentences; } });
|
|
38
|
+
var lines_1 = require("./lines");
|
|
39
|
+
Object.defineProperty(exports, "line", { enumerable: true, get: function () { return lines_1.line; } });
|
|
40
|
+
Object.defineProperty(exports, "lineId", { enumerable: true, get: function () { return lines_1.lineId; } });
|
|
41
|
+
Object.defineProperty(exports, "LINES", { enumerable: true, get: function () { return lines_1.LINES; } });
|
|
42
|
+
Object.defineProperty(exports, "FOLLOW_ONS", { enumerable: true, get: function () { return lines_1.FOLLOW_ONS; } });
|
|
43
|
+
Object.defineProperty(exports, "needsYouLine", { enumerable: true, get: function () { return lines_1.needsYouLine; } });
|
|
44
|
+
Object.defineProperty(exports, "NEEDS_YOU_CODES", { enumerable: true, get: function () { return lines_1.NEEDS_YOU_CODES; } });
|
|
45
|
+
Object.defineProperty(exports, "activityLine", { enumerable: true, get: function () { return lines_1.activityLine; } });
|
|
46
|
+
Object.defineProperty(exports, "ACTIVITY_CODES", { enumerable: true, get: function () { return lines_1.ACTIVITY_CODES; } });
|
|
47
|
+
Object.defineProperty(exports, "ACTIVITY_NOT_LISTED", { enumerable: true, get: function () { return lines_1.ACTIVITY_NOT_LISTED; } });
|
|
48
|
+
Object.defineProperty(exports, "ENTRY_DROPPED", { enumerable: true, get: function () { return lines_1.ENTRY_DROPPED; } });
|
|
49
|
+
Object.defineProperty(exports, "endedLine", { enumerable: true, get: function () { return lines_1.endedLine; } });
|
|
50
|
+
Object.defineProperty(exports, "PAPER_LINES", { enumerable: true, get: function () { return lines_1.PAPER_LINES; } });
|
|
51
|
+
Object.defineProperty(exports, "END_REASONS", { enumerable: true, get: function () { return lines_1.END_REASONS; } });
|
|
52
|
+
Object.defineProperty(exports, "READ_OUTS", { enumerable: true, get: function () { return lines_1.READ_OUTS; } });
|
|
53
|
+
Object.defineProperty(exports, "gradedFigure", { enumerable: true, get: function () { return lines_1.gradedFigure; } });
|
|
54
|
+
Object.defineProperty(exports, "whatIfLine", { enumerable: true, get: function () { return lines_1.whatIfLine; } });
|
|
55
|
+
Object.defineProperty(exports, "WHAT_IF_RESPONSES", { enumerable: true, get: function () { return lines_1.WHAT_IF_RESPONSES; } });
|
package/dist/lines.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import lines from './lines.json';
|
|
2
|
+
/**
|
|
3
|
+
* The words of every line the chat, the cards and the pages show for v3 (AGT-219 part 3, the line
|
|
4
|
+
* table), keyed `id` or `id.form`. The id is what a tool result's `say` carries and what the other
|
|
5
|
+
* parts use; the form picks one wording of it (`start-1.empty`, `close-reason.close_open_halted`).
|
|
6
|
+
* A line whose main text is the service's (a warning, most refusals) holds only the follow-on code
|
|
7
|
+
* adds after that message.
|
|
8
|
+
*/
|
|
9
|
+
export type LineKey = keyof typeof lines;
|
|
10
|
+
/** A translation of `lines.json`: every key, with the same `{placeholders}`. */
|
|
11
|
+
export type LineTranslations = Record<LineKey, string>;
|
|
12
|
+
export type SayLine = {
|
|
13
|
+
id: string;
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
export type LineVars = Record<string, string | number>;
|
|
17
|
+
export declare const LINES: LineTranslations;
|
|
18
|
+
/** The line id of a key: what comes before its form. */
|
|
19
|
+
export declare const lineId: (key: LineKey) => string;
|
|
20
|
+
/**
|
|
21
|
+
* The line for `key`, filled in one pass, so a `{...}` inside a value (a market's question) stays as
|
|
22
|
+
* text. A placeholder with no value is left as written.
|
|
23
|
+
*/
|
|
24
|
+
export declare function line(key: LineKey, vars?: LineVars, t?: LineTranslations): SayLine;
|
|
25
|
+
/**
|
|
26
|
+
* The follow-on code adds after the service's message, by the issue's code or, for a refused check,
|
|
27
|
+
* its `details.reason`. A code with none is relayed alone.
|
|
28
|
+
*/
|
|
29
|
+
export declare const FOLLOW_ONS: Readonly<Record<string, LineKey>>;
|
|
30
|
+
/** A run's status, as the strategy service reports it. */
|
|
31
|
+
export type RunStatus = 'running' | 'closing' | 'holding' | 'ended';
|
|
32
|
+
type Options = {
|
|
33
|
+
t?: LineTranslations;
|
|
34
|
+
mode?: 'live' | 'paper';
|
|
35
|
+
/**
|
|
36
|
+
* The run's status, for the items whose facts depend on it: a liquidation (carrying on, closing,
|
|
37
|
+
* or done) and a held account history (which stays after the run ends).
|
|
38
|
+
*/
|
|
39
|
+
status?: RunStatus;
|
|
40
|
+
};
|
|
41
|
+
/** A Needs-you item as the strategy service returns it (reya-chain's `Incident`). */
|
|
42
|
+
export type NeedsYouItem = {
|
|
43
|
+
code: string;
|
|
44
|
+
/** The order manager's cause behind an overdue item: its line wins where it has one. */
|
|
45
|
+
sender_code?: string;
|
|
46
|
+
market?: string;
|
|
47
|
+
rule?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The engine's text. Never shown raw: only a max-loss pause's cause and a stopped close's
|
|
50
|
+
* position are read from it, in the engine's exact words.
|
|
51
|
+
*/
|
|
52
|
+
detail?: string;
|
|
53
|
+
escalated?: boolean;
|
|
54
|
+
/** The effect (order) the item is about: set when the exchange refused an order. */
|
|
55
|
+
effect?: number | string;
|
|
56
|
+
/** Why an outside action ended the run: `new_order`, `modified`, `cancelled`, `found_at_restart`. */
|
|
57
|
+
cause?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Every Needs-you code reya-chain sends that has a line of its own (the rest show `needs-other`). */
|
|
60
|
+
export declare const NEEDS_YOU_CODES: readonly string[];
|
|
61
|
+
/**
|
|
62
|
+
* The line for a Needs-you item, picked by its code. `vars` fills what the item does not carry (an
|
|
63
|
+
* expiry's `date`, an ended market's `question`, a rule's name as `rule`). Pass the run's `status`
|
|
64
|
+
* in `options`: a liquidation's line depends on it. A code this client has no line for, and
|
|
65
|
+
* `legacy`, show `needs-other` with the code as its reference.
|
|
66
|
+
*/
|
|
67
|
+
export declare function needsYouLine(item: NeedsYouItem, vars?: LineVars, options?: Options): SayLine;
|
|
68
|
+
/** An activity entry as the strategy service returns it (reya-chain's `Activity`). */
|
|
69
|
+
export type ActivityEntry = {
|
|
70
|
+
code: string;
|
|
71
|
+
/** Diagnostic text; an entry drop's fixed reason. Shown only as an order refusal's reason. */
|
|
72
|
+
reason?: string;
|
|
73
|
+
rule?: string;
|
|
74
|
+
market?: string;
|
|
75
|
+
event?: string;
|
|
76
|
+
incident?: NeedsYouItem;
|
|
77
|
+
/** The effect (order) the entry is about: set when the exchange refused an order. */
|
|
78
|
+
effect?: number | string;
|
|
79
|
+
};
|
|
80
|
+
/** The engine's fixed reasons for a dropped entry (`runtime/step.rs`), matched exactly. */
|
|
81
|
+
export declare const ENTRY_DROPPED: Readonly<Record<string, LineKey>>;
|
|
82
|
+
/**
|
|
83
|
+
* Activity codes with nothing to show the user: the engine's bookkeeping, a fault written beside
|
|
84
|
+
* the rule's own event, a fill another order owns, and moving the user's own stop into a strategy
|
|
85
|
+
* (not in this release).
|
|
86
|
+
*/
|
|
87
|
+
export declare const ACTIVITY_NOT_LISTED: readonly string[];
|
|
88
|
+
/** Every activity code with a line. */
|
|
89
|
+
export declare const ACTIVITY_CODES: readonly string[];
|
|
90
|
+
/**
|
|
91
|
+
* The line for an activity entry, picked by its code, or `null` for one with nothing to show (an
|
|
92
|
+
* event kind whose Needs-you item or effect carries the line, and `ACTIVITY_NOT_LISTED`). A code
|
|
93
|
+
* this client has no line for, and `legacy`, show `activity-other`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function activityLine(entry: ActivityEntry, vars?: LineVars, options?: Options): SayLine | null;
|
|
96
|
+
/** Every end reason reya-chain sends. */
|
|
97
|
+
export declare const END_REASONS: readonly string[];
|
|
98
|
+
/**
|
|
99
|
+
* Why a strategy ended, by the engine's reason: for an Ended run only. The engine sets the reason
|
|
100
|
+
* when the run starts to end, while it is still Closing; show `status-closing` until it is Ended.
|
|
101
|
+
* A liquidation, an order from outside and permission gone use their Needs-you line, so one reason
|
|
102
|
+
* has one set of words. With no reason, or one this client does not know, `status-ended`.
|
|
103
|
+
*/
|
|
104
|
+
export declare const endedLine: (reason: string | undefined, t?: LineTranslations) => SayLine;
|
|
105
|
+
/**
|
|
106
|
+
* A Paper run's lasting lines, by code (reya-chain's `PaperLine`): shown for good once they happen,
|
|
107
|
+
* never as Needs-you items. `paper-below-zero` takes the `date`; `paper-not-closed` goes beside each
|
|
108
|
+
* position left open.
|
|
109
|
+
*/
|
|
110
|
+
export declare const PAPER_LINES: Readonly<Record<string, LineKey>>;
|
|
111
|
+
/** Each read-out's name, by its field in the check result (`result.readouts`). */
|
|
112
|
+
export declare const READ_OUTS: Readonly<Record<string, LineKey>>;
|
|
113
|
+
/** A figure's grade, as the service sends it (`kind`). */
|
|
114
|
+
export type Grade = 'exact' | 'at_most' | 'at_least' | 'unknown';
|
|
115
|
+
/**
|
|
116
|
+
* A figure with its grade, which is part of what is said: "at most 106.43 USDC", "not known yet".
|
|
117
|
+
* `figure` is the value as the client formats it, with its unit.
|
|
118
|
+
*/
|
|
119
|
+
export declare const gradedFigure: (grade: Grade, figure: string, t?: LineTranslations) => string;
|
|
120
|
+
/** A "what happens if" row as the service returns it (reya-chain's `WhatIfRow`). */
|
|
121
|
+
export type WhatIfRow = {
|
|
122
|
+
response: string;
|
|
123
|
+
/** The event, by trigger kind or setting name: `source_ended <pin>`, `exchange_stop_loss`, … */
|
|
124
|
+
event: string;
|
|
125
|
+
market?: string;
|
|
126
|
+
basis_after?: unknown;
|
|
127
|
+
};
|
|
128
|
+
/** Every `response` reya-chain sends, `authored` included (it reads as its rule's sentence). */
|
|
129
|
+
export declare const WHAT_IF_RESPONSES: readonly string[];
|
|
130
|
+
/**
|
|
131
|
+
* The line for a "what happens if" row, picked by its `response`, or `null` for `authored`: that
|
|
132
|
+
* row reads as its rule's own sentence (`sentences(doc)[row.rule]`). `vars` holds the figures as the
|
|
133
|
+
* client formats them (`needed`, `have`, `basis`) and an odds row's `question`. An unknown row reads
|
|
134
|
+
* "{its event's 'If …' words}: not known yet." On a Paper run the liquidation row reads
|
|
135
|
+
* `paper-no-liquidation`.
|
|
136
|
+
*/
|
|
137
|
+
export declare function whatIfLine(row: WhatIfRow, vars?: LineVars, { t, mode }?: Options): SayLine | null;
|
|
138
|
+
export {};
|