oakscriptjs 0.21.0 → 0.23.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.
Files changed (52) hide show
  1. package/dist/cjs/check/index.d.ts.map +1 -1
  2. package/dist/cjs/check/index.js +2 -1
  3. package/dist/cjs/check/index.js.map +2 -2
  4. package/dist/cjs/check/spec.d.ts +1 -1
  5. package/dist/cjs/check/spec.d.ts.map +1 -1
  6. package/dist/cjs/check/spec.js +1 -1
  7. package/dist/cjs/check/spec.js.map +2 -2
  8. package/dist/cjs/index.d.ts +1 -1
  9. package/dist/cjs/index.js +1 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/runtime/adapters/SimpleInputAdapter.js +1 -1
  12. package/dist/cjs/runtime/adapters/SimpleInputAdapter.js.map +2 -2
  13. package/dist/cjs/runtime/types.d.ts +10 -4
  14. package/dist/cjs/runtime/types.d.ts.map +1 -1
  15. package/dist/cjs/runtime/types.js.map +1 -1
  16. package/dist/cjs/script/globals.d.ts +1 -0
  17. package/dist/cjs/script/globals.d.ts.map +1 -1
  18. package/dist/cjs/script/globals.js.map +1 -1
  19. package/dist/cjs/script/index.d.ts +30 -1
  20. package/dist/cjs/script/index.d.ts.map +1 -1
  21. package/dist/cjs/script/index.js +66 -7
  22. package/dist/cjs/script/index.js.map +2 -2
  23. package/dist/esm/check/index.d.ts.map +1 -1
  24. package/dist/esm/check/index.js +2 -1
  25. package/dist/esm/check/index.js.map +1 -1
  26. package/dist/esm/check/spec.d.ts +1 -1
  27. package/dist/esm/check/spec.d.ts.map +1 -1
  28. package/dist/esm/check/spec.js +1 -1
  29. package/dist/esm/check/spec.js.map +1 -1
  30. package/dist/esm/index.d.ts +1 -1
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/runtime/adapters/SimpleInputAdapter.js +1 -1
  33. package/dist/esm/runtime/adapters/SimpleInputAdapter.js.map +1 -1
  34. package/dist/esm/runtime/types.d.ts +10 -4
  35. package/dist/esm/runtime/types.d.ts.map +1 -1
  36. package/dist/esm/script/globals.d.ts +1 -0
  37. package/dist/esm/script/globals.d.ts.map +1 -1
  38. package/dist/esm/script/globals.js.map +1 -1
  39. package/dist/esm/script/index.d.ts +30 -1
  40. package/dist/esm/script/index.d.ts.map +1 -1
  41. package/dist/esm/script/index.js +74 -6
  42. package/dist/esm/script/index.js.map +1 -1
  43. package/package.json +1 -1
  44. package/skills/oakscript/reference/script-structure.md +13 -3
  45. package/skills/oakscript/spec.schema.json +3 -1
  46. package/src/check/index.ts +2 -1
  47. package/src/check/spec.ts +1 -1
  48. package/src/index.ts +1 -1
  49. package/src/runtime/adapters/SimpleInputAdapter.ts +1 -1
  50. package/src/runtime/types.ts +10 -4
  51. package/src/script/globals.ts +1 -0
  52. package/src/script/index.ts +87 -7
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/check/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAQL,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGvF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1I,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,EACf,aA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AgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CAsKnF"}
@@ -79,7 +79,8 @@ function alternative(input) {
79
79
  const d = Number(input.defval);
80
80
  return [d + 1, d - 1, d * 2, d + 10].find((v) => Number.isFinite(v) && v !== d && inRange(v));
81
81
  }
82
- case "float": {
82
+ case "float":
83
+ case "price": {
83
84
  const d = Number(input.defval);
84
85
  return [d * 1.5, d + 1, d / 2, d - 1].find((v) => Number.isFinite(v) && v !== d && inRange(v));
85
86
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/check/index.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Checks a script source: runs it like a host (a declaration run on zero bars, then a run on bars) and\n * returns a report an agent or a host can act on: what the script declares (inputs, outputs, strategy), what its outputs\n * contain (values, warm-up, ranges, signal counts, trades), warnings for the mistakes that give no error (an empty plot,\n * a signal on every bar or never, an input that changes nothing...), and the result of a spec (the expected inputs,\n * outputs and signals) and of a reference (expected values per bar). The `oakscript check` command prints it.\n *\n * ```ts\n * import { checkScript } from 'oakscriptjs/check';\n * const report = checkScript(source, { spec: { overlay: true, outputs: ['Fast', 'Slow'] } });\n * report.ok; report.errors; report.warnings; report.spec?.items;\n * ```\n *\n * @module check\n */\nimport type { Bar } from '../types/index.js';\nimport type { ScriptRunResult } from '../script/index.js';\nimport type { InputConfig } from '../runtime/types.js';\nimport {\n compileScript,\n inferTimeframe,\n runScript,\n incrementalReason,\n syntheticBars,\n timeframeSeconds,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\nimport { runChecks, signalBars, type CheckContext, type CheckItem } from './checks.js';\nimport { validateSpec } from './spec.js';\n\nexport { validateSpec, specJsonSchema, SPEC_FIELDS, SPEC_FILE_FIELDS } from './spec.js';\nexport { runChecks, signalBars, type CheckContext, type CheckItem, type CheckPlot, type CheckSignal, type SignalBars } from './checks.js';\nexport { formatReport, assertCheck } from './format.js';\n\nexport {\n compileScript,\n inferTimeframe,\n rewriteImports,\n runScript,\n scriptArguments,\n syntheticBars,\n testChart,\n timeframeSeconds,\n LIBRARY_PARAMETER,\n SCRIPT_GLOBALS,\n SCRIPT_PREFIX,\n SCRIPT_SUFFIX,\n TestEngine,\n wrapSource,\n type RunScriptOptions,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\n\n// \u2500\u2500 Spec, reference and report types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Expected count of a signal (a shape, character, arrow, alert condition, background or bar colour) over the bars. */\nexport interface SignalSpec {\n /** At least this many bars with the signal. */\n min?: number;\n /** At most this many bars with the signal. */\n max?: number;\n /** At least this share of the bars (0 to 1). */\n minShare?: number;\n /** At most this share of the bars (0 to 1). */\n maxShare?: number;\n}\n\n/** Expected values of a plot. */\nexport interface PlotSpec {\n /** Every value is at least this. */\n min?: number;\n /** Every value is at most this. */\n max?: number;\n /** The first value comes at this bar index or before (the warm-up). */\n warmup?: number;\n}\n\n/** Expected input: the keys are compared when given. */\nexport interface InputSpec {\n type?: InputConfig['type'];\n defval?: unknown;\n title?: string;\n min?: number;\n max?: number;\n options?: string[];\n}\n\n/**\n * What the user asked for, written before the script: each given entry is checked. Inputs, plots and signals are\n * found by id or title (case insensitive).\n */\nexport interface CheckSpec {\n kind?: 'indicator' | 'strategy';\n title?: string;\n overlay?: boolean;\n /** Inputs that must exist, with the expected type, default... */\n inputs?: Record<string, InputSpec>;\n /** Outputs that must exist (a title, or a title and a kind: plot, shape, char, arrow, candle, bar, hline, bgcolor, barcolor, alertcondition). */\n outputs?: Array<string | { title: string; kind?: string }>;\n /** Value checks per plot. */\n plots?: Record<string, PlotSpec>;\n /** Count checks per signal. */\n signals?: Record<string, SignalSpec>;\n /** Number of closed trades of a strategy. */\n trades?: { min?: number; max?: number };\n}\n\n/** Expected values per bar, e.g. the outputs of the Pine script a port follows, on the same bars. */\nexport interface CheckReference {\n /** Bar times (UNIX seconds). */\n times: number[];\n /** Expected values per plot id or title, aligned with `times` (NaN or null: na). */\n columns: Record<string, Array<number | null>>;\n /** Equal when |a - b| <= tolerance * max(1, |a|, |b|) (default 1e-10), or both na. */\n tolerance?: number;\n /** A column without a plot of that id or title is listed as ignored instead of failing (a chart export holds other columns). */\n ignoreUnknown?: boolean;\n}\n\n/** A run on edge-case bars (`scenarios: true`): a short history, daily bars, flat prices, no volume, a gap. */\nexport interface CheckScenario {\n name: string;\n description: string;\n timeframe: string;\n bars: () => Bar[];\n}\n\nexport interface CheckOptions extends TestChartOptions {\n /** Bars of the run (default: 1,500 deterministic synthetic bars of the timeframe). */\n bars?: Bar[];\n /** Input values by id (default: the defaults). */\n inputs?: Record<string, unknown>;\n spec?: CheckSpec;\n reference?: CheckReference;\n /** Compiles the source (default: `new Function`; the CLI compiles with the file name for error lines). */\n compile?: (source: string) => () => void;\n /** Wraps each run (the CLI stops a run that takes too long). */\n run?: <T>(fn: () => T) => T;\n /** File name of the source, to read the error lines from the stack (`<file>:line:column`). */\n filename?: string;\n /** Re-run with each input changed to find inputs that change no output (default true). */\n inputSweep?: boolean;\n /** Behaviour checks: called with the outputs of the run per bar (see {@link CheckContext}); their results join the spec items. */\n checks?: (t: CheckContext) => void;\n /** Also run on the edge-case bars of {@link SCENARIOS} (or the given ones): their errors fail the check. */\n scenarios?: boolean | CheckScenario[];\n}\n\nexport type CheckStage = 'syntax' | 'types' | 'declaration' | 'run' | 'timeout' | 'spec' | 'reference' | 'scenario';\n\nexport interface CheckError {\n stage: CheckStage;\n message: string;\n line?: number;\n column?: number;\n /** TypeScript error code (stage \"types\"). */\n code?: string;\n}\n\nexport interface CheckWarning {\n code:\n | 'empty-plot'\n | 'constant-plot'\n | 'late-start'\n | 'signal-never'\n | 'signal-everywhere'\n | 'one-colour'\n | 'unused-input'\n | 'input-error'\n | 'no-trades'\n | 'no-output';\n message: string;\n /** Output or input title (or id). */\n target?: string;\n}\n\nexport interface PlotSummary {\n id: string;\n title: string;\n /** Bars with a value (not na). */\n values: number;\n /** Bar index of the first value (-1: none). */\n firstBar: number;\n min: number | null;\n max: number | null;\n /** Values of the last 5 bars (null: na). */\n last: Array<number | null>;\n /** Distinct per-bar colours (0: the plot colour is the same on every bar). */\n colours: number;\n}\n\nexport interface SignalSummary {\n kind: 'shape' | 'char' | 'arrow' | 'alertcondition' | 'bgcolor' | 'barcolor';\n id: string;\n title: string;\n /** Bars with the signal. */\n count: number;\n /** count / number of bars. */\n share: number;\n firstBar: number;\n lastBar: number;\n}\n\nexport interface TradeSummary {\n entry: string;\n direction: 'long' | 'short';\n entryBar: number;\n entryPrice: number;\n exitBar: number | null;\n exitPrice: number | null;\n profit: number;\n}\n\nexport interface CheckReport {\n /** No error, no failed spec or reference check. Warnings do not change it. */\n ok: boolean;\n bars: { count: number; first: number | null; last: number | null; timeframe: string; synthetic: boolean };\n errors: CheckError[];\n warnings: CheckWarning[];\n declaration?: {\n kind: 'indicator' | 'strategy';\n title: string;\n shortTitle?: string;\n overlay: boolean;\n inputs: Array<Pick<InputConfig, 'id' | 'type' | 'defval' | 'title' | 'min' | 'max' | 'options'>>;\n outputs: Array<{ kind: string; id: string; title: string }>;\n strategy?: Record<string, unknown>;\n };\n plots: PlotSummary[];\n signals: SignalSummary[];\n drawings: { labels: number; lines: number; boxes: number; tables: number; polylines: number; linefills: number };\n /** alert() calls of the script (all bars). */\n alertCalls: number;\n /**\n * Live updates on a chart that runs the script with createScriptRun (#196): resumed (the newest bars only) or full\n * runs, with the reason (state outside persist(), drawings in two blocks, request.security...). Not a warning: the\n * results are the same.\n */\n liveUpdates?: { resumed: boolean; reason: string | null };\n strategy?: { closedTrades: number; openTrade: boolean; netProfit: number; wins: number; first: TradeSummary[] };\n /** Spec items and behaviour checks. */\n spec?: { passed: number; failed: number; items: CheckItem[] };\n reference?: Array<{\n column: string;\n output?: string;\n /** No plot of this id or title, and `ignoreUnknown` is set. */\n ignored?: boolean;\n equal: number;\n total: number;\n firstMismatch?: { bar: number; time: number; expected: number | null; actual: number | null };\n }>;\n /** Runs on edge-case bars: their errors (also in `errors`, stage \"scenario\") and the plots with no value the main run does not have. */\n scenarios?: Array<{ name: string; description: string; bars: number; errors: CheckError[]; warnings: CheckWarning[] }>;\n}\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst lower = (s: string | undefined): string => (s ?? '').trim().toLowerCase();\n\n/** Line and column of a script error, from `error.scriptLine` or the `<filename>:line:column` frames of its stack. */\nexport function errorLocation(error: unknown, filename?: string): { line?: number; column?: number } {\n const e = error as { scriptLine?: number; scriptColumn?: number; stack?: string } | undefined;\n if (e && typeof e.scriptLine === 'number') return { line: e.scriptLine, column: e.scriptColumn };\n if (!filename || typeof e?.stack !== 'string') return {};\n const name = filename.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const m = new RegExp(`${name}:(\\\\d+)(?::(\\\\d+))?`).exec(e.stack);\n return m ? { line: Number(m[1]), column: m[2] ? Number(m[2]) : undefined } : {};\n}\n\nfunction messageOf(error: unknown): string {\n // an error of another realm (the time limit of the CLI) is not `instanceof Error`\n const e = error as { name?: unknown; message?: unknown } | null;\n if (e && typeof e === 'object' && typeof e.message === 'string') {\n return `${!e.name || e.name === 'Error' ? '' : `${String(e.name)}: `}${e.message}`;\n }\n return String(error);\n}\n\nfunction isTimeout(error: unknown): boolean {\n return /Script execution timed out/i.test(messageOf(error));\n}\n\n/** An input value different from the default, valid for the input (undefined: not tried). */\nfunction alternative(input: InputConfig): unknown {\n const inRange = (v: number) => (input.min === undefined || v >= input.min) && (input.max === undefined || v <= input.max);\n switch (input.type) {\n case 'int': {\n const d = Number(input.defval);\n return [d + 1, d - 1, d * 2, d + 10].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'float': {\n const d = Number(input.defval);\n return [d * 1.5, d + 1, d / 2, d - 1].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'bool':\n return !input.defval;\n case 'string':\n return input.options?.find((o) => o !== input.defval);\n case 'source':\n return input.defval === 'open' ? 'close' : 'open';\n case 'color':\n return input.defval === '#123456' ? '#654321' : '#123456';\n default:\n return undefined;\n }\n}\n\n/** Everything a run draws or signals, to compare two runs. */\nfunction fingerprint(run: ScriptRunResult, engine: ScriptRun['engine']): string {\n return JSON.stringify([run.result, engine ? [engine.closed, engine.openTradeNow] : null]);\n}\n\nfunction findByName<T extends { id: string; title?: string }>(items: T[], name: string): T | undefined {\n const n = lower(name);\n return items.find((x) => lower(x.id) === n) ?? items.find((x) => lower(x.title) === n);\n}\n\n// \u2500\u2500 Report parts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction summarizePlots(run: ScriptRunResult, bars: Bar[]): PlotSummary[] {\n const index = new Map(bars.map((b, i) => [b.time, i]));\n return run.plotConfig.map((p) => {\n const points = (run.result.plots[p.id] ?? []) as Array<{ time: number; value: number; color?: string }>;\n const byTime = new Map(points.map((pt) => [pt.time, pt.value]));\n let min = Infinity;\n let max = -Infinity;\n const colours = new Set<string>();\n for (const pt of points) {\n if (pt.value < min) min = pt.value;\n if (pt.value > max) max = pt.value;\n if (pt.color !== undefined) colours.add(String(pt.color));\n }\n return {\n id: p.id,\n title: p.title ?? p.id,\n values: points.length,\n firstBar: points.length ? (index.get(points[0]!.time) ?? -1) : -1,\n min: points.length ? min : null,\n max: points.length ? max : null,\n last: bars.slice(-5).map((b) => byTime.get(b.time) ?? null),\n colours: colours.size,\n };\n });\n}\n\nfunction summarizeSignals(run: ScriptRunResult, bars: Bar[]): SignalSummary[] {\n const n = Math.max(1, bars.length);\n return signalBars(run, bars).map((x) => ({\n kind: x.kind,\n id: x.id,\n title: x.title,\n count: x.bars.length,\n share: x.bars.length / n,\n firstBar: x.bars[0] ?? -1,\n lastBar: x.bars[x.bars.length - 1] ?? -1,\n }));\n}\n\nfunction summarizeStrategy(engine: NonNullable<ScriptRun['engine']>): NonNullable<CheckReport['strategy']> {\n const trades = engine.closed;\n const first = trades.slice(0, 3).map(\n (t): TradeSummary => ({\n entry: t.entry_id,\n direction: t.size >= 0 ? 'long' : 'short',\n entryBar: t.entry_bar_index,\n entryPrice: t.entry_price,\n exitBar: t.exit_bar_index ?? null,\n exitPrice: t.exit_price ?? null,\n profit: t.profit,\n })\n );\n return {\n closedTrades: trades.length,\n openTrade: engine.openTradeNow !== null,\n netProfit: trades.reduce((s, t) => s + t.profit, 0),\n wins: trades.filter((t) => t.profit > 0).length,\n first,\n };\n}\n\nfunction warningsOf(report: CheckReport, bars: Bar[]): CheckWarning[] {\n const w: CheckWarning[] = [];\n const n = bars.length;\n const outputs = report.declaration?.outputs ?? [];\n const drawings = Object.values(report.drawings).reduce((a, b) => a + b, 0);\n if (!outputs.length && !drawings && !report.strategy && !report.alertCalls) {\n w.push({ code: 'no-output', message: 'The script declares no output (plot, shape, colour, drawing, alert): it shows nothing.' });\n }\n for (const p of report.plots) {\n if (p.values === 0) {\n w.push({\n code: 'empty-plot',\n target: p.title,\n message: `Plot \"${p.title}\" has no value on any bar (na everywhere): a ta.* Series returned from a bar loop, a division by zero, a NaN input or a length longer than the bars?`,\n });\n continue;\n }\n if (p.values > 1 && p.min === p.max) {\n w.push({ code: 'constant-plot', target: p.title, message: `Plot \"${p.title}\" has the same value (${p.min}) on every bar: check that it is meant (a level is an hline()).` });\n }\n if (n >= 20 && p.firstBar > n / 2) {\n w.push({ code: 'late-start', target: p.title, message: `Plot \"${p.title}\" starts on bar ${p.firstBar} of ${n}: a long warm-up (long lengths, or a higher timeframe).` });\n }\n if (p.colours === 1 && p.values >= 20) {\n w.push({ code: 'one-colour', target: p.title, message: `Plot \"${p.title}\" has per-bar colours but the same colour on every bar: is the colour condition ever false?` });\n }\n }\n if (n >= 20) {\n for (const s of report.signals) {\n if (s.count === 0) {\n w.push({ code: 'signal-never', target: s.title, message: `${s.kind} \"${s.title}\" is never true on the ${n} bars: check the condition (or test on more bars).` });\n } else if (s.share > 0.5 && s.kind !== 'bgcolor' && s.kind !== 'barcolor') {\n w.push({\n code: 'signal-everywhere',\n target: s.title,\n message: `${s.kind} \"${s.title}\" is true on ${Math.round(s.share * 100)} % of the bars: a Series used as a JavaScript boolean (always true), or a condition that is not a cross?`,\n });\n }\n }\n }\n if (report.strategy && report.strategy.closedTrades === 0 && !report.strategy.openTrade) {\n w.push({ code: 'no-trades', message: `The strategy makes no trade on the ${n} bars: check the entry conditions (plot them with plotshape) and where the orders are placed.` });\n }\n return w;\n}\n\nfunction checkSpec(spec: CheckSpec, report: CheckReport, run: ScriptRunResult | undefined): NonNullable<CheckReport['spec']> {\n const items: NonNullable<CheckReport['spec']>['items'] = [];\n const item = (check: string, ok: boolean, expected?: unknown, actual?: unknown) => items.push({ check, ok, expected, actual });\n const d = report.declaration;\n if (spec.kind !== undefined) item('kind', d?.kind === spec.kind, spec.kind, d?.kind);\n if (spec.title !== undefined) item('title', d?.title === spec.title, spec.title, d?.title);\n if (spec.overlay !== undefined) item('overlay', d?.overlay === spec.overlay, spec.overlay, d?.overlay);\n const inputs = run?.inputConfig ?? [];\n for (const [name, want] of Object.entries(spec.inputs ?? {})) {\n const got = findByName(inputs, name);\n if (!got) {\n item(`input \"${name}\" exists`, false, name, inputs.map((i) => i.id));\n continue;\n }\n for (const key of ['type', 'defval', 'title', 'min', 'max', 'options'] as const) {\n if (want[key] === undefined) continue;\n item(`input \"${name}\" ${key}`, JSON.stringify(got[key]) === JSON.stringify(want[key]), want[key], got[key]);\n }\n }\n const all = [\n ...(d?.outputs ?? []),\n ...(run?.hlineConfig ?? []).map((h) => ({ kind: 'hline', id: h.id, title: h.title ?? h.id })),\n ...(run?.barColorConfig ?? []).map((b) => ({ kind: b.kind, id: b.id, title: b.title ?? b.id })),\n ...(run?.alertConfig ?? []).map((a) => ({ kind: 'alertcondition', id: a.id, title: a.title ?? a.id })),\n ];\n for (const o of spec.outputs ?? []) {\n const { title, kind } = typeof o === 'string' ? { title: o, kind: undefined } : o;\n const got = all.filter((x) => lower(x.title) === lower(title) || lower(x.id) === lower(title));\n const match = kind ? got.find((x) => x.kind === kind) : got[0];\n item(`output \"${title}\"${kind ? ` (${kind})` : ''} exists`, !!match, kind ? `${kind} \"${title}\"` : title, got.length ? got.map((x) => `${x.kind} \"${x.title}\"`) : all.map((x) => `${x.kind} \"${x.title}\"`));\n }\n for (const [name, want] of Object.entries(spec.plots ?? {})) {\n const p = findByName(report.plots, name);\n if (!p) {\n item(`plot \"${name}\" exists`, false, name, report.plots.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`plot \"${name}\" min`, p.min !== null && p.min >= want.min, `>= ${want.min}`, p.min);\n if (want.max !== undefined) item(`plot \"${name}\" max`, p.max !== null && p.max <= want.max, `<= ${want.max}`, p.max);\n if (want.warmup !== undefined) item(`plot \"${name}\" first value`, p.firstBar >= 0 && p.firstBar <= want.warmup, `bar <= ${want.warmup}`, p.firstBar);\n }\n for (const [name, want] of Object.entries(spec.signals ?? {})) {\n const s = findByName(report.signals, name);\n if (!s) {\n item(`signal \"${name}\" exists`, false, name, report.signals.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`signal \"${name}\" count`, s.count >= want.min, `>= ${want.min}`, s.count);\n if (want.max !== undefined) item(`signal \"${name}\" count`, s.count <= want.max, `<= ${want.max}`, s.count);\n if (want.minShare !== undefined) item(`signal \"${name}\" share`, s.share >= want.minShare, `>= ${want.minShare}`, Number(s.share.toFixed(4)));\n if (want.maxShare !== undefined) item(`signal \"${name}\" share`, s.share <= want.maxShare, `<= ${want.maxShare}`, Number(s.share.toFixed(4)));\n }\n if (spec.trades) {\n const t = report.strategy?.closedTrades;\n if (t === undefined) item('trades', false, 'a strategy', d?.kind);\n else {\n if (spec.trades.min !== undefined) item('closed trades', t >= spec.trades.min, `>= ${spec.trades.min}`, t);\n if (spec.trades.max !== undefined) item('closed trades', t <= spec.trades.max, `<= ${spec.trades.max}`, t);\n }\n }\n const failed = items.filter((i) => !i.ok).length;\n return { passed: items.length - failed, failed, items };\n}\n\nfunction checkReference(ref: CheckReference, run: ScriptRunResult, bars: Bar[]): NonNullable<CheckReport['reference']> {\n const tol = ref.tolerance ?? 1e-10;\n const index = new Map(bars.map((b, i) => [b.time, i]));\n const na = (v: number | null | undefined) => v === null || v === undefined || Number.isNaN(v);\n return Object.entries(ref.columns).map(([column, expected]) => {\n const plot = findByName(\n run.plotConfig.map((p) => ({ id: p.id, title: p.title ?? p.id })),\n column\n );\n if (!plot) return ref.ignoreUnknown ? { column, ignored: true, equal: 0, total: 0 } : { column, equal: 0, total: expected.length };\n const values = new Map(((run.result.plots[plot.id] ?? []) as Array<{ time: number; value: number }>).map((p) => [p.time, p.value]));\n let equal = 0;\n let total = 0;\n let firstMismatch: { bar: number; time: number; expected: number | null; actual: number | null } | undefined;\n ref.times.forEach((time, k) => {\n const bar = index.get(time);\n if (bar === undefined) return;\n total++;\n const e = expected[k];\n const a = values.get(time);\n const same = na(e) && na(a) ? true : na(e) || na(a) ? false : Math.abs(a! - e!) <= tol * Math.max(1, Math.abs(a!), Math.abs(e!));\n if (same) equal++;\n else firstMismatch ??= { bar, time, expected: na(e) ? null : e!, actual: na(a) ? null : a! };\n });\n return { column, output: plot.title, equal, total, ...(firstMismatch ? { firstMismatch } : {}) };\n });\n}\n\n// \u2500\u2500 checkScript \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Default number of synthetic bars of a check. */\nexport const CHECK_BARS = 1500;\n\nconst HOUR = 3600;\n\n/** The edge-case bars of `scenarios: true`. */\nexport const SCENARIOS: readonly CheckScenario[] = [\n { name: 'short', description: '30 hourly bars (a short history)', timeframe: '60', bars: () => syntheticBars(30) },\n { name: 'daily', description: '800 daily bars', timeframe: 'D', bars: () => syntheticBars(800, 86400) },\n { name: 'minute', description: '1,000 one-minute bars', timeframe: '1', bars: () => syntheticBars(1000, 60) },\n {\n name: 'flat',\n description: '200 bars with the same price and no volume (zero ranges)',\n timeframe: '60',\n bars: () => syntheticBars(200).map((b) => ({ ...b, open: 100, high: 100, low: 100, close: 100, volume: 0 })),\n },\n {\n name: 'no-volume',\n description: '500 bars without volume (na)',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b) => ({ ...b, volume: NaN })),\n },\n {\n name: 'gap',\n description: '500 hourly bars with a 3-day gap in the middle',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b, i) => (i >= 250 ? { ...b, time: b.time + 72 * HOUR } : b)),\n },\n];\n\n/**\n * Checks a script source (the body of a script, as a host runs it): compiles it, runs it on zero bars (the\n * declarations) and on the bars, and reports its declarations, outputs, warnings and the spec / reference results.\n * Never throws for a script error: the errors are in the report.\n */\nexport function checkScript(source: string, options: CheckOptions = {}): CheckReport {\n const timeframe = options.timeframe ?? (options.bars ? inferTimeframe(options.bars) : '60');\n const step = timeframeSeconds(timeframe) || 3600;\n const bars = options.bars ?? syntheticBars(CHECK_BARS, step);\n const inputs = options.inputs ?? {};\n const wrap = options.run ?? (<T>(fn: () => T) => fn());\n const runOptions = { ...options, timeframe };\n const report: CheckReport = {\n ok: false,\n bars: { count: bars.length, first: bars[0]?.time ?? null, last: bars[bars.length - 1]?.time ?? null, timeframe, synthetic: !options.bars },\n errors: [],\n warnings: [],\n plots: [],\n signals: [],\n drawings: { labels: 0, lines: 0, boxes: 0, tables: 0, polylines: 0, linefills: 0 },\n alertCalls: 0,\n };\n const fail = (stage: CheckStage, error: unknown) =>\n report.errors.push({ stage: isTimeout(error) ? 'timeout' : stage, message: messageOf(error), ...errorLocation(error, options.filename) });\n // a misspelt key would be skipped and the check would pass without checking it\n if (options.spec) for (const message of validateSpec(options.spec)) report.errors.push({ stage: 'spec', message });\n\n // compile once to report syntax errors apart from the run errors\n try {\n (options.compile ?? compileScript)(source);\n } catch (e) {\n fail('syntax', e);\n return finish();\n }\n\n let main: ScriptRun | undefined;\n try {\n const decl = wrap(() => runScript(source, [], inputs, runOptions)).run;\n report.declaration = {\n kind: decl.strategyConfig ? 'strategy' : 'indicator',\n title: decl.metadata.title,\n ...(decl.metadata.shortTitle ? { shortTitle: decl.metadata.shortTitle } : {}),\n overlay: decl.metadata.overlay,\n inputs: decl.inputConfig.map(({ id, type, defval, title, min, max, options: opts }) => ({\n id,\n type,\n defval,\n ...(title !== undefined ? { title } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n ...(opts !== undefined ? { options: opts } : {}),\n })),\n outputs: decl.outputs.map((o) => ({ kind: o.kind, id: o.id, title: o.title ?? o.id })),\n ...(decl.strategyConfig ? { strategy: { ...decl.strategyConfig } } : {}),\n };\n } catch (e) {\n fail('declaration', e);\n return finish();\n }\n\n try {\n main = wrap(() => runScript(source, bars, inputs, runOptions));\n } catch (e) {\n fail('run', e);\n return finish();\n }\n\n const run = main.run;\n const r = run.result;\n report.plots = summarizePlots(run, bars);\n report.signals = summarizeSignals(run, bars);\n report.drawings = {\n labels: r.labels?.length ?? 0,\n lines: r.lines?.length ?? 0,\n boxes: r.boxes?.length ?? 0,\n tables: r.tables?.length ?? 0,\n polylines: r.polylines?.length ?? 0,\n linefills: r.linefills?.length ?? 0,\n };\n report.alertCalls = (r as { alertCalls?: unknown[] }).alertCalls?.length ?? 0;\n if (main.engine) report.strategy = summarizeStrategy(main.engine);\n report.warnings = warningsOf(report, bars);\n // a live chart (createScriptRun) calculates only the newest bars of a script whose state the runtime keeps (#196)\n if (!main.engine) {\n try {\n const reason = wrap(() => incrementalReason(source, bars, inputs, runOptions));\n report.liveUpdates = { resumed: reason === null, reason };\n } catch {\n // the main run already reports the errors of the script\n }\n }\n\n if (options.inputSweep !== false) {\n const base = fingerprint(run, main.engine);\n for (const input of run.inputConfig) {\n const value = alternative(input);\n if (value === undefined) continue;\n try {\n const other = wrap(() => runScript(source, bars, { ...inputs, [input.id]: value }, runOptions));\n if (fingerprint(other.run, other.engine) === base) {\n report.warnings.push({\n code: 'unused-input',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" changes no output (tried ${JSON.stringify(value)} instead of ${JSON.stringify(input.defval)}): is its value used?`,\n });\n }\n } catch (e) {\n report.warnings.push({\n code: 'input-error',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" = ${JSON.stringify(value)} stops the script: ${messageOf(e)}`,\n });\n }\n }\n }\n\n if (options.spec) report.spec = checkSpec(options.spec, report, run);\n if (options.checks) {\n const trades = main.engine?.closed ?? [];\n const items = wrapChecks(() => runChecks(options.checks!, run, bars, inputs, trades));\n const spec = (report.spec ??= { passed: 0, failed: 0, items: [] });\n spec.items.push(...items);\n spec.failed = spec.items.filter((i) => !i.ok).length;\n spec.passed = spec.items.length - spec.failed;\n }\n if (options.reference) report.reference = checkReference(options.reference, run, bars);\n if (options.scenarios) runScenarios(options.scenarios === true ? SCENARIOS : options.scenarios);\n return finish();\n\n function wrapChecks(fn: () => CheckItem[]): CheckItem[] {\n try {\n return wrap(fn);\n } catch (e) {\n return [{ check: 'checks (stopped)', ok: false, actual: messageOf(e) }];\n }\n }\n\n function runScenarios(list: readonly CheckScenario[]): void {\n const known = new Set(report.warnings.map((w) => `${w.code}:${w.target ?? ''}`));\n report.scenarios = list.map((sc) => {\n const b = sc.bars();\n const r = checkScript(source, {\n ...options,\n bars: b,\n timeframe: sc.timeframe,\n spec: undefined,\n reference: undefined,\n checks: undefined,\n scenarios: false,\n inputSweep: false,\n });\n for (const e of r.errors) report.errors.push({ ...e, stage: 'scenario', message: `[${sc.name}: ${sc.description}] ${e.message}` });\n return {\n name: sc.name,\n description: sc.description,\n bars: b.length,\n errors: r.errors,\n // only the na that leaks through (a division by a zero range...): other warnings follow from the bars\n warnings: r.warnings.filter((w) => w.code === 'empty-plot' && !known.has(`${w.code}:${w.target ?? ''}`)),\n };\n });\n }\n\n function finish(): CheckReport {\n if (options.spec && !report.spec) report.spec = checkSpec(options.spec, report, main?.run);\n report.ok =\n report.errors.length === 0 &&\n (report.spec?.failed ?? 0) === 0 &&\n (report.reference ?? []).every((c) => c.ignored || (c.equal === c.total && c.output !== undefined));\n return report;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,qBASO;AACP,oBAAyE;AACzE,kBAA6B;AAE7B,IAAAA,eAA4E;AAC5E,IAAAC,iBA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;AAAA,QAC5B,GAAG;AAAA,QACH,MAAM;AAAA,QACN,WAAW,GAAG;AAAA,QACd,MAAM;AAAA,QACN,WAAW;AAAA,QACX,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,YAAY;AAAA,MACd,CAAC;AACD,iBAAW,KAAKA,GAAE,OAAQ,QAAO,OAAO,KAAK,EAAE,GAAG,GAAG,OAAO,YAAY,SAAS,IAAI,GAAG,IAAI,KAAK,GAAG,WAAW,KAAK,EAAE,OAAO,GAAG,CAAC;AACjI,aAAO;AAAA,QACL,MAAM,GAAG;AAAA,QACT,aAAa,GAAG;AAAA,QAChB,MAAM,EAAE;AAAA,QACR,QAAQA,GAAE;AAAA;AAAA,QAEV,UAAUA,GAAE,SAAS,OAAO,CAAC,MAAM,EAAE,SAAS,gBAAgB,CAAC,MAAM,IAAI,GAAG,EAAE,IAAI,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;AAAA,MACzG;AAAA,IACF,CAAC;AAAA,EACH;AAEA,WAAS,SAAsB;AAC7B,QAAI,QAAQ,QAAQ,CAAC,OAAO,KAAM,QAAO,OAAO,UAAU,QAAQ,MAAM,QAAQ,MAAM,GAAG;AACzF,WAAO,KACL,OAAO,OAAO,WAAW,MACxB,OAAO,MAAM,UAAU,OAAO,MAC9B,OAAO,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,MAAU;AACpG,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["/**\n * @fileoverview Checks a script source: runs it like a host (a declaration run on zero bars, then a run on bars) and\n * returns a report an agent or a host can act on: what the script declares (inputs, outputs, strategy), what its outputs\n * contain (values, warm-up, ranges, signal counts, trades), warnings for the mistakes that give no error (an empty plot,\n * a signal on every bar or never, an input that changes nothing...), and the result of a spec (the expected inputs,\n * outputs and signals) and of a reference (expected values per bar). The `oakscript check` command prints it.\n *\n * ```ts\n * import { checkScript } from 'oakscriptjs/check';\n * const report = checkScript(source, { spec: { overlay: true, outputs: ['Fast', 'Slow'] } });\n * report.ok; report.errors; report.warnings; report.spec?.items;\n * ```\n *\n * @module check\n */\nimport type { Bar } from '../types/index.js';\nimport type { ScriptRunResult } from '../script/index.js';\nimport type { InputConfig } from '../runtime/types.js';\nimport {\n compileScript,\n inferTimeframe,\n runScript,\n incrementalReason,\n syntheticBars,\n timeframeSeconds,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\nimport { runChecks, signalBars, type CheckContext, type CheckItem } from './checks.js';\nimport { validateSpec } from './spec.js';\n\nexport { validateSpec, specJsonSchema, SPEC_FIELDS, SPEC_FILE_FIELDS } from './spec.js';\nexport { runChecks, signalBars, type CheckContext, type CheckItem, type CheckPlot, type CheckSignal, type SignalBars } from './checks.js';\nexport { formatReport, assertCheck } from './format.js';\n\nexport {\n compileScript,\n inferTimeframe,\n rewriteImports,\n runScript,\n scriptArguments,\n syntheticBars,\n testChart,\n timeframeSeconds,\n LIBRARY_PARAMETER,\n SCRIPT_GLOBALS,\n SCRIPT_PREFIX,\n SCRIPT_SUFFIX,\n TestEngine,\n wrapSource,\n type RunScriptOptions,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\n\n// \u2500\u2500 Spec, reference and report types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Expected count of a signal (a shape, character, arrow, alert condition, background or bar colour) over the bars. */\nexport interface SignalSpec {\n /** At least this many bars with the signal. */\n min?: number;\n /** At most this many bars with the signal. */\n max?: number;\n /** At least this share of the bars (0 to 1). */\n minShare?: number;\n /** At most this share of the bars (0 to 1). */\n maxShare?: number;\n}\n\n/** Expected values of a plot. */\nexport interface PlotSpec {\n /** Every value is at least this. */\n min?: number;\n /** Every value is at most this. */\n max?: number;\n /** The first value comes at this bar index or before (the warm-up). */\n warmup?: number;\n}\n\n/** Expected input: the keys are compared when given. */\nexport interface InputSpec {\n type?: InputConfig['type'];\n defval?: unknown;\n title?: string;\n min?: number;\n max?: number;\n options?: string[];\n}\n\n/**\n * What the user asked for, written before the script: each given entry is checked. Inputs, plots and signals are\n * found by id or title (case insensitive).\n */\nexport interface CheckSpec {\n kind?: 'indicator' | 'strategy';\n title?: string;\n overlay?: boolean;\n /** Inputs that must exist, with the expected type, default... */\n inputs?: Record<string, InputSpec>;\n /** Outputs that must exist (a title, or a title and a kind: plot, shape, char, arrow, candle, bar, hline, bgcolor, barcolor, alertcondition). */\n outputs?: Array<string | { title: string; kind?: string }>;\n /** Value checks per plot. */\n plots?: Record<string, PlotSpec>;\n /** Count checks per signal. */\n signals?: Record<string, SignalSpec>;\n /** Number of closed trades of a strategy. */\n trades?: { min?: number; max?: number };\n}\n\n/** Expected values per bar, e.g. the outputs of the Pine script a port follows, on the same bars. */\nexport interface CheckReference {\n /** Bar times (UNIX seconds). */\n times: number[];\n /** Expected values per plot id or title, aligned with `times` (NaN or null: na). */\n columns: Record<string, Array<number | null>>;\n /** Equal when |a - b| <= tolerance * max(1, |a|, |b|) (default 1e-10), or both na. */\n tolerance?: number;\n /** A column without a plot of that id or title is listed as ignored instead of failing (a chart export holds other columns). */\n ignoreUnknown?: boolean;\n}\n\n/** A run on edge-case bars (`scenarios: true`): a short history, daily bars, flat prices, no volume, a gap. */\nexport interface CheckScenario {\n name: string;\n description: string;\n timeframe: string;\n bars: () => Bar[];\n}\n\nexport interface CheckOptions extends TestChartOptions {\n /** Bars of the run (default: 1,500 deterministic synthetic bars of the timeframe). */\n bars?: Bar[];\n /** Input values by id (default: the defaults). */\n inputs?: Record<string, unknown>;\n spec?: CheckSpec;\n reference?: CheckReference;\n /** Compiles the source (default: `new Function`; the CLI compiles with the file name for error lines). */\n compile?: (source: string) => () => void;\n /** Wraps each run (the CLI stops a run that takes too long). */\n run?: <T>(fn: () => T) => T;\n /** File name of the source, to read the error lines from the stack (`<file>:line:column`). */\n filename?: string;\n /** Re-run with each input changed to find inputs that change no output (default true). */\n inputSweep?: boolean;\n /** Behaviour checks: called with the outputs of the run per bar (see {@link CheckContext}); their results join the spec items. */\n checks?: (t: CheckContext) => void;\n /** Also run on the edge-case bars of {@link SCENARIOS} (or the given ones): their errors fail the check. */\n scenarios?: boolean | CheckScenario[];\n}\n\nexport type CheckStage = 'syntax' | 'types' | 'declaration' | 'run' | 'timeout' | 'spec' | 'reference' | 'scenario';\n\nexport interface CheckError {\n stage: CheckStage;\n message: string;\n line?: number;\n column?: number;\n /** TypeScript error code (stage \"types\"). */\n code?: string;\n}\n\nexport interface CheckWarning {\n code:\n | 'empty-plot'\n | 'constant-plot'\n | 'late-start'\n | 'signal-never'\n | 'signal-everywhere'\n | 'one-colour'\n | 'unused-input'\n | 'input-error'\n | 'no-trades'\n | 'no-output';\n message: string;\n /** Output or input title (or id). */\n target?: string;\n}\n\nexport interface PlotSummary {\n id: string;\n title: string;\n /** Bars with a value (not na). */\n values: number;\n /** Bar index of the first value (-1: none). */\n firstBar: number;\n min: number | null;\n max: number | null;\n /** Values of the last 5 bars (null: na). */\n last: Array<number | null>;\n /** Distinct per-bar colours (0: the plot colour is the same on every bar). */\n colours: number;\n}\n\nexport interface SignalSummary {\n kind: 'shape' | 'char' | 'arrow' | 'alertcondition' | 'bgcolor' | 'barcolor';\n id: string;\n title: string;\n /** Bars with the signal. */\n count: number;\n /** count / number of bars. */\n share: number;\n firstBar: number;\n lastBar: number;\n}\n\nexport interface TradeSummary {\n entry: string;\n direction: 'long' | 'short';\n entryBar: number;\n entryPrice: number;\n exitBar: number | null;\n exitPrice: number | null;\n profit: number;\n}\n\nexport interface CheckReport {\n /** No error, no failed spec or reference check. Warnings do not change it. */\n ok: boolean;\n bars: { count: number; first: number | null; last: number | null; timeframe: string; synthetic: boolean };\n errors: CheckError[];\n warnings: CheckWarning[];\n declaration?: {\n kind: 'indicator' | 'strategy';\n title: string;\n shortTitle?: string;\n overlay: boolean;\n inputs: Array<Pick<InputConfig, 'id' | 'type' | 'defval' | 'title' | 'min' | 'max' | 'options'>>;\n outputs: Array<{ kind: string; id: string; title: string }>;\n strategy?: Record<string, unknown>;\n };\n plots: PlotSummary[];\n signals: SignalSummary[];\n drawings: { labels: number; lines: number; boxes: number; tables: number; polylines: number; linefills: number };\n /** alert() calls of the script (all bars). */\n alertCalls: number;\n /**\n * Live updates on a chart that runs the script with createScriptRun (#196): resumed (the newest bars only) or full\n * runs, with the reason (state outside persist(), drawings in two blocks, request.security...). Not a warning: the\n * results are the same.\n */\n liveUpdates?: { resumed: boolean; reason: string | null };\n strategy?: { closedTrades: number; openTrade: boolean; netProfit: number; wins: number; first: TradeSummary[] };\n /** Spec items and behaviour checks. */\n spec?: { passed: number; failed: number; items: CheckItem[] };\n reference?: Array<{\n column: string;\n output?: string;\n /** No plot of this id or title, and `ignoreUnknown` is set. */\n ignored?: boolean;\n equal: number;\n total: number;\n firstMismatch?: { bar: number; time: number; expected: number | null; actual: number | null };\n }>;\n /** Runs on edge-case bars: their errors (also in `errors`, stage \"scenario\") and the plots with no value the main run does not have. */\n scenarios?: Array<{ name: string; description: string; bars: number; errors: CheckError[]; warnings: CheckWarning[] }>;\n}\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst lower = (s: string | undefined): string => (s ?? '').trim().toLowerCase();\n\n/** Line and column of a script error, from `error.scriptLine` or the `<filename>:line:column` frames of its stack. */\nexport function errorLocation(error: unknown, filename?: string): { line?: number; column?: number } {\n const e = error as { scriptLine?: number; scriptColumn?: number; stack?: string } | undefined;\n if (e && typeof e.scriptLine === 'number') return { line: e.scriptLine, column: e.scriptColumn };\n if (!filename || typeof e?.stack !== 'string') return {};\n const name = filename.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const m = new RegExp(`${name}:(\\\\d+)(?::(\\\\d+))?`).exec(e.stack);\n return m ? { line: Number(m[1]), column: m[2] ? Number(m[2]) : undefined } : {};\n}\n\nfunction messageOf(error: unknown): string {\n // an error of another realm (the time limit of the CLI) is not `instanceof Error`\n const e = error as { name?: unknown; message?: unknown } | null;\n if (e && typeof e === 'object' && typeof e.message === 'string') {\n return `${!e.name || e.name === 'Error' ? '' : `${String(e.name)}: `}${e.message}`;\n }\n return String(error);\n}\n\nfunction isTimeout(error: unknown): boolean {\n return /Script execution timed out/i.test(messageOf(error));\n}\n\n/** An input value different from the default, valid for the input (undefined: not tried). */\nfunction alternative(input: InputConfig): unknown {\n const inRange = (v: number) => (input.min === undefined || v >= input.min) && (input.max === undefined || v <= input.max);\n switch (input.type) {\n case 'int': {\n const d = Number(input.defval);\n return [d + 1, d - 1, d * 2, d + 10].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'float':\n case 'price': {\n const d = Number(input.defval);\n return [d * 1.5, d + 1, d / 2, d - 1].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'bool':\n return !input.defval;\n case 'string':\n return input.options?.find((o) => o !== input.defval);\n case 'source':\n return input.defval === 'open' ? 'close' : 'open';\n case 'color':\n return input.defval === '#123456' ? '#654321' : '#123456';\n default:\n return undefined;\n }\n}\n\n/** Everything a run draws or signals, to compare two runs. */\nfunction fingerprint(run: ScriptRunResult, engine: ScriptRun['engine']): string {\n return JSON.stringify([run.result, engine ? [engine.closed, engine.openTradeNow] : null]);\n}\n\nfunction findByName<T extends { id: string; title?: string }>(items: T[], name: string): T | undefined {\n const n = lower(name);\n return items.find((x) => lower(x.id) === n) ?? items.find((x) => lower(x.title) === n);\n}\n\n// \u2500\u2500 Report parts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction summarizePlots(run: ScriptRunResult, bars: Bar[]): PlotSummary[] {\n const index = new Map(bars.map((b, i) => [b.time, i]));\n return run.plotConfig.map((p) => {\n const points = (run.result.plots[p.id] ?? []) as Array<{ time: number; value: number; color?: string }>;\n const byTime = new Map(points.map((pt) => [pt.time, pt.value]));\n let min = Infinity;\n let max = -Infinity;\n const colours = new Set<string>();\n for (const pt of points) {\n if (pt.value < min) min = pt.value;\n if (pt.value > max) max = pt.value;\n if (pt.color !== undefined) colours.add(String(pt.color));\n }\n return {\n id: p.id,\n title: p.title ?? p.id,\n values: points.length,\n firstBar: points.length ? (index.get(points[0]!.time) ?? -1) : -1,\n min: points.length ? min : null,\n max: points.length ? max : null,\n last: bars.slice(-5).map((b) => byTime.get(b.time) ?? null),\n colours: colours.size,\n };\n });\n}\n\nfunction summarizeSignals(run: ScriptRunResult, bars: Bar[]): SignalSummary[] {\n const n = Math.max(1, bars.length);\n return signalBars(run, bars).map((x) => ({\n kind: x.kind,\n id: x.id,\n title: x.title,\n count: x.bars.length,\n share: x.bars.length / n,\n firstBar: x.bars[0] ?? -1,\n lastBar: x.bars[x.bars.length - 1] ?? -1,\n }));\n}\n\nfunction summarizeStrategy(engine: NonNullable<ScriptRun['engine']>): NonNullable<CheckReport['strategy']> {\n const trades = engine.closed;\n const first = trades.slice(0, 3).map(\n (t): TradeSummary => ({\n entry: t.entry_id,\n direction: t.size >= 0 ? 'long' : 'short',\n entryBar: t.entry_bar_index,\n entryPrice: t.entry_price,\n exitBar: t.exit_bar_index ?? null,\n exitPrice: t.exit_price ?? null,\n profit: t.profit,\n })\n );\n return {\n closedTrades: trades.length,\n openTrade: engine.openTradeNow !== null,\n netProfit: trades.reduce((s, t) => s + t.profit, 0),\n wins: trades.filter((t) => t.profit > 0).length,\n first,\n };\n}\n\nfunction warningsOf(report: CheckReport, bars: Bar[]): CheckWarning[] {\n const w: CheckWarning[] = [];\n const n = bars.length;\n const outputs = report.declaration?.outputs ?? [];\n const drawings = Object.values(report.drawings).reduce((a, b) => a + b, 0);\n if (!outputs.length && !drawings && !report.strategy && !report.alertCalls) {\n w.push({ code: 'no-output', message: 'The script declares no output (plot, shape, colour, drawing, alert): it shows nothing.' });\n }\n for (const p of report.plots) {\n if (p.values === 0) {\n w.push({\n code: 'empty-plot',\n target: p.title,\n message: `Plot \"${p.title}\" has no value on any bar (na everywhere): a ta.* Series returned from a bar loop, a division by zero, a NaN input or a length longer than the bars?`,\n });\n continue;\n }\n if (p.values > 1 && p.min === p.max) {\n w.push({ code: 'constant-plot', target: p.title, message: `Plot \"${p.title}\" has the same value (${p.min}) on every bar: check that it is meant (a level is an hline()).` });\n }\n if (n >= 20 && p.firstBar > n / 2) {\n w.push({ code: 'late-start', target: p.title, message: `Plot \"${p.title}\" starts on bar ${p.firstBar} of ${n}: a long warm-up (long lengths, or a higher timeframe).` });\n }\n if (p.colours === 1 && p.values >= 20) {\n w.push({ code: 'one-colour', target: p.title, message: `Plot \"${p.title}\" has per-bar colours but the same colour on every bar: is the colour condition ever false?` });\n }\n }\n if (n >= 20) {\n for (const s of report.signals) {\n if (s.count === 0) {\n w.push({ code: 'signal-never', target: s.title, message: `${s.kind} \"${s.title}\" is never true on the ${n} bars: check the condition (or test on more bars).` });\n } else if (s.share > 0.5 && s.kind !== 'bgcolor' && s.kind !== 'barcolor') {\n w.push({\n code: 'signal-everywhere',\n target: s.title,\n message: `${s.kind} \"${s.title}\" is true on ${Math.round(s.share * 100)} % of the bars: a Series used as a JavaScript boolean (always true), or a condition that is not a cross?`,\n });\n }\n }\n }\n if (report.strategy && report.strategy.closedTrades === 0 && !report.strategy.openTrade) {\n w.push({ code: 'no-trades', message: `The strategy makes no trade on the ${n} bars: check the entry conditions (plot them with plotshape) and where the orders are placed.` });\n }\n return w;\n}\n\nfunction checkSpec(spec: CheckSpec, report: CheckReport, run: ScriptRunResult | undefined): NonNullable<CheckReport['spec']> {\n const items: NonNullable<CheckReport['spec']>['items'] = [];\n const item = (check: string, ok: boolean, expected?: unknown, actual?: unknown) => items.push({ check, ok, expected, actual });\n const d = report.declaration;\n if (spec.kind !== undefined) item('kind', d?.kind === spec.kind, spec.kind, d?.kind);\n if (spec.title !== undefined) item('title', d?.title === spec.title, spec.title, d?.title);\n if (spec.overlay !== undefined) item('overlay', d?.overlay === spec.overlay, spec.overlay, d?.overlay);\n const inputs = run?.inputConfig ?? [];\n for (const [name, want] of Object.entries(spec.inputs ?? {})) {\n const got = findByName(inputs, name);\n if (!got) {\n item(`input \"${name}\" exists`, false, name, inputs.map((i) => i.id));\n continue;\n }\n for (const key of ['type', 'defval', 'title', 'min', 'max', 'options'] as const) {\n if (want[key] === undefined) continue;\n item(`input \"${name}\" ${key}`, JSON.stringify(got[key]) === JSON.stringify(want[key]), want[key], got[key]);\n }\n }\n const all = [\n ...(d?.outputs ?? []),\n ...(run?.hlineConfig ?? []).map((h) => ({ kind: 'hline', id: h.id, title: h.title ?? h.id })),\n ...(run?.barColorConfig ?? []).map((b) => ({ kind: b.kind, id: b.id, title: b.title ?? b.id })),\n ...(run?.alertConfig ?? []).map((a) => ({ kind: 'alertcondition', id: a.id, title: a.title ?? a.id })),\n ];\n for (const o of spec.outputs ?? []) {\n const { title, kind } = typeof o === 'string' ? { title: o, kind: undefined } : o;\n const got = all.filter((x) => lower(x.title) === lower(title) || lower(x.id) === lower(title));\n const match = kind ? got.find((x) => x.kind === kind) : got[0];\n item(`output \"${title}\"${kind ? ` (${kind})` : ''} exists`, !!match, kind ? `${kind} \"${title}\"` : title, got.length ? got.map((x) => `${x.kind} \"${x.title}\"`) : all.map((x) => `${x.kind} \"${x.title}\"`));\n }\n for (const [name, want] of Object.entries(spec.plots ?? {})) {\n const p = findByName(report.plots, name);\n if (!p) {\n item(`plot \"${name}\" exists`, false, name, report.plots.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`plot \"${name}\" min`, p.min !== null && p.min >= want.min, `>= ${want.min}`, p.min);\n if (want.max !== undefined) item(`plot \"${name}\" max`, p.max !== null && p.max <= want.max, `<= ${want.max}`, p.max);\n if (want.warmup !== undefined) item(`plot \"${name}\" first value`, p.firstBar >= 0 && p.firstBar <= want.warmup, `bar <= ${want.warmup}`, p.firstBar);\n }\n for (const [name, want] of Object.entries(spec.signals ?? {})) {\n const s = findByName(report.signals, name);\n if (!s) {\n item(`signal \"${name}\" exists`, false, name, report.signals.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`signal \"${name}\" count`, s.count >= want.min, `>= ${want.min}`, s.count);\n if (want.max !== undefined) item(`signal \"${name}\" count`, s.count <= want.max, `<= ${want.max}`, s.count);\n if (want.minShare !== undefined) item(`signal \"${name}\" share`, s.share >= want.minShare, `>= ${want.minShare}`, Number(s.share.toFixed(4)));\n if (want.maxShare !== undefined) item(`signal \"${name}\" share`, s.share <= want.maxShare, `<= ${want.maxShare}`, Number(s.share.toFixed(4)));\n }\n if (spec.trades) {\n const t = report.strategy?.closedTrades;\n if (t === undefined) item('trades', false, 'a strategy', d?.kind);\n else {\n if (spec.trades.min !== undefined) item('closed trades', t >= spec.trades.min, `>= ${spec.trades.min}`, t);\n if (spec.trades.max !== undefined) item('closed trades', t <= spec.trades.max, `<= ${spec.trades.max}`, t);\n }\n }\n const failed = items.filter((i) => !i.ok).length;\n return { passed: items.length - failed, failed, items };\n}\n\nfunction checkReference(ref: CheckReference, run: ScriptRunResult, bars: Bar[]): NonNullable<CheckReport['reference']> {\n const tol = ref.tolerance ?? 1e-10;\n const index = new Map(bars.map((b, i) => [b.time, i]));\n const na = (v: number | null | undefined) => v === null || v === undefined || Number.isNaN(v);\n return Object.entries(ref.columns).map(([column, expected]) => {\n const plot = findByName(\n run.plotConfig.map((p) => ({ id: p.id, title: p.title ?? p.id })),\n column\n );\n if (!plot) return ref.ignoreUnknown ? { column, ignored: true, equal: 0, total: 0 } : { column, equal: 0, total: expected.length };\n const values = new Map(((run.result.plots[plot.id] ?? []) as Array<{ time: number; value: number }>).map((p) => [p.time, p.value]));\n let equal = 0;\n let total = 0;\n let firstMismatch: { bar: number; time: number; expected: number | null; actual: number | null } | undefined;\n ref.times.forEach((time, k) => {\n const bar = index.get(time);\n if (bar === undefined) return;\n total++;\n const e = expected[k];\n const a = values.get(time);\n const same = na(e) && na(a) ? true : na(e) || na(a) ? false : Math.abs(a! - e!) <= tol * Math.max(1, Math.abs(a!), Math.abs(e!));\n if (same) equal++;\n else firstMismatch ??= { bar, time, expected: na(e) ? null : e!, actual: na(a) ? null : a! };\n });\n return { column, output: plot.title, equal, total, ...(firstMismatch ? { firstMismatch } : {}) };\n });\n}\n\n// \u2500\u2500 checkScript \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Default number of synthetic bars of a check. */\nexport const CHECK_BARS = 1500;\n\nconst HOUR = 3600;\n\n/** The edge-case bars of `scenarios: true`. */\nexport const SCENARIOS: readonly CheckScenario[] = [\n { name: 'short', description: '30 hourly bars (a short history)', timeframe: '60', bars: () => syntheticBars(30) },\n { name: 'daily', description: '800 daily bars', timeframe: 'D', bars: () => syntheticBars(800, 86400) },\n { name: 'minute', description: '1,000 one-minute bars', timeframe: '1', bars: () => syntheticBars(1000, 60) },\n {\n name: 'flat',\n description: '200 bars with the same price and no volume (zero ranges)',\n timeframe: '60',\n bars: () => syntheticBars(200).map((b) => ({ ...b, open: 100, high: 100, low: 100, close: 100, volume: 0 })),\n },\n {\n name: 'no-volume',\n description: '500 bars without volume (na)',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b) => ({ ...b, volume: NaN })),\n },\n {\n name: 'gap',\n description: '500 hourly bars with a 3-day gap in the middle',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b, i) => (i >= 250 ? { ...b, time: b.time + 72 * HOUR } : b)),\n },\n];\n\n/**\n * Checks a script source (the body of a script, as a host runs it): compiles it, runs it on zero bars (the\n * declarations) and on the bars, and reports its declarations, outputs, warnings and the spec / reference results.\n * Never throws for a script error: the errors are in the report.\n */\nexport function checkScript(source: string, options: CheckOptions = {}): CheckReport {\n const timeframe = options.timeframe ?? (options.bars ? inferTimeframe(options.bars) : '60');\n const step = timeframeSeconds(timeframe) || 3600;\n const bars = options.bars ?? syntheticBars(CHECK_BARS, step);\n const inputs = options.inputs ?? {};\n const wrap = options.run ?? (<T>(fn: () => T) => fn());\n const runOptions = { ...options, timeframe };\n const report: CheckReport = {\n ok: false,\n bars: { count: bars.length, first: bars[0]?.time ?? null, last: bars[bars.length - 1]?.time ?? null, timeframe, synthetic: !options.bars },\n errors: [],\n warnings: [],\n plots: [],\n signals: [],\n drawings: { labels: 0, lines: 0, boxes: 0, tables: 0, polylines: 0, linefills: 0 },\n alertCalls: 0,\n };\n const fail = (stage: CheckStage, error: unknown) =>\n report.errors.push({ stage: isTimeout(error) ? 'timeout' : stage, message: messageOf(error), ...errorLocation(error, options.filename) });\n // a misspelt key would be skipped and the check would pass without checking it\n if (options.spec) for (const message of validateSpec(options.spec)) report.errors.push({ stage: 'spec', message });\n\n // compile once to report syntax errors apart from the run errors\n try {\n (options.compile ?? compileScript)(source);\n } catch (e) {\n fail('syntax', e);\n return finish();\n }\n\n let main: ScriptRun | undefined;\n try {\n const decl = wrap(() => runScript(source, [], inputs, runOptions)).run;\n report.declaration = {\n kind: decl.strategyConfig ? 'strategy' : 'indicator',\n title: decl.metadata.title,\n ...(decl.metadata.shortTitle ? { shortTitle: decl.metadata.shortTitle } : {}),\n overlay: decl.metadata.overlay,\n inputs: decl.inputConfig.map(({ id, type, defval, title, min, max, options: opts }) => ({\n id,\n type,\n defval,\n ...(title !== undefined ? { title } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n ...(opts !== undefined ? { options: opts } : {}),\n })),\n outputs: decl.outputs.map((o) => ({ kind: o.kind, id: o.id, title: o.title ?? o.id })),\n ...(decl.strategyConfig ? { strategy: { ...decl.strategyConfig } } : {}),\n };\n } catch (e) {\n fail('declaration', e);\n return finish();\n }\n\n try {\n main = wrap(() => runScript(source, bars, inputs, runOptions));\n } catch (e) {\n fail('run', e);\n return finish();\n }\n\n const run = main.run;\n const r = run.result;\n report.plots = summarizePlots(run, bars);\n report.signals = summarizeSignals(run, bars);\n report.drawings = {\n labels: r.labels?.length ?? 0,\n lines: r.lines?.length ?? 0,\n boxes: r.boxes?.length ?? 0,\n tables: r.tables?.length ?? 0,\n polylines: r.polylines?.length ?? 0,\n linefills: r.linefills?.length ?? 0,\n };\n report.alertCalls = (r as { alertCalls?: unknown[] }).alertCalls?.length ?? 0;\n if (main.engine) report.strategy = summarizeStrategy(main.engine);\n report.warnings = warningsOf(report, bars);\n // a live chart (createScriptRun) calculates only the newest bars of a script whose state the runtime keeps (#196)\n if (!main.engine) {\n try {\n const reason = wrap(() => incrementalReason(source, bars, inputs, runOptions));\n report.liveUpdates = { resumed: reason === null, reason };\n } catch {\n // the main run already reports the errors of the script\n }\n }\n\n if (options.inputSweep !== false) {\n const base = fingerprint(run, main.engine);\n for (const input of run.inputConfig) {\n const value = alternative(input);\n if (value === undefined) continue;\n try {\n const other = wrap(() => runScript(source, bars, { ...inputs, [input.id]: value }, runOptions));\n if (fingerprint(other.run, other.engine) === base) {\n report.warnings.push({\n code: 'unused-input',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" changes no output (tried ${JSON.stringify(value)} instead of ${JSON.stringify(input.defval)}): is its value used?`,\n });\n }\n } catch (e) {\n report.warnings.push({\n code: 'input-error',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" = ${JSON.stringify(value)} stops the script: ${messageOf(e)}`,\n });\n }\n }\n }\n\n if (options.spec) report.spec = checkSpec(options.spec, report, run);\n if (options.checks) {\n const trades = main.engine?.closed ?? [];\n const items = wrapChecks(() => runChecks(options.checks!, run, bars, inputs, trades));\n const spec = (report.spec ??= { passed: 0, failed: 0, items: [] });\n spec.items.push(...items);\n spec.failed = spec.items.filter((i) => !i.ok).length;\n spec.passed = spec.items.length - spec.failed;\n }\n if (options.reference) report.reference = checkReference(options.reference, run, bars);\n if (options.scenarios) runScenarios(options.scenarios === true ? SCENARIOS : options.scenarios);\n return finish();\n\n function wrapChecks(fn: () => CheckItem[]): CheckItem[] {\n try {\n return wrap(fn);\n } catch (e) {\n return [{ check: 'checks (stopped)', ok: false, actual: messageOf(e) }];\n }\n }\n\n function runScenarios(list: readonly CheckScenario[]): void {\n const known = new Set(report.warnings.map((w) => `${w.code}:${w.target ?? ''}`));\n report.scenarios = list.map((sc) => {\n const b = sc.bars();\n const r = checkScript(source, {\n ...options,\n bars: b,\n timeframe: sc.timeframe,\n spec: undefined,\n reference: undefined,\n checks: undefined,\n scenarios: false,\n inputSweep: false,\n });\n for (const e of r.errors) report.errors.push({ ...e, stage: 'scenario', message: `[${sc.name}: ${sc.description}] ${e.message}` });\n return {\n name: sc.name,\n description: sc.description,\n bars: b.length,\n errors: r.errors,\n // only the na that leaks through (a division by a zero range...): other warnings follow from the bars\n warnings: r.warnings.filter((w) => w.code === 'empty-plot' && !known.has(`${w.code}:${w.target ?? ''}`)),\n };\n });\n }\n\n function finish(): CheckReport {\n if (options.spec && !report.spec) report.spec = checkSpec(options.spec, report, main?.run);\n report.ok =\n report.errors.length === 0 &&\n (report.spec?.failed ?? 0) === 0 &&\n (report.reference ?? []).every((c) => c.ignored || (c.equal === c.total && c.output !== undefined));\n return report;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,qBASO;AACP,oBAAyE;AACzE,kBAA6B;AAE7B,IAAAA,eAA4E;AAC5E,IAAAC,iBAA4H;AAC5H,oBAA0C;AAE1C,IAAAC,kBAkBO;AA8MP,MAAM,QAAQ,CAAC,OAAmC,KAAK,IAAI,KAAK,EAAE,YAAY;AAGvE,SAAS,cAAc,OAAgB,UAAuD;AACnG,QAAM,IAAI;AACV,MAAI,KAAK,OAAO,EAAE,eAAe,SAAU,QAAO,EAAE,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa;AAC/F,MAAI,CAAC,YAAY,OAAO,GAAG,UAAU,SAAU,QAAO,CAAC;AACvD,QAAM,OAAO,SAAS,QAAQ,uBAAuB,MAAM;AAC3D,QAAM,IAAI,IAAI,OAAO,GAAG,IAAI,qBAAqB,EAAE,KAAK,EAAE,KAAK;AAC/D,SAAO,IAAI,EAAE,MAAM,OAAO,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,IAAI,OAAU,IAAI,CAAC;AAChF;AAEA,SAAS,UAAU,OAAwB;AAEzC,QAAM,IAAI;AACV,MAAI,KAAK,OAAO,MAAM,YAAY,OAAO,EAAE,YAAY,UAAU;AAC/D,WAAO,GAAG,CAAC,EAAE,QA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AAQ,MAAM,QAAQ,MAAM,GAAG;AACzF,WAAO,KACL,OAAO,OAAO,WAAW,MACxB,OAAO,MAAM,UAAU,OAAO,MAC9B,OAAO,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,MAAU;AACpG,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["import_spec", "import_checks", "import_harness", "r"]
7
7
  }
@@ -25,7 +25,7 @@ type Field = {
25
25
  kind: 'outputs';
26
26
  doc: string;
27
27
  };
28
- export declare const INPUT_TYPES: readonly ["int", "float", "bool", "string", "text_area", "source", "color", "timeframe", "session", "time", "symbol"];
28
+ export declare const INPUT_TYPES: readonly ["int", "float", "bool", "string", "text_area", "source", "color", "timeframe", "session", "time", "symbol", "enum", "price"];
29
29
  export declare const OUTPUT_KINDS: readonly ["plot", "shape", "char", "arrow", "candle", "bar", "hline", "bgcolor", "barcolor", "alertcondition"];
30
30
  /** The keys of a spec checked by checkScript. */
31
31
  export declare const SPEC_FIELDS: Record<string, Field>;
@@ -1 +1 @@
1
- {"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/check/spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,KAAK,KAAK,GACN;IAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC5F;IAAE,IAAI,EAAE,KAA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K,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAIrC,eAAO,MAAM,WAAW,wIAAyI,CAAC;AAClK,eAAO,MAAM,YAAY,gHAAiH,CAAC;AAE3I,iDAAiD;AACjD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CA6C7C,CAAC;AAEF,uGAAuG;AACvG,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAOlD,CAAC;AAmEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,EAAE,CAKtF;AAuCD,uEAAuE;AACvE,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOxD"}
@@ -27,7 +27,7 @@ __export(spec_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(spec_exports);
29
29
  const num = (doc) => ({ kind: "number", doc });
30
- const INPUT_TYPES = ["int", "float", "bool", "string", "text_area", "source", "color", "timeframe", "session", "time", "symbol"];
30
+ const INPUT_TYPES = ["int", "float", "bool", "string", "text_area", "source", "color", "timeframe", "session", "time", "symbol", "enum", "price"];
31
31
  const OUTPUT_KINDS = ["plot", "shape", "char", "arrow", "candle", "bar", "hline", "bgcolor", "barcolor", "alertcondition"];
32
32
  const SPEC_FIELDS = {
33
33
  kind: { kind: "enum", values: ["indicator", "strategy"], doc: "indicator() or strategy()" },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/check/spec.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview The spec of a check (what the user asked for), described once: {@link validateSpec} rejects unknown\n * keys and wrong values (a misspelt key would otherwise be skipped and the check would pass without checking it), and\n * {@link specJsonSchema} gives the JSON Schema of a spec file (`skills/oakscript/spec.schema.json`).\n *\n * @module check/spec\n */\n\ntype Field =\n | { kind: 'string' | 'number' | 'boolean' | 'any' | 'string[]'; doc: string }\n | { kind: 'enum'; values: readonly string[]; doc: string }\n | { kind: 'object'; fields: Record<string, Field>; doc: string; required?: readonly string[] }\n | { kind: 'map'; of: Field; doc: string }\n | { kind: 'outputs'; doc: string };\n\nconst num = (doc: string): Field => ({ kind: 'number', doc });\n\nexport const INPUT_TYPES = ['int', 'float', 'bool', 'string', 'text_area', 'source', 'color', 'timeframe', 'session', 'time', 'symbol'] as const;\nexport const OUTPUT_KINDS = ['plot', 'shape', 'char', 'arrow', 'candle', 'bar', 'hline', 'bgcolor', 'barcolor', 'alertcondition'] as const;\n\n/** The keys of a spec checked by checkScript. */\nexport const SPEC_FIELDS: Record<string, Field> = {\n kind: { kind: 'enum', values: ['indicator', 'strategy'], doc: 'indicator() or strategy()' },\n title: { kind: 'string', doc: 'the title of the declaration' },\n overlay: { kind: 'boolean', doc: 'true: price pane, false: own pane' },\n inputs: {\n kind: 'map',\n doc: 'inputs that must exist, by id or title',\n of: {\n kind: 'object',\n doc: 'the expected input',\n fields: {\n type: { kind: 'enum', values: INPUT_TYPES, doc: 'input type' },\n defval: { kind: 'any', doc: 'default value' },\n title: { kind: 'string', doc: 'title' },\n min: num('minval'),\n max: num('maxval'),\n options: { kind: 'string[]', doc: 'the choices of a string input' },\n },\n },\n },\n outputs: { kind: 'outputs', doc: 'outputs that must exist: a title, or { title, kind }' },\n plots: {\n kind: 'map',\n doc: 'value checks per plot, by id or title',\n of: {\n kind: 'object',\n doc: 'the expected values',\n fields: { min: num('every value is at least this'), max: num('every value is at most this'), warmup: num('the first value comes at this bar index or before') },\n },\n },\n signals: {\n kind: 'map',\n doc: 'count checks per signal (shape, char, arrow, alertcondition, bgcolor, barcolor), by id or title',\n of: {\n kind: 'object',\n doc: 'the expected count',\n fields: {\n min: num('at least this many bars'),\n max: num('at most this many bars'),\n minShare: num('at least this share of the bars (0 to 1)'),\n maxShare: num('at most this share of the bars (0 to 1)'),\n },\n },\n },\n trades: { kind: 'object', doc: 'closed trades of a strategy', fields: { min: num('at least'), max: num('at most') } },\n};\n\n/** The keys of a spec file read by the `oakscript check` command (paths relative to the spec file). */\nexport const SPEC_FILE_FIELDS: Record<string, Field> = {\n $schema: { kind: 'string', doc: 'the JSON Schema of the spec (oakscriptjs/skills/oakscript/spec.schema.json)' },\n reference: { kind: 'string', doc: 'CSV of expected values per bar (a time column, one column per plot)' },\n export: { kind: 'string', doc: 'chart export CSV: the bars (time, open, high, low, close, volume) and the expected plot values' },\n tolerance: num('relative tolerance of the reference values (default 1e-10)'),\n checks: { kind: 'string', doc: 'JavaScript file of behaviour checks (the body of a function of `t`)' },\n scenarios: { kind: 'boolean', doc: 'also run on the built-in edge-case bars' },\n};\n\nfunction closest(name: string, names: string[]): string | undefined {\n const dist = (a: string, b: string): number => {\n const row = Array.from({ length: b.length + 1 }, (_, j) => j);\n for (let i = 1; i <= a.length; i++) {\n let diag = row[0]!;\n row[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const up = row[j]!;\n row[j] = Math.min(up + 1, row[j - 1]! + 1, diag + (a[i - 1] === b[j - 1] ? 0 : 1));\n diag = up;\n }\n }\n return row[b.length]!;\n };\n const n = name.toLowerCase();\n const best = names.map((k) => ({ k, d: dist(n, k.toLowerCase()) })).sort((a, b) => a.d - b.d)[0];\n if (!best) return undefined;\n return best.d <= Math.max(2, Math.floor(name.length / 2)) || best.k.toLowerCase().startsWith(n.slice(0, 3)) ? best.k : undefined;\n}\n\nfunction check(value: unknown, field: Field, path: string, errors: string[]): void {\n const fail = (what: string): void => {\n errors.push(`${path}: ${what}`);\n };\n switch (field.kind) {\n case 'any':\n return;\n case 'string':\n case 'number':\n case 'boolean':\n if (typeof value !== field.kind || (field.kind === 'number' && !Number.isFinite(value))) fail(`expected a ${field.kind}, got ${JSON.stringify(value)}`);\n return;\n case 'string[]':\n if (!Array.isArray(value) || value.some((v) => typeof v !== 'string')) fail(`expected an array of strings, got ${JSON.stringify(value)}`);\n return;\n case 'enum':\n if (typeof value !== 'string' || !field.values.includes(value)) fail(`expected one of ${field.values.join(', ')}, got ${JSON.stringify(value)}`);\n return;\n case 'outputs':\n if (!Array.isArray(value)) return fail('expected an array of titles or { title, kind }');\n value.forEach((o, k) => {\n if (typeof o === 'string') return;\n check(o, { kind: 'object', doc: '', required: ['title'], fields: { title: { kind: 'string', doc: '' }, kind: { kind: 'enum', values: OUTPUT_KINDS, doc: '' } } }, `${path}[${k}]`, errors);\n });\n return;\n case 'map':\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return fail('expected an object (name -> checks)');\n for (const [k, v] of Object.entries(value)) check(v, field.of, `${path}.${k}`, errors);\n return;\n case 'object': {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return fail('expected an object');\n const keys = Object.keys(field.fields);\n for (const [k, v] of Object.entries(value)) {\n const f = field.fields[k];\n if (!f) {\n const near = closest(k, keys);\n fail(`unknown key \"${k}\"${near ? ` (did you mean \"${near}\"?)` : ''}; the keys are ${keys.join(', ')}`);\n } else check(v, f, `${path}.${k}`, errors);\n }\n for (const r of field.required ?? []) if (!(r in (value as object))) fail(`\"${r}\" is required`);\n return;\n }\n }\n}\n\n/**\n * The problems of a spec: unknown keys (with the closest key) and wrong values, one message per problem; empty when the\n * spec is valid. `file`: also accept the keys of a spec file (reference, export, tolerance, checks, scenarios).\n */\nexport function validateSpec(spec: unknown, options: { file?: boolean } = {}): string[] {\n const errors: string[] = [];\n const fields = options.file ? { ...SPEC_FIELDS, ...SPEC_FILE_FIELDS } : SPEC_FIELDS;\n check(spec, { kind: 'object', doc: '', fields }, 'spec', errors);\n return errors;\n}\n\nfunction schemaOf(field: Field): Record<string, unknown> {\n const description = field.doc ? { description: field.doc } : {};\n switch (field.kind) {\n case 'any':\n return { ...description };\n case 'string':\n case 'number':\n case 'boolean':\n return { type: field.kind, ...description };\n case 'string[]':\n return { type: 'array', items: { type: 'string' }, ...description };\n case 'enum':\n return { enum: [...field.values], ...description };\n case 'outputs':\n return {\n type: 'array',\n ...description,\n items: {\n oneOf: [\n { type: 'string' },\n { type: 'object', additionalProperties: false, required: ['title'], properties: { title: { type: 'string' }, kind: { enum: [...OUTPUT_KINDS] } } },\n ],\n },\n };\n case 'map':\n return { type: 'object', ...description, additionalProperties: schemaOf(field.of) };\n case 'object':\n return {\n type: 'object',\n ...description,\n additionalProperties: false,\n ...(field.required ? { required: [...field.required] } : {}),\n properties: Object.fromEntries(Object.entries(field.fields).map(([k, f]) => [k, schemaOf(f)])),\n };\n }\n}\n\n/** JSON Schema (draft 2020-12) of a spec file of `oakscript check`. */\nexport function specJsonSchema(): Record<string, unknown> {\n return {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'oakscript check spec',\n description: 'What the user asked for, checked by `oakscript check --spec`: every given entry is checked, an unknown key is an error.',\n ...schemaOf({ kind: 'object', doc: '', fields: { ...SPEC_FIELDS, ...SPEC_FILE_FIELDS } }),\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,MAAM,MAAM,CAAC,SAAwB,EAAE,MAAM,UAAU,IAAI;AAEpD,MAAM,cAAc,CAAC,OAAO,SAAS,QAAQ,UAAU,aAAa,UAAU,SAAS,aAAa,WAAW,QAAQ,QAAQ;AAC/H,MAAM,eAAe,CAAC,QAAQ,SAAS,QAAQ,SAAS,UAAU,OAAO,SAAS,WAAW,YAAY,gBAAgB;AAGzH,MAAM,cAAqC;AAAA,EAChD,MAAM,EAAE,MAAM,QAAQ,QAAQ,CAAC,aAAa,UAAU,GAAG,KAAK,4BAA4B;AAAA,EAC1F,OAAO,EAAE,MAAM,UAAU,KAAK,+BAA+B;AAAA,EAC7D,SAAS,EAAE,MAAM,WAAW,KAAK,oCAAoC;AAAA,EACrE,QAAQ;AAAA,IACN,MAAM;AAAA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AA,IACpE,KAAK;AACH,aAAO,EAAE,MAAM,CAAC,GAAG,MAAM,MAAM,GAAG,GAAG,YAAY;AAAA,IACnD,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,GAAG;AAAA,QACH,OAAO;AAAA,UACL,OAAO;AAAA,YACL,EAAE,MAAM,SAAS;AAAA,YACjB,EAAE,MAAM,UAAU,sBAAsB,OAAO,UAAU,CAAC,OAAO,GAAG,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,EAAE,EAAE,EAAE;AAAA,UACnJ;AAAA,QACF;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO,EAAE,MAAM,UAAU,GAAG,aAAa,sBAAsB,SAAS,MAAM,EAAE,EAAE;AAAA,IACpF,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,GAAG;AAAA,QACH,sBAAsB;AAAA,QACtB,GAAI,MAAM,WAAW,EAAE,UAAU,CAAC,GAAG,MAAM,QAAQ,EAAE,IAAI,CAAC;AAAA,QAC1D,YAAY,OAAO,YAAY,OAAO,QAAQ,MAAM,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAAA,MAC/F;AAAA,EACJ;AACF;AAGO,SAAS,iBAA0C;AACxD,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO;AAAA,IACP,aAAa;AAAA,IACb,GAAG,SAAS,EAAE,MAAM,UAAU,KAAK,IAAI,QAAQ,EAAE,GAAG,aAAa,GAAG,iBAAiB,EAAE,CAAC;AAAA,EAC1F;AACF;",
4
+ "sourcesContent": ["/**\n * @fileoverview The spec of a check (what the user asked for), described once: {@link validateSpec} rejects unknown\n * keys and wrong values (a misspelt key would otherwise be skipped and the check would pass without checking it), and\n * {@link specJsonSchema} gives the JSON Schema of a spec file (`skills/oakscript/spec.schema.json`).\n *\n * @module check/spec\n */\n\ntype Field =\n | { kind: 'string' | 'number' | 'boolean' | 'any' | 'string[]'; doc: string }\n | { kind: 'enum'; values: readonly string[]; doc: string }\n | { kind: 'object'; fields: Record<string, Field>; doc: string; required?: readonly string[] }\n | { kind: 'map'; of: Field; doc: string }\n | { kind: 'outputs'; doc: string };\n\nconst num = (doc: string): Field => ({ kind: 'number', doc });\n\nexport const INPUT_TYPES = ['int', 'float', 'bool', 'string', 'text_area', 'source', 'color', 'timeframe', 'session', 'time', 'symbol', 'enum', 'price'] as const;\nexport const OUTPUT_KINDS = ['plot', 'shape', 'char', 'arrow', 'candle', 'bar', 'hline', 'bgcolor', 'barcolor', 'alertcondition'] as const;\n\n/** The keys of a spec checked by checkScript. */\nexport const SPEC_FIELDS: Record<string, Field> = {\n kind: { kind: 'enum', values: ['indicator', 'strategy'], doc: 'indicator() or strategy()' },\n title: { kind: 'string', doc: 'the title of the declaration' },\n overlay: { kind: 'boolean', doc: 'true: price pane, false: own pane' },\n inputs: {\n kind: 'map',\n doc: 'inputs that must exist, by id or title',\n of: {\n kind: 'object',\n doc: 'the expected input',\n fields: {\n type: { kind: 'enum', values: INPUT_TYPES, doc: 'input type' },\n defval: { kind: 'any', doc: 'default value' },\n title: { kind: 'string', doc: 'title' },\n min: num('minval'),\n max: num('maxval'),\n options: { kind: 'string[]', doc: 'the choices of a string input' },\n },\n },\n },\n outputs: { kind: 'outputs', doc: 'outputs that must exist: a title, or { title, kind }' },\n plots: {\n kind: 'map',\n doc: 'value checks per plot, by id or title',\n of: {\n kind: 'object',\n doc: 'the expected values',\n fields: { min: num('every value is at least this'), max: num('every value is at most this'), warmup: num('the first value comes at this bar index or before') },\n },\n },\n signals: {\n kind: 'map',\n doc: 'count checks per signal (shape, char, arrow, alertcondition, bgcolor, barcolor), by id or title',\n of: {\n kind: 'object',\n doc: 'the expected count',\n fields: {\n min: num('at least this many bars'),\n max: num('at most this many bars'),\n minShare: num('at least this share of the bars (0 to 1)'),\n maxShare: num('at most this share of the bars (0 to 1)'),\n },\n },\n },\n trades: { kind: 'object', doc: 'closed trades of a strategy', fields: { min: num('at least'), max: num('at most') } },\n};\n\n/** The keys of a spec file read by the `oakscript check` command (paths relative to the spec file). */\nexport const SPEC_FILE_FIELDS: Record<string, Field> = {\n $schema: { kind: 'string', doc: 'the JSON Schema of the spec (oakscriptjs/skills/oakscript/spec.schema.json)' },\n reference: { kind: 'string', doc: 'CSV of expected values per bar (a time column, one column per plot)' },\n export: { kind: 'string', doc: 'chart export CSV: the bars (time, open, high, low, close, volume) and the expected plot values' },\n tolerance: num('relative tolerance of the reference values (default 1e-10)'),\n checks: { kind: 'string', doc: 'JavaScript file of behaviour checks (the body of a function of `t`)' },\n scenarios: { kind: 'boolean', doc: 'also run on the built-in edge-case bars' },\n};\n\nfunction closest(name: string, names: string[]): string | undefined {\n const dist = (a: string, b: string): number => {\n const row = Array.from({ length: b.length + 1 }, (_, j) => j);\n for (let i = 1; i <= a.length; i++) {\n let diag = row[0]!;\n row[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const up = row[j]!;\n row[j] = Math.min(up + 1, row[j - 1]! + 1, diag + (a[i - 1] === b[j - 1] ? 0 : 1));\n diag = up;\n }\n }\n return row[b.length]!;\n };\n const n = name.toLowerCase();\n const best = names.map((k) => ({ k, d: dist(n, k.toLowerCase()) })).sort((a, b) => a.d - b.d)[0];\n if (!best) return undefined;\n return best.d <= Math.max(2, Math.floor(name.length / 2)) || best.k.toLowerCase().startsWith(n.slice(0, 3)) ? best.k : undefined;\n}\n\nfunction check(value: unknown, field: Field, path: string, errors: string[]): void {\n const fail = (what: string): void => {\n errors.push(`${path}: ${what}`);\n };\n switch (field.kind) {\n case 'any':\n return;\n case 'string':\n case 'number':\n case 'boolean':\n if (typeof value !== field.kind || (field.kind === 'number' && !Number.isFinite(value))) fail(`expected a ${field.kind}, got ${JSON.stringify(value)}`);\n return;\n case 'string[]':\n if (!Array.isArray(value) || value.some((v) => typeof v !== 'string')) fail(`expected an array of strings, got ${JSON.stringify(value)}`);\n return;\n case 'enum':\n if (typeof value !== 'string' || !field.values.includes(value)) fail(`expected one of ${field.values.join(', ')}, got ${JSON.stringify(value)}`);\n return;\n case 'outputs':\n if (!Array.isArray(value)) return fail('expected an array of titles or { title, kind }');\n value.forEach((o, k) => {\n if (typeof o === 'string') return;\n check(o, { kind: 'object', doc: '', required: ['title'], fields: { title: { kind: 'string', doc: '' }, kind: { kind: 'enum', values: OUTPUT_KINDS, doc: '' } } }, `${path}[${k}]`, errors);\n });\n return;\n case 'map':\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return fail('expected an object (name -> checks)');\n for (const [k, v] of Object.entries(value)) check(v, field.of, `${path}.${k}`, errors);\n return;\n case 'object': {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return fail('expected an object');\n const keys = Object.keys(field.fields);\n for (const [k, v] of Object.entries(value)) {\n const f = field.fields[k];\n if (!f) {\n const near = closest(k, keys);\n fail(`unknown key \"${k}\"${near ? ` (did you mean \"${near}\"?)` : ''}; the keys are ${keys.join(', ')}`);\n } else check(v, f, `${path}.${k}`, errors);\n }\n for (const r of field.required ?? []) if (!(r in (value as object))) fail(`\"${r}\" is required`);\n return;\n }\n }\n}\n\n/**\n * The problems of a spec: unknown keys (with the closest key) and wrong values, one message per problem; empty when the\n * spec is valid. `file`: also accept the keys of a spec file (reference, export, tolerance, checks, scenarios).\n */\nexport function validateSpec(spec: unknown, options: { file?: boolean } = {}): string[] {\n const errors: string[] = [];\n const fields = options.file ? { ...SPEC_FIELDS, ...SPEC_FILE_FIELDS } : SPEC_FIELDS;\n check(spec, { kind: 'object', doc: '', fields }, 'spec', errors);\n return errors;\n}\n\nfunction schemaOf(field: Field): Record<string, unknown> {\n const description = field.doc ? { description: field.doc } : {};\n switch (field.kind) {\n case 'any':\n return { ...description };\n case 'string':\n case 'number':\n case 'boolean':\n return { type: field.kind, ...description };\n case 'string[]':\n return { type: 'array', items: { type: 'string' }, ...description };\n case 'enum':\n return { enum: [...field.values], ...description };\n case 'outputs':\n return {\n type: 'array',\n ...description,\n items: {\n oneOf: [\n { type: 'string' },\n { type: 'object', additionalProperties: false, required: ['title'], properties: { title: { type: 'string' }, kind: { enum: [...OUTPUT_KINDS] } } },\n ],\n },\n };\n case 'map':\n return { type: 'object', ...description, additionalProperties: schemaOf(field.of) };\n case 'object':\n return {\n type: 'object',\n ...description,\n additionalProperties: false,\n ...(field.required ? { required: [...field.required] } : {}),\n properties: Object.fromEntries(Object.entries(field.fields).map(([k, f]) => [k, schemaOf(f)])),\n };\n }\n}\n\n/** JSON Schema (draft 2020-12) of a spec file of `oakscript check`. */\nexport function specJsonSchema(): Record<string, unknown> {\n return {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'oakscript check spec',\n description: 'What the user asked for, checked by `oakscript check --spec`: every given entry is checked, an unknown key is an error.',\n ...schemaOf({ kind: 'object', doc: '', fields: { ...SPEC_FIELDS, ...SPEC_FILE_FIELDS } }),\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,MAAM,MAAM,CAAC,SAAwB,EAAE,MAAM,UAAU,IAAI;AAEpD,MAAM,cAAc,CAAC,OAAO,SAAS,QAAQ,UAAU,aAAa,UAAU,SAAS,aAAa,WAAW,QAAQ,UAAU,QAAQ,OAAO;AAChJ,MAAM,eAAe,CAAC,QAAQ,SAAS,QAAQ,SAAS,UAAU,OAAO,SAAS,WAAW,YAAY,gBAAgB;AAGzH,MAAM,cAAqC;AAAA,EAChD,MAAM,EAAE,MAAM,QAAQ,QAAQ,CAAC,aAAa,UAAU,GAAG,KAAK,4BAA4B;AAAA,EAC1F,OAAO,EAAE,MAAM,UAAU,KAAK,+BAA+B;AAAA,EAC7D,SAAS,EAAE,MAAM,WAAW,KAAK,oCAAoC;AAAA,EACrE,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,KAAK;AAAA,IACL,IAAI;AAA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MAAM,CAAC,GAAG,MAAM,MAAM,GAAG,GAAG,YAAY;AAAA,IACnD,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,GAAG;AAAA,QACH,OAAO;AAAA,UACL,OAAO;AAAA,YACL,EAAE,MAAM,SAAS;AAAA,YACjB,EAAE,MAAM,UAAU,sBAAsB,OAAO,UAAU,CAAC,OAAO,GAAG,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,GAAG,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,EAAE,EAAE,EAAE;AAAA,UACnJ;AAAA,QACF;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO,EAAE,MAAM,UAAU,GAAG,aAAa,sBAAsB,SAAS,MAAM,EAAE,EAAE;AAAA,IACpF,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,GAAG;AAAA,QACH,sBAAsB;AAAA,QACtB,GAAI,MAAM,WAAW,EAAE,UAAU,CAAC,GAAG,MAAM,QAAQ,EAAE,IAAI,CAAC;AAAA,QAC1D,YAAY,OAAO,YAAY,OAAO,QAAQ,MAAM,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAAA,MAC/F;AAAA,EACJ;AACF;AAGO,SAAS,iBAA0C;AACxD,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO;AAAA,IACP,aAAa;AAAA,IACb,GAAG,SAAS,EAAE,MAAM,UAAU,KAAK,IAAI,QAAQ,EAAE,GAAG,aAAa,GAAG,iBAAiB,EAAE,CAAC;AAAA,EAC1F;AACF;",
6
6
  "names": []
7
7
  }
@@ -66,7 +66,7 @@ export type * from './strategy/index.js';
66
66
  export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
67
67
  export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
68
68
  export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
69
- export declare const VERSION = "0.20.0";
69
+ export declare const VERSION = "0.23.0";
70
70
  /**
71
71
  * Library information
72
72
  */
package/dist/cjs/index.js CHANGED
@@ -213,7 +213,7 @@ var import_input_active = require("./runtime/input-active.js");
213
213
  var import_strategy = require("./strategy/index.js");
214
214
  var import_LightweightChartsAdapter = require("./runtime/adapters/LightweightChartsAdapter.js");
215
215
  var import_SimpleInputAdapter = require("./runtime/adapters/SimpleInputAdapter.js");
216
- const VERSION = "0.20.0";
216
+ const VERSION = "0.23.0";
217
217
  const info = {
218
218
  name: "OakScriptJS",
219
219
  version: VERSION,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// ta.* one bar at a time (step / commit), for incremental calculations (#196)\nexport { taStep, type BarStep } from './ta/step.js';\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count)),\n// and the drawing checkpoint of a port with its own bar loop (live updates of the forming bar, #203)\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n createdDrawingKinds,\n saveDrawingCheckpoint,\n restoreDrawingCheckpoint,\n type DrawingCheckpoint,\n type DrawingKind,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf, session, timezone), time_close(...), time_tradingday,\n// session.* flags, request.security periods with the session and holidays, and bars after the last bar on the trading\n// calendar\nexport {\n chartSessions,\n sessionPeriods,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionPeriods,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n// request.security of another symbol: which bar of the other symbol each chart bar shows (#179)\nexport {\n securityOther,\n securityOtherValues,\n securityLowerTf,\n MAX_INTRABARS,\n type OtherSymbolChart,\n type OtherSymbolOptions,\n type SymbolCalendar,\n} from './security/other.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\nexport { setSourceResolver, externalSource, BUILTIN_SOURCES, type SourceResolver } from './utils/source-resolver.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_text_area,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n ShapeConfig,\n BarColorConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.20.0';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
4
+ "sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// ta.* one bar at a time (step / commit), for incremental calculations (#196)\nexport { taStep, type BarStep } from './ta/step.js';\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count)),\n// and the drawing checkpoint of a port with its own bar loop (live updates of the forming bar, #203)\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n createdDrawingKinds,\n saveDrawingCheckpoint,\n restoreDrawingCheckpoint,\n type DrawingCheckpoint,\n type DrawingKind,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf, session, timezone), time_close(...), time_tradingday,\n// session.* flags, request.security periods with the session and holidays, and bars after the last bar on the trading\n// calendar\nexport {\n chartSessions,\n sessionPeriods,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionPeriods,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n// request.security of another symbol: which bar of the other symbol each chart bar shows (#179)\nexport {\n securityOther,\n securityOtherValues,\n securityLowerTf,\n MAX_INTRABARS,\n type OtherSymbolChart,\n type OtherSymbolOptions,\n type SymbolCalendar,\n} from './security/other.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\nexport { setSourceResolver, externalSource, BUILTIN_SOURCES, type SourceResolver } from './utils/source-resolver.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_text_area,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n ShapeConfig,\n BarColorConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.23.0';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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gCAAmC;AAG5B,MAAM,UAAU;AAKhB,MAAM,OAAO;AAAA,EAClB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,YAAY;AAAA,IACV,MAAM,CAAC,MAAM,QAAQ,SAAS,OAAO,OAAO,SAAS,QAAQ,aAAa,QAAQ;AAAA,IAClF,SAAS,CAAC,QAAQ,OAAO,SAAS,YAAY,cAAc,YAAY,SAAS,MAAM;AAAA,IACvF,SAAS,CAAC,cAAc,QAAQ,SAAS,SAAS;AAAA,IAClD,WAAW,CAAC,aAAa,SAAS,cAAc,YAAY;AAAA,EAC9D;AACF;AAUO,SAAS,eAAe,YAAqB,QAAiB,UAAyB;AAE9F;",
6
6
  "names": ["import_utils"]
7
7
  }
@@ -57,7 +57,7 @@ class SimpleInputAdapter {
57
57
  }
58
58
  const { config } = input;
59
59
  let validatedValue = value;
60
- if ((config.type === "int" || config.type === "float") && typeof value === "number") {
60
+ if ((config.type === "int" || config.type === "float" || config.type === "price") && typeof value === "number") {
61
61
  if (config.min !== void 0 && value < config.min) {
62
62
  validatedValue = config.min;
63
63
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/runtime/adapters/SimpleInputAdapter.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Simple in-memory input adapter for demos and testing\n * Stores input values in memory and provides change notification\n * @module runtime/adapters/SimpleInputAdapter\n */\n\nimport type { InputAdapter, InputConfig } from '../types.js';\n\n/**\n * Simple in-memory input adapter\n * Stores input configurations and values in memory\n * Useful for demos, testing, and simple applications\n */\nexport class SimpleInputAdapter implements InputAdapter {\n private inputs: Map<string, { config: InputConfig; value: unknown }> = new Map();\n private changeCallbacks: Array<(id: string, value: unknown) => void> = [];\n\n /**\n * Register an input configuration\n * If already registered, returns current value without modifying config\n * @param config - Input configuration\n * @returns Current value (defval on first registration)\n */\n registerInput(config: InputConfig): unknown {\n if (!this.inputs.has(config.id)) {\n this.inputs.set(config.id, { config, value: config.defval });\n }\n return this.inputs.get(config.id)!.value;\n }\n\n /**\n * Get current value of an input\n * @param id - Input identifier\n * @returns Current value or undefined if not registered\n */\n getValue(id: string): unknown {\n return this.inputs.get(id)?.value;\n }\n\n /**\n * Set value of an input with validation\n * Validates against config constraints (min/max/step for numerics, options for strings)\n * @param id - Input identifier\n * @param value - New value\n */\n setValue(id: string, value: unknown): void {\n const input = this.inputs.get(id);\n if (!input) {\n return;\n }\n\n const { config } = input;\n let validatedValue = value;\n\n // Validate numeric inputs\n if ((config.type === 'int' || config.type === 'float') && typeof value === 'number') {\n // Apply min constraint\n if (config.min !== undefined && value < config.min) {\n validatedValue = config.min;\n }\n // Apply max constraint\n if (config.max !== undefined && value > config.max) {\n validatedValue = config.max;\n }\n // Round to step for int type\n if (config.type === 'int') {\n validatedValue = Math.floor(validatedValue as number);\n }\n }\n\n // Validate string, timeframe and session inputs with options\n if (\n (config.type === 'string' || config.type === 'timeframe' || config.type === 'session' || config.type === 'symbol') &&\n config.options &&\n typeof value === 'string'\n ) {\n if (!config.options.includes(value)) {\n // Keep current value if invalid option\n return;\n }\n }\n\n // Validate source inputs\n if (config.type === 'source' && config.options && typeof value === 'string') {\n if (!config.options.includes(value)) {\n return;\n }\n }\n\n // Update value\n input.value = validatedValue;\n\n // Notify callbacks\n this.changeCallbacks.forEach(cb => cb(id, validatedValue));\n }\n\n /**\n * Register a callback for input value changes\n * @param callback - Function to call when any input value changes\n */\n onInputChange(callback: (id: string, value: unknown) => void): void {\n this.changeCallbacks.push(callback);\n }\n\n /**\n * Get all registered inputs (for UI rendering)\n * @returns Map of input IDs to their configs and values\n */\n getAllInputs(): Map<string, { config: InputConfig; value: unknown }> {\n return new Map(this.inputs);\n }\n\n /**\n * Clear all registered inputs\n * Useful for testing or resetting state\n */\n clear(): void {\n this.inputs.clear();\n this.changeCallbacks = [];\n }\n\n /**\n * Remove a specific change callback\n * @param callback - The callback to remove\n */\n removeChangeCallback(callback: (id: string, value: unknown) => void): void {\n const index = this.changeCallbacks.indexOf(callback);\n if (index !== -1) {\n this.changeCallbacks.splice(index, 1);\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,mBAA2C;AAAA,EAC9C,SAA+D,oBAAI,IAAI;AAAA,EACvE,kBAA+D,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxE,cAAc,QAA8B;AAC1C,QAAI,CAAC,KAAK,OAAO,IAAI,OAAO,EAAE,GAAG;AAC/B,WAAK,OAAO,IAAI,OAAO,IAAI,EAAE,QAAQ,OAAO,OAAO,OAAO,CAAC;AAAA,IAC7D;AACA,WAAO,KAAK,OAAO,IAAI,OAAO,EAAE,EAAG;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,IAAqB;AAC5B,WAAO,KAAK,OAAO,IAAI,EAAE,GAAG;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,IAAY,OAAsB;AACzC,UAAM,QAAQ,KAAK,OAAO,IAAI,EAAE;AAChC,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,iBAAiB;AAGrB,SAAK,OAAO,SAAS,SAAS,OAAO,SAAS,YAAY,OAAO,UAAU,UAAU;AAEnF,UAAI,OAAO,QAAQ,UAAa,QAAQ,OAAO,KAAK;AAClD,yBAAiB,OAAO;AAAA,MAC1B;AAEA,UAAI,OAAO,QAAQ,UAAa,QAAQ,OAAO,KAAK;AAClD,yBAAiB,OAAO;AAAA,MAC1B;AAEA,UAAI,OAAO,SAAS,OAAO;AACzB,yBAAiB,KAAK,MAAM,cAAwB;AAAA,MACtD;AAAA,IACF;AAGA,SACG,OAAO,SAAS,YAAY,OAAO,SAAS,eAAe,OAAO,SAAS,aAAa,OAAO,SAAS,aACzG,OAAO,WACP,OAAO,UAAU,UACjB;AACA,UAAI,CAAC,OAAO,QAAQ,SAAS,KAAK,GAAG;AAEnC;AAAA,MACF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,YAAY,OAAO,WAAW,OAAO,UAAU,UAAU;AAC3E,UAAI,CAAC,OAAO,QAAQ,SAAS,KAAK,GAAG;AACnC;AAAA,MACF;AAAA,IACF;AAGA,UAAM,QAAQ;AAGd,SAAK,gBAAgB,QAAQ,QAAM,GAAG,IAAI,cAAc,CAAC;AAAA,EAC3D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc,UAAsD;AAClE,SAAK,gBAAgB,KAAK,QAAQ;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,eAAqE;AACnE,WAAO,IAAI,IAAI,KAAK,MAAM;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAc;AACZ,SAAK,OAAO,MAAM;AAClB,SAAK,kBAAkB,CAAC;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAqB,UAAsD;AACzE,UAAM,QAAQ,KAAK,gBAAgB,QAAQ,QAAQ;AACnD,QAAI,UAAU,IAAI;AAChB,WAAK,gBAAgB,OAAO,OAAO,CAAC;AAAA,IACtC;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * @fileoverview Simple in-memory input adapter for demos and testing\n * Stores input values in memory and provides change notification\n * @module runtime/adapters/SimpleInputAdapter\n */\n\nimport type { InputAdapter, InputConfig } from '../types.js';\n\n/**\n * Simple in-memory input adapter\n * Stores input configurations and values in memory\n * Useful for demos, testing, and simple applications\n */\nexport class SimpleInputAdapter implements InputAdapter {\n private inputs: Map<string, { config: InputConfig; value: unknown }> = new Map();\n private changeCallbacks: Array<(id: string, value: unknown) => void> = [];\n\n /**\n * Register an input configuration\n * If already registered, returns current value without modifying config\n * @param config - Input configuration\n * @returns Current value (defval on first registration)\n */\n registerInput(config: InputConfig): unknown {\n if (!this.inputs.has(config.id)) {\n this.inputs.set(config.id, { config, value: config.defval });\n }\n return this.inputs.get(config.id)!.value;\n }\n\n /**\n * Get current value of an input\n * @param id - Input identifier\n * @returns Current value or undefined if not registered\n */\n getValue(id: string): unknown {\n return this.inputs.get(id)?.value;\n }\n\n /**\n * Set value of an input with validation\n * Validates against config constraints (min/max/step for numerics, options for strings)\n * @param id - Input identifier\n * @param value - New value\n */\n setValue(id: string, value: unknown): void {\n const input = this.inputs.get(id);\n if (!input) {\n return;\n }\n\n const { config } = input;\n let validatedValue = value;\n\n // Validate numeric inputs\n if ((config.type === 'int' || config.type === 'float' || config.type === 'price') && typeof value === 'number') {\n // Apply min constraint\n if (config.min !== undefined && value < config.min) {\n validatedValue = config.min;\n }\n // Apply max constraint\n if (config.max !== undefined && value > config.max) {\n validatedValue = config.max;\n }\n // Round to step for int type\n if (config.type === 'int') {\n validatedValue = Math.floor(validatedValue as number);\n }\n }\n\n // Validate string, timeframe and session inputs with options\n if (\n (config.type === 'string' || config.type === 'timeframe' || config.type === 'session' || config.type === 'symbol') &&\n config.options &&\n typeof value === 'string'\n ) {\n if (!config.options.includes(value)) {\n // Keep current value if invalid option\n return;\n }\n }\n\n // Validate source inputs\n if (config.type === 'source' && config.options && typeof value === 'string') {\n if (!config.options.includes(value)) {\n return;\n }\n }\n\n // Update value\n input.value = validatedValue;\n\n // Notify callbacks\n this.changeCallbacks.forEach(cb => cb(id, validatedValue));\n }\n\n /**\n * Register a callback for input value changes\n * @param callback - Function to call when any input value changes\n */\n onInputChange(callback: (id: string, value: unknown) => void): void {\n this.changeCallbacks.push(callback);\n }\n\n /**\n * Get all registered inputs (for UI rendering)\n * @returns Map of input IDs to their configs and values\n */\n getAllInputs(): Map<string, { config: InputConfig; value: unknown }> {\n return new Map(this.inputs);\n }\n\n /**\n * Clear all registered inputs\n * Useful for testing or resetting state\n */\n clear(): void {\n this.inputs.clear();\n this.changeCallbacks = [];\n }\n\n /**\n * Remove a specific change callback\n * @param callback - The callback to remove\n */\n removeChangeCallback(callback: (id: string, value: unknown) => void): void {\n const index = this.changeCallbacks.indexOf(callback);\n if (index !== -1) {\n this.changeCallbacks.splice(index, 1);\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,mBAA2C;AAAA,EAC9C,SAA+D,oBAAI,IAAI;AAAA,EACvE,kBAA+D,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxE,cAAc,QAA8B;AAC1C,QAAI,CAAC,KAAK,OAAO,IAAI,OAAO,EAAE,GAAG;AAC/B,WAAK,OAAO,IAAI,OAAO,IAAI,EAAE,QAAQ,OAAO,OAAO,OAAO,CAAC;AAAA,IAC7D;AACA,WAAO,KAAK,OAAO,IAAI,OAAO,EAAE,EAAG;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,IAAqB;AAC5B,WAAO,KAAK,OAAO,IAAI,EAAE,GAAG;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,IAAY,OAAsB;AACzC,UAAM,QAAQ,KAAK,OAAO,IAAI,EAAE;AAChC,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,iBAAiB;AAGrB,SAAK,OAAO,SAAS,SAAS,OAAO,SAAS,WAAW,OAAO,SAAS,YAAY,OAAO,UAAU,UAAU;AAE9G,UAAI,OAAO,QAAQ,UAAa,QAAQ,OAAO,KAAK;AAClD,yBAAiB,OAAO;AAAA,MAC1B;AAEA,UAAI,OAAO,QAAQ,UAAa,QAAQ,OAAO,KAAK;AAClD,yBAAiB,OAAO;AAAA,MAC1B;AAEA,UAAI,OAAO,SAAS,OAAO;AACzB,yBAAiB,KAAK,MAAM,cAAwB;AAAA,MACtD;AAAA,IACF;AAGA,SACG,OAAO,SAAS,YAAY,OAAO,SAAS,eAAe,OAAO,SAAS,aAAa,OAAO,SAAS,aACzG,OAAO,WACP,OAAO,UAAU,UACjB;AACA,UAAI,CAAC,OAAO,QAAQ,SAAS,KAAK,GAAG;AAEnC;AAAA,MACF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,YAAY,OAAO,WAAW,OAAO,UAAU,UAAU;AAC3E,UAAI,CAAC,OAAO,QAAQ,SAAS,KAAK,GAAG;AACnC;AAAA,MACF;AAAA,IACF;AAGA,UAAM,QAAQ;AAGd,SAAK,gBAAgB,QAAQ,QAAM,GAAG,IAAI,cAAc,CAAC;AAAA,EAC3D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc,UAAsD;AAClE,SAAK,gBAAgB,KAAK,QAAQ;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,eAAqE;AACnE,WAAO,IAAI,IAAI,KAAK,MAAM;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAc;AACZ,SAAK,OAAO,MAAM;AAClB,SAAK,kBAAkB,CAAC;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAqB,UAAsD;AACzE,UAAM,QAAQ,KAAK,gBAAgB,QAAQ,QAAQ;AACnD,QAAI,UAAU,IAAI;AAChB,WAAK,gBAAgB,OAAO,OAAO,CAAC;AAAA,IACtC;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -74,9 +74,10 @@ export interface InputConfig {
74
74
  /**
75
75
  * Type of input. `timeframe` and `session` values are strings ("60", "1D", "0930-1600:23456";
76
76
  * an empty timeframe means the chart timeframe), `time` values are UNIX times in milliseconds. A `text_area`
77
- * value is a string that can hold several lines.
77
+ * value is a string that can hold several lines. An `enum` value is the field name of one of its `options`. A `price`
78
+ * value is a number, a price level (a host can let the user pick it on the chart).
78
79
  */
79
- type: 'int' | 'float' | 'bool' | 'string' | 'text_area' | 'source' | 'color' | 'timeframe' | 'session' | 'time' | 'symbol';
80
+ type: 'int' | 'float' | 'bool' | 'string' | 'text_area' | 'source' | 'color' | 'timeframe' | 'session' | 'time' | 'symbol' | 'enum' | 'price';
80
81
  /** Default value */
81
82
  defval: unknown;
82
83
  /** Display title */
@@ -87,8 +88,13 @@ export interface InputConfig {
87
88
  max?: number;
88
89
  /** Step size (for numeric inputs) */
89
90
  step?: number;
90
- /** Options for dropdown selection (for string, timeframe and session inputs) */
91
- options?: string[];
91
+ /**
92
+ * Options for dropdown selection: strings (string, timeframe, session and symbol inputs), numbers (int and float
93
+ * inputs) or the field names of an enum input
94
+ */
95
+ options?: (string | number)[];
96
+ /** Titles of the options of an enum input, by field name */
97
+ optionsTitles?: Record<string, string>;
92
98
  /** Settings group header (PineScript `group`) */
93
99
  group?: string;
94
100
  /** Inputs with the same `inline` id are shown on one line (PineScript `inline`) */