@rippling/rippling-sdk 0.2.0-alpha.107 → 0.2.0-alpha.109

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.
Files changed (189) hide show
  1. package/client.d.mts +10 -1
  2. package/client.d.mts.map +1 -1
  3. package/client.d.ts +10 -1
  4. package/client.d.ts.map +1 -1
  5. package/client.js +10 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +10 -1
  8. package/client.mjs.map +1 -1
  9. package/lib/charts/builders.d.mts +18 -19
  10. package/lib/charts/builders.d.mts.map +1 -1
  11. package/lib/charts/builders.d.ts +18 -19
  12. package/lib/charts/builders.d.ts.map +1 -1
  13. package/lib/charts/builders.js +35 -28
  14. package/lib/charts/builders.js.map +1 -1
  15. package/lib/charts/builders.mjs +35 -28
  16. package/lib/charts/builders.mjs.map +1 -1
  17. package/lib/charts/describe.d.mts +6 -7
  18. package/lib/charts/describe.d.mts.map +1 -1
  19. package/lib/charts/describe.d.ts +6 -7
  20. package/lib/charts/describe.d.ts.map +1 -1
  21. package/lib/charts/describe.js +26 -27
  22. package/lib/charts/describe.js.map +1 -1
  23. package/lib/charts/describe.mjs +27 -28
  24. package/lib/charts/describe.mjs.map +1 -1
  25. package/lib/charts/errors.d.mts +2 -6
  26. package/lib/charts/errors.d.mts.map +1 -1
  27. package/lib/charts/errors.d.ts +2 -6
  28. package/lib/charts/errors.d.ts.map +1 -1
  29. package/lib/charts/errors.js +2 -6
  30. package/lib/charts/errors.js.map +1 -1
  31. package/lib/charts/errors.mjs +2 -6
  32. package/lib/charts/errors.mjs.map +1 -1
  33. package/lib/charts/evaluate.d.mts +5 -7
  34. package/lib/charts/evaluate.d.mts.map +1 -1
  35. package/lib/charts/evaluate.d.ts +5 -7
  36. package/lib/charts/evaluate.d.ts.map +1 -1
  37. package/lib/charts/evaluate.js +21 -35
  38. package/lib/charts/evaluate.js.map +1 -1
  39. package/lib/charts/evaluate.mjs +22 -36
  40. package/lib/charts/evaluate.mjs.map +1 -1
  41. package/lib/charts/schema.d.mts +8 -97
  42. package/lib/charts/schema.d.mts.map +1 -1
  43. package/lib/charts/schema.d.ts +8 -97
  44. package/lib/charts/schema.d.ts.map +1 -1
  45. package/lib/charts/schema.js +186 -65
  46. package/lib/charts/schema.js.map +1 -1
  47. package/lib/charts/schema.mjs +185 -65
  48. package/lib/charts/schema.mjs.map +1 -1
  49. package/lib/charts/types.d.mts +40 -25
  50. package/lib/charts/types.d.mts.map +1 -1
  51. package/lib/charts/types.d.ts +40 -25
  52. package/lib/charts/types.d.ts.map +1 -1
  53. package/lib/charts/types.js +8 -10
  54. package/lib/charts/types.js.map +1 -1
  55. package/lib/charts/types.mjs +8 -10
  56. package/lib/charts/types.mjs.map +1 -1
  57. package/lib/charts/visualization-grammar.d.mts +66 -0
  58. package/lib/charts/visualization-grammar.d.mts.map +1 -0
  59. package/lib/charts/visualization-grammar.d.ts +66 -0
  60. package/lib/charts/visualization-grammar.d.ts.map +1 -0
  61. package/lib/charts/visualization-grammar.js +70 -0
  62. package/lib/charts/visualization-grammar.js.map +1 -0
  63. package/lib/charts/visualization-grammar.mjs +67 -0
  64. package/lib/charts/visualization-grammar.mjs.map +1 -0
  65. package/lib/charts/vocabulary.d.mts +7 -0
  66. package/lib/charts/vocabulary.d.mts.map +1 -0
  67. package/lib/charts/vocabulary.d.ts +7 -0
  68. package/lib/charts/vocabulary.d.ts.map +1 -0
  69. package/lib/charts/vocabulary.js +10 -0
  70. package/lib/charts/vocabulary.js.map +1 -0
  71. package/lib/charts/vocabulary.mjs +7 -0
  72. package/lib/charts/vocabulary.mjs.map +1 -0
  73. package/lib/charts.d.mts +3 -3
  74. package/lib/charts.d.mts.map +1 -1
  75. package/lib/charts.d.ts +3 -3
  76. package/lib/charts.d.ts.map +1 -1
  77. package/lib/charts.js +2 -1
  78. package/lib/charts.js.map +1 -1
  79. package/lib/charts.mjs +1 -1
  80. package/lib/charts.mjs.map +1 -1
  81. package/package.json +4 -2
  82. package/resources/card-transactions.d.mts +579 -0
  83. package/resources/card-transactions.d.mts.map +1 -0
  84. package/resources/card-transactions.d.ts +579 -0
  85. package/resources/card-transactions.d.ts.map +1 -0
  86. package/resources/card-transactions.js +116 -0
  87. package/resources/card-transactions.js.map +1 -0
  88. package/resources/card-transactions.mjs +112 -0
  89. package/resources/card-transactions.mjs.map +1 -0
  90. package/resources/earning-types.d.mts +50 -10
  91. package/resources/earning-types.d.mts.map +1 -1
  92. package/resources/earning-types.d.ts +50 -10
  93. package/resources/earning-types.d.ts.map +1 -1
  94. package/resources/earning-types.js +21 -2
  95. package/resources/earning-types.js.map +1 -1
  96. package/resources/earning-types.mjs +21 -2
  97. package/resources/earning-types.mjs.map +1 -1
  98. package/resources/index.d.mts +4 -1
  99. package/resources/index.d.mts.map +1 -1
  100. package/resources/index.d.ts +4 -1
  101. package/resources/index.d.ts.map +1 -1
  102. package/resources/index.js +10 -4
  103. package/resources/index.js.map +1 -1
  104. package/resources/index.mjs +4 -1
  105. package/resources/index.mjs.map +1 -1
  106. package/resources/reimbursements.d.mts +954 -0
  107. package/resources/reimbursements.d.mts.map +1 -0
  108. package/resources/reimbursements.d.ts +954 -0
  109. package/resources/reimbursements.d.ts.map +1 -0
  110. package/resources/reimbursements.js +140 -0
  111. package/resources/reimbursements.js.map +1 -0
  112. package/resources/reimbursements.mjs +136 -0
  113. package/resources/reimbursements.mjs.map +1 -0
  114. package/resources/spend-categories.d.mts +140 -0
  115. package/resources/spend-categories.d.mts.map +1 -0
  116. package/resources/spend-categories.d.ts +140 -0
  117. package/resources/spend-categories.d.ts.map +1 -0
  118. package/resources/spend-categories.js +83 -0
  119. package/resources/spend-categories.js.map +1 -0
  120. package/resources/spend-categories.mjs +79 -0
  121. package/resources/spend-categories.mjs.map +1 -0
  122. package/resources/workflows/executions.d.mts +153 -0
  123. package/resources/workflows/executions.d.mts.map +1 -0
  124. package/resources/workflows/executions.d.ts +153 -0
  125. package/resources/workflows/executions.d.ts.map +1 -0
  126. package/resources/workflows/executions.js +74 -0
  127. package/resources/workflows/executions.js.map +1 -0
  128. package/resources/workflows/executions.mjs +70 -0
  129. package/resources/workflows/executions.mjs.map +1 -0
  130. package/resources/workflows/index.d.mts +3 -0
  131. package/resources/workflows/index.d.mts.map +1 -0
  132. package/resources/workflows/index.d.ts +3 -0
  133. package/resources/workflows/index.d.ts.map +1 -0
  134. package/resources/workflows/index.js +9 -0
  135. package/resources/workflows/index.js.map +1 -0
  136. package/resources/workflows/index.mjs +4 -0
  137. package/resources/workflows/index.mjs.map +1 -0
  138. package/resources/workflows/workflows.d.mts +977 -0
  139. package/resources/workflows/workflows.d.mts.map +1 -0
  140. package/resources/workflows/workflows.d.ts +977 -0
  141. package/resources/workflows/workflows.d.ts.map +1 -0
  142. package/resources/workflows/workflows.js +246 -0
  143. package/resources/workflows/workflows.js.map +1 -0
  144. package/resources/workflows/workflows.mjs +241 -0
  145. package/resources/workflows/workflows.mjs.map +1 -0
  146. package/resources/workflows.d.mts +1 -972
  147. package/resources/workflows.d.mts.map +1 -1
  148. package/resources/workflows.d.ts +1 -972
  149. package/resources/workflows.d.ts.map +1 -1
  150. package/resources/workflows.js +2 -234
  151. package/resources/workflows.js.map +1 -1
  152. package/resources/workflows.mjs +1 -232
  153. package/resources/workflows.mjs.map +1 -1
  154. package/src/client.ts +63 -12
  155. package/src/lib/charts/README.md +35 -28
  156. package/src/lib/charts/agent-reference.md +73 -0
  157. package/src/lib/charts/builders.ts +51 -35
  158. package/src/lib/charts/capabilities.json +96 -0
  159. package/src/lib/charts/describe.ts +31 -29
  160. package/src/lib/charts/errors.ts +2 -6
  161. package/src/lib/charts/evaluate.ts +25 -38
  162. package/src/lib/charts/schema.ts +232 -66
  163. package/src/lib/charts/types.ts +42 -31
  164. package/src/lib/charts/visualization-grammar.ts +67 -0
  165. package/src/lib/charts/vocabulary.ts +7 -0
  166. package/src/lib/charts.ts +8 -1
  167. package/src/resources/card-transactions.ts +718 -0
  168. package/src/resources/earning-types.ts +52 -10
  169. package/src/resources/index.ts +22 -1
  170. package/src/resources/reimbursements.ts +1157 -0
  171. package/src/resources/spend-categories.ts +175 -0
  172. package/src/resources/workflows/executions.ts +191 -0
  173. package/src/resources/workflows/index.ts +15 -0
  174. package/src/resources/workflows/workflows.ts +1661 -0
  175. package/src/resources/workflows.ts +1 -1647
  176. package/src/version.ts +1 -1
  177. package/version.d.mts +1 -1
  178. package/version.d.ts +1 -1
  179. package/version.js +1 -1
  180. package/version.mjs +1 -1
  181. package/lib/charts/guards.d.mts +0 -15
  182. package/lib/charts/guards.d.mts.map +0 -1
  183. package/lib/charts/guards.d.ts +0 -15
  184. package/lib/charts/guards.d.ts.map +0 -1
  185. package/lib/charts/guards.js +0 -38
  186. package/lib/charts/guards.js.map +0 -1
  187. package/lib/charts/guards.mjs +0 -34
  188. package/lib/charts/guards.mjs.map +0 -1
  189. package/src/lib/charts/guards.ts +0 -42
@@ -1,71 +1,191 @@
1
+ import { boolean, finite, literal, null_, number, picklist, pipe, safeParse, strictObject, string, summarize, union, variant, } from 'valibot';
2
+ import { MalformedRuleError, UnknownNodeError } from "./errors.mjs";
1
3
  import { CHART_RULE_CONTRACT_VERSION } from "./types.mjs";
2
- /** Stable identifier for the published contract, versioned by the tag. */
4
+ import { EQUALITY_COMPARISON_KINDS, NUMERIC_COMPARISON_KINDS, RULE_CHANNELS, RULE_NODE_KINDS, } from "./vocabulary.mjs";
5
+ const ruleNodeKinds = new Set(RULE_NODE_KINDS);
6
+ const placeholderKeys = new Set(['$rule', 'channel']);
7
+ const ruleFieldKeys = ['$rule', 'channel', 'kind', 'value', 'left', 'right', 'cond', 'then', 'else'];
8
+ const scalarSchema = union([
9
+ pipe(number(), finite()),
10
+ string(),
11
+ boolean(),
12
+ null_(),
13
+ ]);
14
+ const parsedRules = new WeakSet();
15
+ /** @deprecated Use `CHART_RULE_CONTRACT_VERSION` to identify the executable contract. */
3
16
  export const CHART_RULE_SCHEMA_ID = `https://rippling.com/schemas/${CHART_RULE_CONTRACT_VERSION}.json`;
17
+ function hasOwn(value, key) {
18
+ return Object.prototype.hasOwnProperty.call(value, key);
19
+ }
20
+ const refNodeSchema = strictObject({ kind: literal('value') });
21
+ const literalNodeSchema = strictObject({ kind: literal('literal'), value: scalarSchema });
22
+ const numericLiteralNodeSchema = strictObject({
23
+ kind: literal('literal'),
24
+ value: pipe(number(), finite()),
25
+ });
26
+ const requiredColorLiteralNodeSchema = strictObject({
27
+ kind: literal('literal'),
28
+ value: string(),
29
+ });
30
+ const optionalColorLiteralNodeSchema = strictObject({
31
+ kind: literal('literal'),
32
+ value: union([string(), null_()]),
33
+ });
34
+ const comparisonOperandSchema = variant('kind', [refNodeSchema, literalNodeSchema]);
35
+ const numericOperandSchema = variant('kind', [refNodeSchema, numericLiteralNodeSchema]);
36
+ const equalityComparisonNodeSchema = strictObject({
37
+ kind: picklist(EQUALITY_COMPARISON_KINDS),
38
+ left: comparisonOperandSchema,
39
+ right: comparisonOperandSchema,
40
+ });
41
+ const numericComparisonNodeSchema = strictObject({
42
+ kind: picklist(NUMERIC_COMPARISON_KINDS),
43
+ left: numericOperandSchema,
44
+ right: numericOperandSchema,
45
+ });
46
+ const comparisonNodeSchema = variant('kind', [equalityComparisonNodeSchema, numericComparisonNodeSchema]);
47
+ const ifElseNodeSchema = strictObject({
48
+ kind: literal('ifElse'),
49
+ cond: comparisonNodeSchema,
50
+ then: requiredColorLiteralNodeSchema,
51
+ else: optionalColorLiteralNodeSchema,
52
+ });
4
53
  /**
5
- * JSON Schema (2020-12) for the `{$rule}` placeholder and its closed node set.
54
+ * Executable runtime schema for a chart-rule node.
6
55
  *
7
- * This is the contract. A consumer that keeps its own rule evaluator (rather
8
- * than importing `evaluate`) can validate against this so the two never drift —
9
- * every kind and operand shape the builders can emit is described here.
56
+ * v1 is intentionally non-recursive. A comparison contains only `value` or
57
+ * literal operands, and a conditional contains one comparison plus two colour
58
+ * literals. Contract tests prove that every public builder output parses.
10
59
  */
11
- export const chartRuleSchema = {
12
- $schema: 'https://json-schema.org/draft/2020-12/schema',
13
- $id: CHART_RULE_SCHEMA_ID,
14
- title: 'Chart rule placeholder',
15
- description: 'A rule tree the chart agent emits into a chart option, marked with $rule.',
16
- type: 'object',
17
- required: ['$rule', 'channel'],
18
- additionalProperties: false,
19
- properties: {
20
- // A colour rule's top-level tree is the conditional-value form (`when(...)`),
21
- // matching what `color()` builds and accepts. A bare ref/comparison/literal
22
- // resolves to a number/boolean/constant, not a colour decision.
23
- $rule: { $ref: '#/$defs/ifElse' },
24
- channel: { const: 'color' },
25
- },
26
- $defs: {
27
- scalar: { type: ['number', 'string', 'boolean', 'null'] },
28
- node: {
29
- oneOf: [
30
- { $ref: '#/$defs/ref' },
31
- { $ref: '#/$defs/literal' },
32
- { $ref: '#/$defs/comparison' },
33
- { $ref: '#/$defs/ifElse' },
34
- ],
35
- },
36
- ref: {
37
- type: 'object',
38
- required: ['kind'],
39
- additionalProperties: false,
40
- properties: { kind: { const: 'value' } },
41
- },
42
- literal: {
43
- type: 'object',
44
- required: ['kind', 'value'],
45
- additionalProperties: false,
46
- properties: { kind: { const: 'literal' }, value: { $ref: '#/$defs/scalar' } },
47
- },
48
- comparison: {
49
- type: 'object',
50
- required: ['kind', 'left', 'right'],
51
- additionalProperties: false,
52
- properties: {
53
- kind: { enum: ['equals', 'isNot', 'lessThan', 'greaterThan', 'lessOrEqual', 'greaterOrEqual'] },
54
- left: { $ref: '#/$defs/node' },
55
- right: { $ref: '#/$defs/node' },
56
- },
57
- },
58
- ifElse: {
59
- type: 'object',
60
- required: ['kind', 'cond', 'then', 'else'],
61
- additionalProperties: false,
62
- properties: {
63
- kind: { const: 'ifElse' },
64
- cond: { $ref: '#/$defs/node' },
65
- then: { $ref: '#/$defs/node' },
66
- else: { $ref: '#/$defs/node' },
67
- },
68
- },
69
- },
70
- };
60
+ const ruleNodeSchema = variant('kind', [
61
+ refNodeSchema,
62
+ literalNodeSchema,
63
+ equalityComparisonNodeSchema,
64
+ numericComparisonNodeSchema,
65
+ ifElseNodeSchema,
66
+ ]);
67
+ /** Runtime schema for the `{$rule, channel}` value embedded in a chart option. */
68
+ const rulePlaceholderSchema = strictObject({
69
+ $rule: ifElseNodeSchema,
70
+ channel: picklist(RULE_CHANNELS),
71
+ });
72
+ /**
73
+ * Runtime schema for either a bare rule node or a chart-option placeholder.
74
+ * Persisted and agent-authored JSON crosses this boundary as `unknown`.
75
+ */
76
+ export const chartRuleSchema = union([
77
+ rulePlaceholderSchema,
78
+ ruleNodeSchema,
79
+ ]);
80
+ /** Parse untrusted chart-rule JSON and return an immutable validated clone. */
81
+ export function parseChartRule(input) {
82
+ if (isParsedRule(input)) {
83
+ return input;
84
+ }
85
+ preflight(input);
86
+ const result = safeParse(chartRuleSchema, input);
87
+ if (result.success) {
88
+ return markParsedRule(result.output);
89
+ }
90
+ throw new MalformedRuleError(summarize(result.issues));
91
+ }
92
+ /**
93
+ * Valibot's object schemas use `key in input`, which also reads inherited
94
+ * properties. Reject inherited rule fields before parsing so prototype data
95
+ * cannot supply required operands or bypass the flat v1 contract.
96
+ */
97
+ function preflight(input) {
98
+ assertNoInheritedRuleFields(input);
99
+ const root = unwrapPlaceholder(input);
100
+ assertNoInheritedRuleFields(root);
101
+ assertKnownNode(root);
102
+ if (!isRecord(root) || !hasOwn(root, 'kind')) {
103
+ return;
104
+ }
105
+ if (root['kind'] === 'ifElse') {
106
+ inspectChildren(root, ['cond', 'then', 'else']);
107
+ const condition = root['cond'];
108
+ inspectComparison(condition);
109
+ }
110
+ else if (typeof root['kind'] === 'string' && isComparisonKind(root['kind'])) {
111
+ inspectComparison(root);
112
+ }
113
+ }
114
+ function inspectComparison(value) {
115
+ assertNoInheritedRuleFields(value);
116
+ assertKnownNode(value);
117
+ if (isRecord(value)) {
118
+ inspectChildren(value, ['left', 'right']);
119
+ }
120
+ }
121
+ function inspectChildren(parent, keys) {
122
+ for (const key of keys) {
123
+ if (hasOwn(parent, key)) {
124
+ const child = parent[key];
125
+ assertNoInheritedRuleFields(child);
126
+ assertKnownNode(child);
127
+ }
128
+ }
129
+ }
130
+ function assertNoInheritedRuleFields(value) {
131
+ if (!isRecord(value)) {
132
+ return;
133
+ }
134
+ for (const key of ruleFieldKeys) {
135
+ if (key in value && !hasOwn(value, key)) {
136
+ throw new MalformedRuleError(`a chart rule must not inherit the ${key} property`);
137
+ }
138
+ }
139
+ }
140
+ function assertKnownNode(value) {
141
+ if (isRecord(value) &&
142
+ hasOwn(value, 'kind') &&
143
+ typeof value['kind'] === 'string' &&
144
+ !ruleNodeKinds.has(value['kind'])) {
145
+ throw new UnknownNodeError(value['kind']);
146
+ }
147
+ }
148
+ function isComparisonKind(kind) {
149
+ return kind !== 'literal' && kind !== 'value' && kind !== 'ifElse' && ruleNodeKinds.has(kind);
150
+ }
151
+ function isRecord(value) {
152
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
153
+ }
154
+ function unwrapPlaceholder(input) {
155
+ if (input === null || typeof input !== 'object' || Array.isArray(input) || !hasOwn(input, '$rule')) {
156
+ return input;
157
+ }
158
+ const unexpectedKey = Object.keys(input).find((key) => !placeholderKeys.has(key));
159
+ if (unexpectedKey !== undefined) {
160
+ throw new MalformedRuleError(`a rule placeholder has an unexpected property: ${unexpectedKey}`);
161
+ }
162
+ return input.$rule;
163
+ }
164
+ function isParsedRule(input) {
165
+ return input !== null && typeof input === 'object' && !Array.isArray(input) && parsedRules.has(input);
166
+ }
167
+ /**
168
+ * Mark the validated clone so `evaluate(parseChartRule(input), ctx)` does not
169
+ * reparse the full value for every datum. Freezing prevents a caller from
170
+ * mutating a trusted value after validation.
171
+ */
172
+ function markParsedRule(rule) {
173
+ const stack = [rule];
174
+ const seen = new WeakSet();
175
+ while (stack.length > 0) {
176
+ const current = stack.pop();
177
+ if (!current || seen.has(current)) {
178
+ continue;
179
+ }
180
+ seen.add(current);
181
+ for (const value of Object.values(current)) {
182
+ if (value !== null && typeof value === 'object') {
183
+ stack.push(value);
184
+ }
185
+ }
186
+ Object.freeze(current);
187
+ }
188
+ parsedRules.add(rule);
189
+ return rule;
190
+ }
71
191
  //# sourceMappingURL=schema.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","sourceRoot":"","sources":["../../src/lib/charts/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,oBAAgB;AAEtD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,gCAAgC,2BAA2B,OAAO,CAAC;AAEvG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,8CAA8C;IACvD,GAAG,EAAE,oBAAoB;IACzB,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,2EAA2E;IACxF,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;IAC9B,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,8EAA8E;QAC9E,4EAA4E;QAC5E,gEAAgE;QAChE,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;QACjC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;KAC5B;IACD,KAAK,EAAE;QACL,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE;QACzD,IAAI,EAAE;YACJ,KAAK,EAAE;gBACL,EAAE,IAAI,EAAE,aAAa,EAAE;gBACvB,EAAE,IAAI,EAAE,iBAAiB,EAAE;gBAC3B,EAAE,IAAI,EAAE,oBAAoB,EAAE;gBAC9B,EAAE,IAAI,EAAE,gBAAgB,EAAE;aAC3B;SACF;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,MAAM,CAAC;YAClB,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;SACzC;QACD,O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C9C,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACxG,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAU;IAChC,MAAM,KAAK,GAAa,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,OAAO,EAAU,CAAC;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAChD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAkB,CAAC;AAC5B,CAAC"}
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * Chart rule vocabulary — shared types.
3
3
  *
4
- * A rule is a small, serializable tree of nodes discriminated by `kind`. The
4
+ * A rule is a small, serializable value discriminated by `kind`. The
5
5
  * agent builds it with the helpers in `builders.ts`, which emit it wrapped in a
6
6
  * `{$rule}` placeholder — the same idea as the `{$fn}` placeholders a chart
7
7
  * already emits. The renderer resolves it with `evaluate`; the settings panel
8
8
  * reads it with `describe`. All three agree because a node can only ever be one
9
- * of the kinds defined here — the closed set the `chartRuleSchema` describes.
9
+ * of the kinds defined here — the closed set the executable `chartRuleSchema`
10
+ * validates at runtime.
10
11
  *
11
- * v1 is scoped to conditional formatting: compare this datum's `value` against a
12
- * constant, and (optionally) pick between two values. Richer pieces — aggregates,
13
- * logic, more refs — are the documented roadmap in the README.
12
+ * v1 is deliberately non-recursive: compare this datum's `value` or a literal
13
+ * against another literal, then choose between two colour literals. Rules may
14
+ * not appear inside operands or branches. Richer expressions require a future
15
+ * contract version.
14
16
  */
17
+ import { COMPARISON_KINDS, RULE_CHANNELS } from "./vocabulary.mjs";
15
18
  export declare const CHART_RULE_CONTRACT_VERSION: "chart_rule.v1";
16
19
  export type ChartRuleContractVersion = typeof CHART_RULE_CONTRACT_VERSION;
17
20
  /** A leaf value a rule can carry or resolve to. */
@@ -20,53 +23,64 @@ export type Scalar = number | string | boolean | null;
20
23
  export type RefNode = {
21
24
  kind: 'value';
22
25
  };
23
- export interface LiteralNode {
26
+ export interface LiteralNode<TValue extends Scalar = Scalar> {
24
27
  kind: 'literal';
25
- value: Scalar;
28
+ value: TValue;
26
29
  }
27
- export type ComparisonKind = 'equals' | 'isNot' | 'lessThan' | 'greaterThan' | 'lessOrEqual' | 'greaterOrEqual';
28
- export interface ComparisonNode {
29
- kind: ComparisonKind;
30
- left: RuleNode;
31
- right: RuleNode;
30
+ export type ComparisonOperandNode = RefNode | LiteralNode;
31
+ export type NumericOperandNode = RefNode | LiteralNode<number>;
32
+ export type ComparisonKind = (typeof COMPARISON_KINDS)[number];
33
+ export interface EqualityComparisonNode {
34
+ kind: 'equals' | 'isNot';
35
+ left: ComparisonOperandNode;
36
+ right: ComparisonOperandNode;
32
37
  }
38
+ export interface NumericComparisonNode {
39
+ kind: Exclude<ComparisonKind, EqualityComparisonNode['kind']>;
40
+ left: NumericOperandNode;
41
+ right: NumericOperandNode;
42
+ }
43
+ export type ComparisonNode = EqualityComparisonNode | NumericComparisonNode;
44
+ /** A node whose evaluated result is valid as a `when(...)` condition in v1. */
45
+ export type ConditionNode = ComparisonNode;
33
46
  /** The conditional-value form produced by `when(cond, then, else)`. */
34
47
  export interface IfElseNode {
35
48
  kind: 'ifElse';
36
- cond: RuleNode;
37
- then: RuleNode;
38
- else: RuleNode;
49
+ cond: ConditionNode;
50
+ then: LiteralNode<string>;
51
+ else: LiteralNode<string | null>;
39
52
  }
40
- /** Any node of a rule tree. */
53
+ /** Any top-level node accepted by the v1 runtime boundary. */
41
54
  export type RuleNode = RefNode | LiteralNode | ComparisonNode | IfElseNode;
42
55
  /**
43
56
  * The chart channel a rule drives. v1 supports colour only — a rule decides the
44
57
  * colour of a series/datum. Other channels (opacity, label visibility, …) are
45
58
  * the documented roadmap and would be added here.
46
59
  */
47
- export type RuleChannel = 'color';
60
+ export type RuleChannel = (typeof RULE_CHANNELS)[number];
48
61
  /**
49
- * What a builder returns: a rule tree, marked so the renderer can find it, and
62
+ * What a builder returns: a flat rule value, marked so the renderer can find it, and
50
63
  * tagged with the channel it targets. `channel: 'color'` says this resolves to a
51
64
  * colour — so a reader sees the target without inferring it from where it sits.
52
65
  */
53
66
  export interface RulePlaceholder {
54
- $rule: RuleNode;
67
+ $rule: IfElseNode;
55
68
  channel: RuleChannel;
56
69
  }
57
- /** A placeholder, or the bare tree — what `evaluate` and `describe` accept. */
70
+ /** A placeholder, or a bare node — what `evaluate` and `describe` accept. */
58
71
  export type Rule = RulePlaceholder | RuleNode;
72
+ type DeepReadonly<T> = T extends object ? {
73
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
74
+ } : T;
75
+ /** The deeply frozen value returned by `parseChartRule`. */
76
+ export type ParsedRule = DeepReadonly<Rule>;
59
77
  /** What a rule is evaluated against: the current datum's value. */
60
78
  export interface RuleContext {
61
79
  value: number;
62
80
  }
63
81
  /** The result of evaluating a node. */
64
82
  export type RuleValue = Scalar;
65
- /**
66
- * The deepest a rule may nest before `evaluate`/`describe` refuse it. Real rules
67
- * are a handful of levels; this only stops a pathological deserialized tree from
68
- * overflowing the stack. Far below the JS call-stack limit.
69
- */
83
+ /** @deprecated v1 is non-recursive. Retained for source compatibility. */
70
84
  export declare const MAX_RULE_DEPTH = 256;
71
85
  export type ControlRole = 'rule' | 'comparison' | 'ref' | 'literal';
72
86
  /** A node as the panel should show it: a label, its editable value, its parts. */
@@ -76,4 +90,5 @@ export interface Control {
76
90
  value?: Scalar;
77
91
  parts?: Control[];
78
92
  }
93
+ export {};
79
94
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/lib/charts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,2BAA2B,EAAG,eAAwB,CAAC;AACpE,MAAM,MAAM,wBAAwB,GAAG,OAAO,2BAA2B,CAAC;AAE1E,mDAAmD;AACnD,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAMtD,gFAAgF;AAChF,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,OAAO,GACP,UAAU,GACV,aAAa,GACb,aAAa,GACb,gBAAgB,CAAC;AACrB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,+B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AAO,EAAE,WAAW,CAAC;CACtB;AAED,6EAA6E;AAC7E,MAAM,MAAM,IAAI,GAAG,eAAe,GAAG,QAAQ,CAAC;AAE9C,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG;IAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GAAG,CAAC,CAAC;AAElG,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AAM5C,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,0EAA0E;AAC1E,eAAO,MAAM,cAAc,MAAM,CAAC;AAMlC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,KAAK,GAAG,SAAS,CAAC;AAEpE,kFAAkF;AAClF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;CACnB"}
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * Chart rule vocabulary — shared types.
3
3
  *
4
- * A rule is a small, serializable tree of nodes discriminated by `kind`. The
4
+ * A rule is a small, serializable value discriminated by `kind`. The
5
5
  * agent builds it with the helpers in `builders.ts`, which emit it wrapped in a
6
6
  * `{$rule}` placeholder — the same idea as the `{$fn}` placeholders a chart
7
7
  * already emits. The renderer resolves it with `evaluate`; the settings panel
8
8
  * reads it with `describe`. All three agree because a node can only ever be one
9
- * of the kinds defined here — the closed set the `chartRuleSchema` describes.
9
+ * of the kinds defined here — the closed set the executable `chartRuleSchema`
10
+ * validates at runtime.
10
11
  *
11
- * v1 is scoped to conditional formatting: compare this datum's `value` against a
12
- * constant, and (optionally) pick between two values. Richer pieces — aggregates,
13
- * logic, more refs — are the documented roadmap in the README.
12
+ * v1 is deliberately non-recursive: compare this datum's `value` or a literal
13
+ * against another literal, then choose between two colour literals. Rules may
14
+ * not appear inside operands or branches. Richer expressions require a future
15
+ * contract version.
14
16
  */
17
+ import { COMPARISON_KINDS, RULE_CHANNELS } from "./vocabulary.js";
15
18
  export declare const CHART_RULE_CONTRACT_VERSION: "chart_rule.v1";
16
19
  export type ChartRuleContractVersion = typeof CHART_RULE_CONTRACT_VERSION;
17
20
  /** A leaf value a rule can carry or resolve to. */
@@ -20,53 +23,64 @@ export type Scalar = number | string | boolean | null;
20
23
  export type RefNode = {
21
24
  kind: 'value';
22
25
  };
23
- export interface LiteralNode {
26
+ export interface LiteralNode<TValue extends Scalar = Scalar> {
24
27
  kind: 'literal';
25
- value: Scalar;
28
+ value: TValue;
26
29
  }
27
- export type ComparisonKind = 'equals' | 'isNot' | 'lessThan' | 'greaterThan' | 'lessOrEqual' | 'greaterOrEqual';
28
- export interface ComparisonNode {
29
- kind: ComparisonKind;
30
- left: RuleNode;
31
- right: RuleNode;
30
+ export type ComparisonOperandNode = RefNode | LiteralNode;
31
+ export type NumericOperandNode = RefNode | LiteralNode<number>;
32
+ export type ComparisonKind = (typeof COMPARISON_KINDS)[number];
33
+ export interface EqualityComparisonNode {
34
+ kind: 'equals' | 'isNot';
35
+ left: ComparisonOperandNode;
36
+ right: ComparisonOperandNode;
32
37
  }
38
+ export interface NumericComparisonNode {
39
+ kind: Exclude<ComparisonKind, EqualityComparisonNode['kind']>;
40
+ left: NumericOperandNode;
41
+ right: NumericOperandNode;
42
+ }
43
+ export type ComparisonNode = EqualityComparisonNode | NumericComparisonNode;
44
+ /** A node whose evaluated result is valid as a `when(...)` condition in v1. */
45
+ export type ConditionNode = ComparisonNode;
33
46
  /** The conditional-value form produced by `when(cond, then, else)`. */
34
47
  export interface IfElseNode {
35
48
  kind: 'ifElse';
36
- cond: RuleNode;
37
- then: RuleNode;
38
- else: RuleNode;
49
+ cond: ConditionNode;
50
+ then: LiteralNode<string>;
51
+ else: LiteralNode<string | null>;
39
52
  }
40
- /** Any node of a rule tree. */
53
+ /** Any top-level node accepted by the v1 runtime boundary. */
41
54
  export type RuleNode = RefNode | LiteralNode | ComparisonNode | IfElseNode;
42
55
  /**
43
56
  * The chart channel a rule drives. v1 supports colour only — a rule decides the
44
57
  * colour of a series/datum. Other channels (opacity, label visibility, …) are
45
58
  * the documented roadmap and would be added here.
46
59
  */
47
- export type RuleChannel = 'color';
60
+ export type RuleChannel = (typeof RULE_CHANNELS)[number];
48
61
  /**
49
- * What a builder returns: a rule tree, marked so the renderer can find it, and
62
+ * What a builder returns: a flat rule value, marked so the renderer can find it, and
50
63
  * tagged with the channel it targets. `channel: 'color'` says this resolves to a
51
64
  * colour — so a reader sees the target without inferring it from where it sits.
52
65
  */
53
66
  export interface RulePlaceholder {
54
- $rule: RuleNode;
67
+ $rule: IfElseNode;
55
68
  channel: RuleChannel;
56
69
  }
57
- /** A placeholder, or the bare tree — what `evaluate` and `describe` accept. */
70
+ /** A placeholder, or a bare node — what `evaluate` and `describe` accept. */
58
71
  export type Rule = RulePlaceholder | RuleNode;
72
+ type DeepReadonly<T> = T extends object ? {
73
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
74
+ } : T;
75
+ /** The deeply frozen value returned by `parseChartRule`. */
76
+ export type ParsedRule = DeepReadonly<Rule>;
59
77
  /** What a rule is evaluated against: the current datum's value. */
60
78
  export interface RuleContext {
61
79
  value: number;
62
80
  }
63
81
  /** The result of evaluating a node. */
64
82
  export type RuleValue = Scalar;
65
- /**
66
- * The deepest a rule may nest before `evaluate`/`describe` refuse it. Real rules
67
- * are a handful of levels; this only stops a pathological deserialized tree from
68
- * overflowing the stack. Far below the JS call-stack limit.
69
- */
83
+ /** @deprecated v1 is non-recursive. Retained for source compatibility. */
70
84
  export declare const MAX_RULE_DEPTH = 256;
71
85
  export type ControlRole = 'rule' | 'comparison' | 'ref' | 'literal';
72
86
  /** A node as the panel should show it: a label, its editable value, its parts. */
@@ -76,4 +90,5 @@ export interface Control {
76
90
  value?: Scalar;
77
91
  parts?: Control[];
78
92
  }
93
+ export {};
79
94
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/charts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,2BAA2B,EAAG,eAAwB,CAAC;AACpE,MAAM,MAAM,wBAAwB,GAAG,OAAO,2BAA2B,CAAC;AAE1E,mDAAmD;AACnD,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAMtD,gFAAgF;AAChF,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,OAAO,GACP,UAAU,GACV,aAAa,GACb,aAAa,GACb,gBAAgB,CAAC;AACrB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,+BAA+B;AAC/B,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,CAAC;AAM3E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC;;;;GAIG;AACH,MAAM,WAAW,eAAe;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G,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GAAG,CAAC,CAAC;AAElG,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AAM5C,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,0EAA0E;AAC1E,eAAO,MAAM,cAAc,MAAM,CAAC;AAMlC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,KAAK,GAAG,SAAS,CAAC;AAEpE,kFAAkF;AAClF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;CACnB"}
@@ -2,24 +2,22 @@
2
2
  /**
3
3
  * Chart rule vocabulary — shared types.
4
4
  *
5
- * A rule is a small, serializable tree of nodes discriminated by `kind`. The
5
+ * A rule is a small, serializable value discriminated by `kind`. The
6
6
  * agent builds it with the helpers in `builders.ts`, which emit it wrapped in a
7
7
  * `{$rule}` placeholder — the same idea as the `{$fn}` placeholders a chart
8
8
  * already emits. The renderer resolves it with `evaluate`; the settings panel
9
9
  * reads it with `describe`. All three agree because a node can only ever be one
10
- * of the kinds defined here — the closed set the `chartRuleSchema` describes.
10
+ * of the kinds defined here — the closed set the executable `chartRuleSchema`
11
+ * validates at runtime.
11
12
  *
12
- * v1 is scoped to conditional formatting: compare this datum's `value` against a
13
- * constant, and (optionally) pick between two values. Richer pieces — aggregates,
14
- * logic, more refs — are the documented roadmap in the README.
13
+ * v1 is deliberately non-recursive: compare this datum's `value` or a literal
14
+ * against another literal, then choose between two colour literals. Rules may
15
+ * not appear inside operands or branches. Richer expressions require a future
16
+ * contract version.
15
17
  */
16
18
  Object.defineProperty(exports, "__esModule", { value: true });
17
19
  exports.MAX_RULE_DEPTH = exports.CHART_RULE_CONTRACT_VERSION = void 0;
18
20
  exports.CHART_RULE_CONTRACT_VERSION = 'chart_rule.v1';
19
- /**
20
- * The deepest a rule may nest before `evaluate`/`describe` refuse it. Real rules
21
- * are a handful of levels; this only stops a pathological deserialized tree from
22
- * overflowing the stack. Far below the JS call-stack limit.
23
- */
21
+ /** @deprecated v1 is non-recursive. Retained for source compatibility. */
24
22
  exports.MAX_RULE_DEPTH = 256;
25
23
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/charts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEU,QAAA,2BAA2B,GAAG,eAAwB,CAAC;AA8EpE;;;;GAIG;AACU,QAAA,cAAc,GAAG,GAAG,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/charts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAIU,QAAA,2BAA2B,GAAG,eAAwB,CAAC;AAyFpE,0EAA0E;AAC7D,QAAA,cAAc,GAAG,GAAG,CAAC"}
@@ -1,22 +1,20 @@
1
1
  /**
2
2
  * Chart rule vocabulary — shared types.
3
3
  *
4
- * A rule is a small, serializable tree of nodes discriminated by `kind`. The
4
+ * A rule is a small, serializable value discriminated by `kind`. The
5
5
  * agent builds it with the helpers in `builders.ts`, which emit it wrapped in a
6
6
  * `{$rule}` placeholder — the same idea as the `{$fn}` placeholders a chart
7
7
  * already emits. The renderer resolves it with `evaluate`; the settings panel
8
8
  * reads it with `describe`. All three agree because a node can only ever be one
9
- * of the kinds defined here — the closed set the `chartRuleSchema` describes.
9
+ * of the kinds defined here — the closed set the executable `chartRuleSchema`
10
+ * validates at runtime.
10
11
  *
11
- * v1 is scoped to conditional formatting: compare this datum's `value` against a
12
- * constant, and (optionally) pick between two values. Richer pieces — aggregates,
13
- * logic, more refs — are the documented roadmap in the README.
12
+ * v1 is deliberately non-recursive: compare this datum's `value` or a literal
13
+ * against another literal, then choose between two colour literals. Rules may
14
+ * not appear inside operands or branches. Richer expressions require a future
15
+ * contract version.
14
16
  */
15
17
  export const CHART_RULE_CONTRACT_VERSION = 'chart_rule.v1';
16
- /**
17
- * The deepest a rule may nest before `evaluate`/`describe` refuse it. Real rules
18
- * are a handful of levels; this only stops a pathological deserialized tree from
19
- * overflowing the stack. Far below the JS call-stack limit.
20
- */
18
+ /** @deprecated v1 is non-recursive. Retained for source compatibility. */
21
19
  export const MAX_RULE_DEPTH = 256;
22
20
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/lib/charts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,eAAwB,CAAC;AA8EpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC"}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/lib/charts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,MAAM,CAAC,MAAM,2BAA2B,GAAG,eAAwB,CAAC;AAyFpE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC"}