@jplorg/jpl 1.5.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/dist/esm/main.js +3474 -0
  2. package/dist/types/applyDefaults.d.ts +2 -0
  3. package/dist/types/builtins/funcContains.d.ts +3 -0
  4. package/dist/types/builtins/funcEndsWith.d.ts +3 -0
  5. package/dist/types/builtins/funcError.d.ts +3 -0
  6. package/dist/types/builtins/funcFromJSON.d.ts +3 -0
  7. package/dist/types/builtins/funcHas.d.ts +3 -0
  8. package/dist/types/builtins/funcIn.d.ts +3 -0
  9. package/dist/types/builtins/funcKeys.d.ts +3 -0
  10. package/dist/types/builtins/funcLength.d.ts +3 -0
  11. package/dist/types/builtins/funcNow.d.ts +3 -0
  12. package/dist/types/builtins/funcStartsWith.d.ts +3 -0
  13. package/dist/types/builtins/funcToJSON.d.ts +3 -0
  14. package/dist/types/builtins/funcToLowerCase.d.ts +3 -0
  15. package/dist/types/builtins/funcToNumber.d.ts +3 -0
  16. package/dist/types/builtins/funcToString.d.ts +3 -0
  17. package/dist/types/builtins/funcToUpperCase.d.ts +3 -0
  18. package/dist/types/builtins/funcTrim.d.ts +3 -0
  19. package/dist/types/builtins/funcTrimEnd.d.ts +3 -0
  20. package/dist/types/builtins/funcTrimStart.d.ts +3 -0
  21. package/dist/types/builtins/funcType.d.ts +3 -0
  22. package/dist/types/builtins/funcVoid.d.ts +3 -0
  23. package/dist/types/builtins/index.d.ts +2 -0
  24. package/dist/types/builtins/internals.d.ts +1 -0
  25. package/dist/types/builtins/math.d.ts +17 -0
  26. package/dist/types/createSingleton.d.ts +1 -0
  27. package/dist/types/interpreter/index.d.ts +21 -0
  28. package/dist/types/interpreter/parse.d.ts +194 -0
  29. package/{src/interpreter/parseFunction.js → dist/types/interpreter/parseFunction.d.ts} +2 -10
  30. package/dist/types/interpreter/system.d.ts +3 -0
  31. package/dist/types/interpreter/util.d.ts +89 -0
  32. package/dist/types/library/apply.d.ts +32 -0
  33. package/dist/types/library/definition.d.ts +79 -0
  34. package/dist/types/library/errors/adaptErrors.d.ts +6 -0
  35. package/dist/types/library/errors/enclosure.d.ts +6 -0
  36. package/dist/types/library/errors/error.d.ts +6 -0
  37. package/dist/types/library/errors/execution.d.ts +12 -0
  38. package/dist/types/library/errors/fatal.d.ts +4 -0
  39. package/dist/types/library/errors/runtime.d.ts +46 -0
  40. package/dist/types/library/errors/syntax.d.ts +7 -0
  41. package/{src/library/functions.js → dist/types/library/functions.d.ts} +9 -30
  42. package/dist/types/library/index.d.ts +18 -0
  43. package/dist/types/library/mux.d.ts +19 -0
  44. package/{src/library/ops/op.js → dist/types/library/ops/op.d.ts} +25 -49
  45. package/{src/library/ops/opa.js → dist/types/library/ops/opa.d.ts} +4 -7
  46. package/{src/library/ops/opc.js → dist/types/library/ops/opc.d.ts} +6 -11
  47. package/{src/library/ops/opm.js → dist/types/library/ops/opm.d.ts} +5 -9
  48. package/{src/library/ops/opu.js → dist/types/library/ops/opu.d.ts} +8 -15
  49. package/dist/types/library/runtimeScope.d.ts +23 -0
  50. package/dist/types/library/runtimeSignal.d.ts +25 -0
  51. package/dist/types/library/types.d.ts +97 -0
  52. package/dist/types/main.d.ts +19 -0
  53. package/dist/types/program/handler.d.ts +12 -0
  54. package/dist/types/program/index.d.ts +40 -0
  55. package/dist/types/program/ops/index.d.ts +5 -0
  56. package/dist/types/program/ops/opAccess/index.d.ts +11 -0
  57. package/dist/types/program/ops/opAccess/opaField.d.ts +11 -0
  58. package/dist/types/program/ops/opAccess/opaFunction.d.ts +11 -0
  59. package/dist/types/program/ops/opAccess/opaIter.d.ts +11 -0
  60. package/dist/types/program/ops/opAccess/opaSlice.d.ts +11 -0
  61. package/dist/types/program/ops/opAnd.d.ts +11 -0
  62. package/dist/types/program/ops/opArrayConstructor.d.ts +11 -0
  63. package/dist/types/program/ops/opAssignment/index.d.ts +11 -0
  64. package/dist/types/program/ops/opAssignment/opaAssignField.d.ts +11 -0
  65. package/dist/types/program/ops/opAssignment/opaAssignIter.d.ts +11 -0
  66. package/dist/types/program/ops/opAssignment/opaAssignSlice.d.ts +11 -0
  67. package/dist/types/program/ops/opAssignment/opuAddition.d.ts +11 -0
  68. package/dist/types/program/ops/opAssignment/opuDivision.d.ts +11 -0
  69. package/dist/types/program/ops/opAssignment/opuMultiplication.d.ts +11 -0
  70. package/dist/types/program/ops/opAssignment/opuNullCoalescence.d.ts +11 -0
  71. package/dist/types/program/ops/opAssignment/opuRemainder.d.ts +11 -0
  72. package/dist/types/program/ops/opAssignment/opuSet.d.ts +11 -0
  73. package/dist/types/program/ops/opAssignment/opuSubtraction.d.ts +11 -0
  74. package/dist/types/program/ops/opAssignment/opuUpdate.d.ts +11 -0
  75. package/dist/types/program/ops/opCalculation/index.d.ts +11 -0
  76. package/dist/types/program/ops/opCalculation/opmAddition.d.ts +11 -0
  77. package/dist/types/program/ops/opCalculation/opmDivision.d.ts +11 -0
  78. package/dist/types/program/ops/opCalculation/opmMultiplication.d.ts +11 -0
  79. package/dist/types/program/ops/opCalculation/opmRemainder.d.ts +11 -0
  80. package/dist/types/program/ops/opCalculation/opmSubtraction.d.ts +11 -0
  81. package/dist/types/program/ops/opComparison/index.d.ts +11 -0
  82. package/dist/types/program/ops/opComparison/opcEqual.d.ts +11 -0
  83. package/dist/types/program/ops/opComparison/opcGreater.d.ts +11 -0
  84. package/dist/types/program/ops/opComparison/opcGreaterEqual.d.ts +11 -0
  85. package/dist/types/program/ops/opComparison/opcLess.d.ts +11 -0
  86. package/dist/types/program/ops/opComparison/opcLessEqual.d.ts +11 -0
  87. package/dist/types/program/ops/opComparison/opcUnequal.d.ts +11 -0
  88. package/dist/types/program/ops/opConstant.d.ts +11 -0
  89. package/dist/types/program/ops/opConstantFalse.d.ts +11 -0
  90. package/dist/types/program/ops/opConstantNull.d.ts +11 -0
  91. package/dist/types/program/ops/opConstantTrue.d.ts +11 -0
  92. package/dist/types/program/ops/opFunctionDefinition.d.ts +11 -0
  93. package/dist/types/program/ops/opIf.d.ts +11 -0
  94. package/dist/types/program/ops/opInterpolatedString.d.ts +11 -0
  95. package/dist/types/program/ops/opNegation.d.ts +11 -0
  96. package/dist/types/program/ops/opNot.d.ts +11 -0
  97. package/dist/types/program/ops/opNullCoalescence.d.ts +11 -0
  98. package/dist/types/program/ops/opNumber.d.ts +11 -0
  99. package/dist/types/program/ops/opObjectConstructor.d.ts +11 -0
  100. package/dist/types/program/ops/opOr.d.ts +11 -0
  101. package/dist/types/program/ops/opOutputConcat.d.ts +11 -0
  102. package/dist/types/program/ops/opString.d.ts +11 -0
  103. package/dist/types/program/ops/opTry.d.ts +11 -0
  104. package/dist/types/program/ops/opVariable.d.ts +11 -0
  105. package/dist/types/program/ops/opVariableDefinition.d.ts +11 -0
  106. package/dist/types/program/ops/opVoid.d.ts +11 -0
  107. package/dist/types/program/ops/utils.d.ts +5 -0
  108. package/dist/types/program/params.d.ts +68 -0
  109. package/dist/types/runtime/index.d.ts +83 -0
  110. package/package.json +66 -49
  111. package/{repl.js → repl.ts} +85 -39
  112. package/lib/applyDefaults.js +0 -34
  113. package/lib/builtins/funcContains.js +0 -25
  114. package/lib/builtins/funcEndsWith.js +0 -21
  115. package/lib/builtins/funcError.js +0 -11
  116. package/lib/builtins/funcFromJSON.js +0 -26
  117. package/lib/builtins/funcHas.js +0 -24
  118. package/lib/builtins/funcIn.js +0 -24
  119. package/lib/builtins/funcKeys.js +0 -20
  120. package/lib/builtins/funcLength.js +0 -24
  121. package/lib/builtins/funcNow.js +0 -10
  122. package/lib/builtins/funcStartsWith.js +0 -21
  123. package/lib/builtins/funcToJSON.js +0 -10
  124. package/lib/builtins/funcToLowerCase.js +0 -17
  125. package/lib/builtins/funcToNumber.js +0 -26
  126. package/lib/builtins/funcToString.js +0 -10
  127. package/lib/builtins/funcToUpperCase.js +0 -17
  128. package/lib/builtins/funcTrim.js +0 -17
  129. package/lib/builtins/funcTrimEnd.js +0 -17
  130. package/lib/builtins/funcTrimStart.js +0 -17
  131. package/lib/builtins/funcType.js +0 -10
  132. package/lib/builtins/funcVoid.js +0 -10
  133. package/lib/builtins/index.js +0 -205
  134. package/lib/builtins/internals.js +0 -8
  135. package/lib/builtins/math.js +0 -40
  136. package/lib/builtins/native.js +0 -180
  137. package/lib/createSingleton.js +0 -14
  138. package/lib/index.js +0 -79
  139. package/lib/interpreter/index.js +0 -56
  140. package/lib/interpreter/parse.js +0 -2377
  141. package/lib/interpreter/parseFunction.js +0 -24
  142. package/lib/interpreter/system.js +0 -10
  143. package/lib/interpreter/util.js +0 -349
  144. package/lib/library/apply.js +0 -142
  145. package/lib/library/definition.js +0 -9
  146. package/lib/library/errors/adaptErrors.js +0 -34
  147. package/lib/library/errors/enclosure.js +0 -16
  148. package/lib/library/errors/error.js +0 -18
  149. package/lib/library/errors/execution.js +0 -20
  150. package/lib/library/errors/fatal.js +0 -15
  151. package/lib/library/errors/runtime.js +0 -78
  152. package/lib/library/errors/syntax.js +0 -17
  153. package/lib/library/functions.js +0 -82
  154. package/lib/library/index.js +0 -335
  155. package/lib/library/mux.js +0 -106
  156. package/lib/library/ops/index.js +0 -60
  157. package/lib/library/ops/op.js +0 -180
  158. package/lib/library/ops/opa.js +0 -41
  159. package/lib/library/ops/opc.js +0 -59
  160. package/lib/library/ops/opm.js +0 -50
  161. package/lib/library/ops/opu.js +0 -77
  162. package/lib/library/runtimeScope.js +0 -38
  163. package/lib/library/runtimeSignal.js +0 -72
  164. package/lib/library/types.js +0 -304
  165. package/lib/program/index.js +0 -101
  166. package/lib/program/ops/index.js +0 -61
  167. package/lib/program/ops/opAccess/index.js +0 -55
  168. package/lib/program/ops/opAccess/opaField.js +0 -50
  169. package/lib/program/ops/opAccess/opaFunction.js +0 -50
  170. package/lib/program/ops/opAccess/opaIter.js +0 -31
  171. package/lib/program/ops/opAccess/opaSlice.js +0 -44
  172. package/lib/program/ops/opAnd.js +0 -30
  173. package/lib/program/ops/opArrayConstructor.js +0 -20
  174. package/lib/program/ops/opAssignment/index.js +0 -90
  175. package/lib/program/ops/opAssignment/opaAssignField.js +0 -125
  176. package/lib/program/ops/opAssignment/opaAssignIter.js +0 -69
  177. package/lib/program/ops/opAssignment/opaAssignSlice.js +0 -99
  178. package/lib/program/ops/opAssignment/opuAddition.js +0 -31
  179. package/lib/program/ops/opAssignment/opuDivision.js +0 -31
  180. package/lib/program/ops/opAssignment/opuMultiplication.js +0 -31
  181. package/lib/program/ops/opAssignment/opuNullCoalescence.js +0 -25
  182. package/lib/program/ops/opAssignment/opuRemainder.js +0 -31
  183. package/lib/program/ops/opAssignment/opuSet.js +0 -19
  184. package/lib/program/ops/opAssignment/opuSubtraction.js +0 -31
  185. package/lib/program/ops/opAssignment/opuUpdate.js +0 -19
  186. package/lib/program/ops/opCalculation/index.js +0 -57
  187. package/lib/program/ops/opCalculation/opmAddition.js +0 -49
  188. package/lib/program/ops/opCalculation/opmDivision.js +0 -42
  189. package/lib/program/ops/opCalculation/opmMultiplication.js +0 -40
  190. package/lib/program/ops/opCalculation/opmRemainder.js +0 -34
  191. package/lib/program/ops/opCalculation/opmSubtraction.js +0 -53
  192. package/lib/program/ops/opComparison/index.js +0 -59
  193. package/lib/program/ops/opComparison/opcEqual.js +0 -19
  194. package/lib/program/ops/opComparison/opcGreater.js +0 -19
  195. package/lib/program/ops/opComparison/opcGreaterEqual.js +0 -19
  196. package/lib/program/ops/opComparison/opcLess.js +0 -19
  197. package/lib/program/ops/opComparison/opcLessEqual.js +0 -19
  198. package/lib/program/ops/opComparison/opcUnequal.js +0 -19
  199. package/lib/program/ops/opConstant.js +0 -18
  200. package/lib/program/ops/opConstantFalse.js +0 -16
  201. package/lib/program/ops/opConstantNull.js +0 -16
  202. package/lib/program/ops/opConstantTrue.js +0 -16
  203. package/lib/program/ops/opFunctionDefinition.js +0 -21
  204. package/lib/program/ops/opIf.js +0 -38
  205. package/lib/program/ops/opInterpolatedString.js +0 -24
  206. package/lib/program/ops/opNegation.js +0 -25
  207. package/lib/program/ops/opNot.js +0 -16
  208. package/lib/program/ops/opNullCoalescence.js +0 -34
  209. package/lib/program/ops/opNumber.js +0 -18
  210. package/lib/program/ops/opObjectConstructor.js +0 -37
  211. package/lib/program/ops/opOr.js +0 -30
  212. package/lib/program/ops/opOutputConcat.js +0 -19
  213. package/lib/program/ops/opString.js +0 -18
  214. package/lib/program/ops/opTry.js +0 -37
  215. package/lib/program/ops/opVariable.js +0 -20
  216. package/lib/program/ops/opVariableDefinition.js +0 -24
  217. package/lib/program/ops/opVoid.js +0 -16
  218. package/lib/program/ops/utils.js +0 -35
  219. package/lib/runtime/index.js +0 -258
  220. package/src/applyDefaults.js +0 -35
  221. package/src/builtins/funcContains.js +0 -27
  222. package/src/builtins/funcEndsWith.js +0 -21
  223. package/src/builtins/funcError.js +0 -7
  224. package/src/builtins/funcFromJSON.js +0 -24
  225. package/src/builtins/funcHas.js +0 -25
  226. package/src/builtins/funcIn.js +0 -25
  227. package/src/builtins/funcKeys.js +0 -20
  228. package/src/builtins/funcLength.js +0 -26
  229. package/src/builtins/funcNow.js +0 -5
  230. package/src/builtins/funcStartsWith.js +0 -21
  231. package/src/builtins/funcToJSON.js +0 -5
  232. package/src/builtins/funcToLowerCase.js +0 -20
  233. package/src/builtins/funcToNumber.js +0 -25
  234. package/src/builtins/funcToString.js +0 -5
  235. package/src/builtins/funcToUpperCase.js +0 -20
  236. package/src/builtins/funcTrim.js +0 -16
  237. package/src/builtins/funcTrimEnd.js +0 -16
  238. package/src/builtins/funcTrimStart.js +0 -16
  239. package/src/builtins/funcType.js +0 -5
  240. package/src/builtins/funcVoid.js +0 -5
  241. package/src/builtins/index.js +0 -193
  242. package/src/builtins/internals.js +0 -9
  243. package/src/builtins/math.js +0 -44
  244. package/src/createSingleton.js +0 -9
  245. package/src/index.js +0 -44
  246. package/src/interpreter/index.js +0 -48
  247. package/src/interpreter/parse.js +0 -1473
  248. package/src/interpreter/system.js +0 -5
  249. package/src/interpreter/util.js +0 -237
  250. package/src/library/apply.js +0 -135
  251. package/src/library/definition.js +0 -3
  252. package/src/library/errors/adaptErrors.js +0 -28
  253. package/src/library/errors/enclosure.js +0 -11
  254. package/src/library/errors/error.js +0 -14
  255. package/src/library/errors/execution.js +0 -15
  256. package/src/library/errors/fatal.js +0 -10
  257. package/src/library/errors/runtime.js +0 -71
  258. package/src/library/errors/syntax.js +0 -12
  259. package/src/library/index.js +0 -41
  260. package/src/library/mux.js +0 -98
  261. package/src/library/runtimeScope.js +0 -35
  262. package/src/library/runtimeSignal.js +0 -67
  263. package/src/library/types.js +0 -299
  264. package/src/program/index.js +0 -114
  265. package/src/program/ops/index.js +0 -82
  266. package/src/program/ops/opAccess/index.js +0 -55
  267. package/src/program/ops/opAccess/opaField.js +0 -58
  268. package/src/program/ops/opAccess/opaFunction.js +0 -52
  269. package/src/program/ops/opAccess/opaIter.js +0 -31
  270. package/src/program/ops/opAccess/opaSlice.js +0 -58
  271. package/src/program/ops/opAnd.js +0 -32
  272. package/src/program/ops/opArrayConstructor.js +0 -16
  273. package/src/program/ops/opAssignment/index.js +0 -102
  274. package/src/program/ops/opAssignment/opaAssignField.js +0 -156
  275. package/src/program/ops/opAssignment/opaAssignIter.js +0 -74
  276. package/src/program/ops/opAssignment/opaAssignSlice.js +0 -157
  277. package/src/program/ops/opAssignment/opuAddition.js +0 -29
  278. package/src/program/ops/opAssignment/opuDivision.js +0 -29
  279. package/src/program/ops/opAssignment/opuMultiplication.js +0 -29
  280. package/src/program/ops/opAssignment/opuNullCoalescence.js +0 -26
  281. package/src/program/ops/opAssignment/opuRemainder.js +0 -29
  282. package/src/program/ops/opAssignment/opuSet.js +0 -15
  283. package/src/program/ops/opAssignment/opuSubtraction.js +0 -29
  284. package/src/program/ops/opAssignment/opuUpdate.js +0 -15
  285. package/src/program/ops/opCalculation/index.js +0 -64
  286. package/src/program/ops/opCalculation/opmAddition.js +0 -63
  287. package/src/program/ops/opCalculation/opmDivision.js +0 -47
  288. package/src/program/ops/opCalculation/opmMultiplication.js +0 -52
  289. package/src/program/ops/opCalculation/opmRemainder.js +0 -49
  290. package/src/program/ops/opCalculation/opmSubtraction.js +0 -72
  291. package/src/program/ops/opComparison/index.js +0 -67
  292. package/src/program/ops/opComparison/opcEqual.js +0 -17
  293. package/src/program/ops/opComparison/opcGreater.js +0 -17
  294. package/src/program/ops/opComparison/opcGreaterEqual.js +0 -17
  295. package/src/program/ops/opComparison/opcLess.js +0 -17
  296. package/src/program/ops/opComparison/opcLessEqual.js +0 -17
  297. package/src/program/ops/opComparison/opcUnequal.js +0 -17
  298. package/src/program/ops/opConstant.js +0 -13
  299. package/src/program/ops/opConstantFalse.js +0 -11
  300. package/src/program/ops/opConstantNull.js +0 -11
  301. package/src/program/ops/opConstantTrue.js +0 -11
  302. package/src/program/ops/opFunctionDefinition.js +0 -17
  303. package/src/program/ops/opIf.js +0 -44
  304. package/src/program/ops/opInterpolatedString.js +0 -27
  305. package/src/program/ops/opNegation.js +0 -26
  306. package/src/program/ops/opNot.js +0 -11
  307. package/src/program/ops/opNullCoalescence.js +0 -36
  308. package/src/program/ops/opNumber.js +0 -13
  309. package/src/program/ops/opObjectConstructor.js +0 -40
  310. package/src/program/ops/opOr.js +0 -32
  311. package/src/program/ops/opOutputConcat.js +0 -17
  312. package/src/program/ops/opString.js +0 -13
  313. package/src/program/ops/opTry.js +0 -38
  314. package/src/program/ops/opVariable.js +0 -17
  315. package/src/program/ops/opVariableDefinition.js +0 -18
  316. package/src/program/ops/opVoid.js +0 -11
  317. package/src/program/ops/utils.js +0 -19
  318. package/src/runtime/index.js +0 -309
  319. /package/{src/builtins/native.js → dist/types/builtins/native.d.ts} +0 -0
  320. /package/{src/library/ops/index.js → dist/types/library/ops/index.d.ts} +0 -0
@@ -0,0 +1,46 @@
1
+ import { default as JPLExecutionError } from './execution';
2
+ /**
3
+ * JPL error type for generic runtime errors.
4
+ *
5
+ * `value` can by of any type.
6
+ * If at least one replacement is specified, the value is formatted as a template.
7
+ */
8
+ export default class JPLRuntimeError extends JPLExecutionError {
9
+ constructor(value: unknown, ...replacements: unknown[]);
10
+ }
11
+ /**
12
+ * JPL runtime error type for type errors.
13
+ *
14
+ * `value` can by of any type.
15
+ * If at least one replacement is specified, the value is formatted as a template.
16
+ */
17
+ export declare class JPLTypeError extends JPLRuntimeError {
18
+ constructor(value: unknown, ...replacements: unknown[]);
19
+ }
20
+ /**
21
+ * JPL runtime error type for reference errors.
22
+ *
23
+ * `value` can by of any type.
24
+ * If at least one replacement is specified, the value is formatted as a template.
25
+ */
26
+ export declare class JPLReferenceError extends JPLRuntimeError {
27
+ constructor(value: unknown, ...replacements: unknown[]);
28
+ }
29
+ /**
30
+ * JPL runtime error type for zero division errors.
31
+ *
32
+ * `value` can by of any type.
33
+ * If at least one replacement is specified, the value is formatted as a template.
34
+ */
35
+ export declare class JPLZeroDivisionError extends JPLRuntimeError {
36
+ constructor(value: unknown, ...replacements: unknown[]);
37
+ }
38
+ /**
39
+ * JPL runtime error type for type conversion errors.
40
+ *
41
+ * `value` can by of any type.
42
+ * If at least one replacement is specified, the value is formatted as a template.
43
+ */
44
+ export declare class JPLTypeConversionError extends JPLRuntimeError {
45
+ constructor(value: unknown, ...replacements: unknown[]);
46
+ }
@@ -0,0 +1,7 @@
1
+ import { default as JPLError } from './error';
2
+ /** JPL error type for syntax errors */
3
+ export default class JPLSyntaxError extends JPLError {
4
+ readonly src: string;
5
+ readonly at: number;
6
+ constructor(message: string, src?: string, at?: number);
7
+ }
@@ -1,19 +1,10 @@
1
- import JPLRuntimeScope from './runtimeScope';
2
-
3
- function jplEnclosure(runtime, signal, next, input, ...args) {
4
- const { argNames, pipe, scope } = this;
5
-
6
- return runtime.executeInstructions(
7
- pipe,
8
- [input],
9
- scope.next({
10
- signal,
11
- vars: Object.fromEntries(argNames.map((name, i) => [name, args[i] ?? null])),
12
- }),
13
- next,
14
- );
1
+ import { default as JPLRuntime } from '../runtime';
2
+ import { Pipe } from './definition';
3
+ import { default as JPLRuntimeScope, JPLRuntimeScopeConfig } from './runtimeScope';
4
+ import { default as JPLRuntimeSignal } from './runtimeSignal';
5
+ export interface JPLFunc {
6
+ (runtime: JPLRuntime, signal: JPLRuntimeSignal, next: (output: unknown) => Promise<unknown[]> | unknown[], input: unknown, ...args: unknown[]): Promise<unknown[]> | unknown[];
15
7
  }
16
-
17
8
  /**
18
9
  * Create a scoped JPL function from the specified instructions.
19
10
  *
@@ -23,10 +14,7 @@ function jplEnclosure(runtime, signal, next, input, ...args) {
23
14
  * @param {object[]} instructions Instructions to execute
24
15
  * @param {JPLRuntimeScope} scope Runtime scope to bind the function to
25
16
  */
26
- export function scopedFunction(argNames, instructions, scope) {
27
- return jplEnclosure.bind({ argNames, pipe: instructions, scope });
28
- }
29
-
17
+ export declare function scopedFunction(argNames: string[], instructions: Pipe, scope: JPLRuntimeScope): JPLFunc;
30
18
  /**
31
19
  * Create an orphan JPL function from the specified instructions.
32
20
  *
@@ -37,10 +25,7 @@ export function scopedFunction(argNames, instructions, scope) {
37
25
  * @param {object[]} instructions Instructions to execute
38
26
  * @param {{ vars: object? }} [presets] Optional scope presets
39
27
  */
40
- export function orphanFunction(argNames, instructions, presets) {
41
- return scopedFunction(argNames, instructions, new JPLRuntimeScope(presets));
42
- }
43
-
28
+ export declare function orphanFunction(argNames: string[], instructions: Pipe, presets?: JPLRuntimeScopeConfig): JPLFunc;
44
29
  /**
45
30
  * Wrap the specified synchronous function to allow it to be used as a JPL function.
46
31
  *
@@ -64,10 +49,4 @@ export function orphanFunction(argNames, instructions, presets) {
64
49
  *
65
50
  * @param {(runtime: JPLRuntime, input: any, ...args: any[]) => (Promise<any[]> | any[])} fn The function to be wrapped
66
51
  */
67
- export function nativeFunction(fn) {
68
- return async (runtime, signal, next, input, ...args) => {
69
- const results = await fn(runtime, input, ...args);
70
-
71
- return runtime.muxAll([results], next);
72
- };
73
- }
52
+ export declare function nativeFunction(fn: (runtime: JPLRuntime, input: unknown, ...args: unknown[]) => Promise<unknown[]> | unknown[]): JPLFunc;
@@ -0,0 +1,18 @@
1
+ export * from './apply';
2
+ export * from './definition';
3
+ export * from './errors/adaptErrors';
4
+ export { default as adaptErrors } from './errors/adaptErrors';
5
+ export { default as JPLErrorEnclosure } from './errors/enclosure';
6
+ export { default as JPLError } from './errors/error';
7
+ export { default as JPLExecutionError } from './errors/execution';
8
+ export { default as JPLFatalError } from './errors/fatal';
9
+ export * from './errors/runtime';
10
+ export { default as JPLRuntimeError } from './errors/runtime';
11
+ export { default as JPLSyntaxError } from './errors/syntax';
12
+ export * from './functions';
13
+ export * from './mux';
14
+ export { default as mux } from './mux';
15
+ export * from './ops';
16
+ export * from './runtimeScope';
17
+ export { default as JPLRuntimeScope } from './runtimeScope';
18
+ export * from './types';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Multiplex the specified array of arguments by calling cb for all possible combinations of arguments.
3
+ * If the specified `args` array is empty, `cb` is called once without any arguments.
4
+ *
5
+ * `mux([[1, 2], [3, 4]], cb)` for example calls:
6
+ * - `cb(1, 3)`
7
+ * - `cb(1, 4)`
8
+ * - `cb(2, 3)`
9
+ * - `cb(2, 4)`
10
+ */
11
+ export default function mux(args: unknown[][], cb: (...args: any) => void): void;
12
+ /** Multiplex the specified array of arguments and return the results produced by the callbacks */
13
+ export declare function muxOne<T>(args: unknown[][], cb: (...args: any) => T): T[];
14
+ /** Multiplex the specified array of arguments asynchronously and return the results produced by the callbacks */
15
+ export declare function muxAsync<T>(args: unknown[][], cb: (...args: any) => Promise<T> | T): Promise<T[]>;
16
+ /** Multiplex the specified array of arguments asynchronously and return a single array of all merged result arrays produced by the callbacks */
17
+ export declare function muxAll<T>(args: unknown[][], cb: (...args: any) => Promise<T[]> | T[]): Promise<T[]>;
18
+ /** Create a single array from the specified array segments */
19
+ export declare function mergeSegments<T>(segments: T[][]): T[];
@@ -3,172 +3,148 @@
3
3
  *
4
4
  * { pipe: [op], selectors: [opa] }
5
5
  */
6
- export const OP_ACCESS = '$.';
7
-
6
+ export declare const OP_ACCESS = "$.";
8
7
  /**
9
8
  * { pipes: [function] }
10
9
  *
11
10
  * { pipes: [[op]] }
12
11
  */
13
- export const OP_AND = 'and';
14
-
12
+ export declare const OP_AND = "and";
15
13
  /**
16
14
  * { pipe: function }
17
15
  *
18
16
  * { pipe: [op] }
19
17
  */
20
- export const OP_ARRAY_CONSTRUCTOR = '[]';
21
-
18
+ export declare const OP_ARRAY_CONSTRUCTOR = "[]";
22
19
  /**
23
20
  * { pipe: function, selectors: [opa], assignment: opu }
24
21
  *
25
22
  * { pipe: [op], selectors: [opa], assignment: [opu] }
26
23
  */
27
- export const OP_ASSIGNMENT = '$=';
28
-
24
+ export declare const OP_ASSIGNMENT = "$=";
29
25
  /**
30
26
  * { pipe: function, operations: [opm] }
31
27
  *
32
28
  * { pipe: [op], operations: [opm] }
33
29
  */
34
- export const OP_CALCULATION = 'clc';
35
-
30
+ export declare const OP_CALCULATION = "clc";
36
31
  /**
37
32
  * { pipe: function, comparisons: [opc] }
38
33
  *
39
34
  * { pipe: [op], comparisons: [opc] }
40
35
  */
41
- export const OP_COMPARISON = 'cmp';
42
-
36
+ export declare const OP_COMPARISON = "cmp";
43
37
  /**
44
38
  * { value: any }
45
39
  *
46
40
  * { value: any }
47
41
  */
48
- export const OP_CONSTANT = 'cnt';
49
-
42
+ export declare const OP_CONSTANT = "cnt";
50
43
  /**
51
44
  * {}
52
45
  *
53
46
  * {}
54
47
  */
55
- export const OP_CONSTANT_FALSE = 'fls';
56
-
48
+ export declare const OP_CONSTANT_FALSE = "fls";
57
49
  /**
58
50
  * {}
59
51
  *
60
52
  * {}
61
53
  */
62
- export const OP_CONSTANT_NULL = 'nul';
63
-
54
+ export declare const OP_CONSTANT_NULL = "nul";
64
55
  /**
65
56
  * {}
66
57
  *
67
58
  * {}
68
59
  */
69
- export const OP_CONSTANT_TRUE = 'tru';
70
-
60
+ export declare const OP_CONSTANT_TRUE = "tru";
71
61
  /**
72
62
  * { argNames: [string], pipe: function }
73
63
  *
74
64
  * { argNames: [string], pipe: [op] }
75
65
  */
76
- export const OP_FUNCTION_DEFINITION = 'fun';
77
-
66
+ export declare const OP_FUNCTION_DEFINITION = "fun";
78
67
  /**
79
68
  * { ifs: [{ if: function, then: function }], else: function }
80
69
  *
81
70
  * { ifs: [{ if: [op], then: [op] }], else: [op] }
82
71
  */
83
- export const OP_IF = 'if';
84
-
72
+ export declare const OP_IF = "if";
85
73
  /**
86
74
  * { interpolations: [{ before: string, pipe: function }], after: string }
87
75
  *
88
76
  * { interpolations: [{ before: string, pipe: [op] }], after: string }
89
77
  */
90
- export const OP_INTERPOLATED_STRING = '"$"';
91
-
78
+ export declare const OP_INTERPOLATED_STRING = "\"$\"";
92
79
  /**
93
80
  * {}
94
81
  *
95
82
  * {}
96
83
  */
97
- export const OP_NEGATION = 'neg';
98
-
84
+ export declare const OP_NEGATION = "neg";
99
85
  /**
100
86
  * {}
101
87
  *
102
88
  * {}
103
89
  */
104
- export const OP_NOT = 'not';
105
-
90
+ export declare const OP_NOT = "not";
106
91
  /**
107
92
  * { pipes: [function] }
108
93
  *
109
94
  * { pipes: [[op]] }
110
95
  */
111
- export const OP_NULL_COALESCENCE = '??';
112
-
96
+ export declare const OP_NULL_COALESCENCE = "??";
113
97
  /**
114
98
  * { number: number }
115
99
  *
116
100
  * { number: number }
117
101
  */
118
- export const OP_NUMBER = 'nbr';
119
-
102
+ export declare const OP_NUMBER = "nbr";
120
103
  /**
121
104
  * { fields: [{ key: function, value: function, optional: boolean }] }
122
105
  *
123
106
  * { fields: [{ key: [op], value: [op], optional: boolean }] }
124
107
  */
125
- export const OP_OBJECT_CONSTRUCTOR = '{}';
126
-
108
+ export declare const OP_OBJECT_CONSTRUCTOR = "{}";
127
109
  /**
128
110
  * { pipes: [function] }
129
111
  *
130
112
  * { pipes: [[op]] }
131
113
  */
132
- export const OP_OR = 'or';
133
-
114
+ export declare const OP_OR = "or";
134
115
  /**
135
116
  * { pipes: [function] }
136
117
  *
137
118
  * { pipes: [[op]] }
138
119
  */
139
- export const OP_OUTPUT_CONCAT = ',';
140
-
120
+ export declare const OP_OUTPUT_CONCAT = ",";
141
121
  /**
142
122
  * { string: string }
143
123
  *
144
124
  * { string: string }
145
125
  */
146
- export const OP_STRING = '""';
147
-
126
+ export declare const OP_STRING = "\"\"";
148
127
  /**
149
128
  * { try: function, catch: function }
150
129
  *
151
130
  * { try: [op], catch: [op] }
152
131
  */
153
- export const OP_TRY = 'try';
154
-
132
+ export declare const OP_TRY = "try";
155
133
  /**
156
134
  * { name: string }
157
135
  *
158
136
  * { name: string }
159
137
  */
160
- export const OP_VARIABLE = 'var';
161
-
138
+ export declare const OP_VARIABLE = "var";
162
139
  /**
163
140
  * { name: string, pipe: function }
164
141
  *
165
142
  * { name: string, pipe: [op] }
166
143
  */
167
- export const OP_VARIABLE_DEFINITION = 'va=';
168
-
144
+ export declare const OP_VARIABLE_DEFINITION = "va=";
169
145
  /**
170
146
  * {}
171
147
  *
172
148
  * {}
173
149
  */
174
- export const OP_VOID = 'vod';
150
+ export declare const OP_VOID = "vod";
@@ -5,8 +5,7 @@
5
5
  *
6
6
  * { pipe: [op], optional: boolean }
7
7
  */
8
- export const OPA_FIELD = '$.$';
9
-
8
+ export declare const OPA_FIELD = "$.$";
10
9
  /**
11
10
  * Sub operator for OP_ACCESS
12
11
  *
@@ -14,8 +13,7 @@ export const OPA_FIELD = '$.$';
14
13
  *
15
14
  * { args: [[op]], bound: boolean, optional: boolean }
16
15
  */
17
- export const OPA_FUNCTION = '$()';
18
-
16
+ export declare const OPA_FUNCTION = "$()";
19
17
  /**
20
18
  * Sub operator for OP_ACCESS
21
19
  *
@@ -23,8 +21,7 @@ export const OPA_FUNCTION = '$()';
23
21
  *
24
22
  * { optional: boolean }
25
23
  */
26
- export const OPA_ITER = '$[]';
27
-
24
+ export declare const OPA_ITER = "$[]";
28
25
  /**
29
26
  * Sub operator for OP_ACCESS
30
27
  *
@@ -32,4 +29,4 @@ export const OPA_ITER = '$[]';
32
29
  *
33
30
  * { from: [op], to: [op], optional: boolean }
34
31
  */
35
- export const OPA_SLICE = '[:]';
32
+ export declare const OPA_SLICE = "[:]";
@@ -5,8 +5,7 @@
5
5
  *
6
6
  * { by: [op] }
7
7
  */
8
- export const OPC_EQUAL = '==';
9
-
8
+ export declare const OPC_EQUAL = "==";
10
9
  /**
11
10
  * Sub operator for OP_COMPARISON
12
11
  *
@@ -14,8 +13,7 @@ export const OPC_EQUAL = '==';
14
13
  *
15
14
  * { by: [op] }
16
15
  */
17
- export const OPC_GREATER = '>';
18
-
16
+ export declare const OPC_GREATER = ">";
19
17
  /**
20
18
  * Sub operator for OP_COMPARISON
21
19
  *
@@ -23,8 +21,7 @@ export const OPC_GREATER = '>';
23
21
  *
24
22
  * { by: [op] }
25
23
  */
26
- export const OPC_GREATEREQUAL = '>=';
27
-
24
+ export declare const OPC_GREATEREQUAL = ">=";
28
25
  /**
29
26
  * Sub operator for OP_COMPARISON
30
27
  *
@@ -32,8 +29,7 @@ export const OPC_GREATEREQUAL = '>=';
32
29
  *
33
30
  * { by: [op] }
34
31
  */
35
- export const OPC_LESS = '<';
36
-
32
+ export declare const OPC_LESS = "<";
37
33
  /**
38
34
  * Sub operator for OP_COMPARISON
39
35
  *
@@ -41,8 +37,7 @@ export const OPC_LESS = '<';
41
37
  *
42
38
  * { by: [op] }
43
39
  */
44
- export const OPC_LESSEQUAL = '<=';
45
-
40
+ export declare const OPC_LESSEQUAL = "<=";
46
41
  /**
47
42
  * Sub operator for OP_COMPARISON
48
43
  *
@@ -50,4 +45,4 @@ export const OPC_LESSEQUAL = '<=';
50
45
  *
51
46
  * { by: [op] }
52
47
  */
53
- export const OPC_UNEQUAL = '!=';
48
+ export declare const OPC_UNEQUAL = "!=";
@@ -5,8 +5,7 @@
5
5
  *
6
6
  * { by: [op] }
7
7
  */
8
- export const OPM_ADDITION = '+';
9
-
8
+ export declare const OPM_ADDITION = "+";
10
9
  /**
11
10
  * Sub operator for OP_CALCULATION
12
11
  *
@@ -14,8 +13,7 @@ export const OPM_ADDITION = '+';
14
13
  *
15
14
  * { by: [op] }
16
15
  */
17
- export const OPM_DIVISION = '/';
18
-
16
+ export declare const OPM_DIVISION = "/";
19
17
  /**
20
18
  * Sub operator for OP_CALCULATION
21
19
  *
@@ -23,8 +21,7 @@ export const OPM_DIVISION = '/';
23
21
  *
24
22
  * { by: [op] }
25
23
  */
26
- export const OPM_MULTIPLICATION = '*';
27
-
24
+ export declare const OPM_MULTIPLICATION = "*";
28
25
  /**
29
26
  * Sub operator for OP_CALCULATION
30
27
  *
@@ -32,8 +29,7 @@ export const OPM_MULTIPLICATION = '*';
32
29
  *
33
30
  * { by: [op] }
34
31
  */
35
- export const OPM_REMAINDER = '%';
36
-
32
+ export declare const OPM_REMAINDER = "%";
37
33
  /**
38
34
  * Sub operator for OP_CALCULATION
39
35
  *
@@ -41,4 +37,4 @@ export const OPM_REMAINDER = '%';
41
37
  *
42
38
  * { by: [op] }
43
39
  */
44
- export const OPM_SUBTRACTION = '-';
40
+ export declare const OPM_SUBTRACTION = "-";
@@ -5,8 +5,7 @@
5
5
  *
6
6
  * { pipe: [op] }
7
7
  */
8
- export const OPU_ADDITION = '+=';
9
-
8
+ export declare const OPU_ADDITION = "+=";
10
9
  /**
11
10
  * Sub operator for OP_ASSIGNMENT
12
11
  *
@@ -14,8 +13,7 @@ export const OPU_ADDITION = '+=';
14
13
  *
15
14
  * { pipe: [op] }
16
15
  */
17
- export const OPU_DIVISION = '/=';
18
-
16
+ export declare const OPU_DIVISION = "/=";
19
17
  /**
20
18
  * Sub operator for OP_ASSIGNMENT
21
19
  *
@@ -23,8 +21,7 @@ export const OPU_DIVISION = '/=';
23
21
  *
24
22
  * { pipe: [op] }
25
23
  */
26
- export const OPU_MULTIPLICATION = '*=';
27
-
24
+ export declare const OPU_MULTIPLICATION = "*=";
28
25
  /**
29
26
  * Sub operator for OP_ASSIGNMENT
30
27
  *
@@ -32,8 +29,7 @@ export const OPU_MULTIPLICATION = '*=';
32
29
  *
33
30
  * { pipe: [op] }
34
31
  */
35
- export const OPU_NULL_COALESCENCE = '?=';
36
-
32
+ export declare const OPU_NULL_COALESCENCE = "?=";
37
33
  /**
38
34
  * Sub operator for OP_ASSIGNMENT
39
35
  *
@@ -41,8 +37,7 @@ export const OPU_NULL_COALESCENCE = '?=';
41
37
  *
42
38
  * { pipe: [op] }
43
39
  */
44
- export const OPU_REMAINDER = '%=';
45
-
40
+ export declare const OPU_REMAINDER = "%=";
46
41
  /**
47
42
  * Sub operator for OP_ASSIGNMENT
48
43
  *
@@ -50,8 +45,7 @@ export const OPU_REMAINDER = '%=';
50
45
  *
51
46
  * { pipe: [op] }
52
47
  */
53
- export const OPU_SET = '=';
54
-
48
+ export declare const OPU_SET = "=";
55
49
  /**
56
50
  * Sub operator for OP_ASSIGNMENT
57
51
  *
@@ -59,8 +53,7 @@ export const OPU_SET = '=';
59
53
  *
60
54
  * { pipe: [op] }
61
55
  */
62
- export const OPU_SUBTRACTION = '-=';
63
-
56
+ export declare const OPU_SUBTRACTION = "-=";
64
57
  /**
65
58
  * Sub operator for OP_ASSIGNMENT
66
59
  *
@@ -68,4 +61,4 @@ export const OPU_SUBTRACTION = '-=';
68
61
  *
69
62
  * { pipe: [op] }
70
63
  */
71
- export const OPU_UPDATE = '|=';
64
+ export declare const OPU_UPDATE = "|=";
@@ -0,0 +1,23 @@
1
+ import { default as JPLRuntimeSignal } from './runtimeSignal';
2
+ export type JPLRuntimeScopeConfig = {
3
+ signal?: JPLRuntimeSignal;
4
+ vars?: {
5
+ [name: string]: unknown;
6
+ };
7
+ };
8
+ /**
9
+ * Runtime scope for managing contextual runtime information.
10
+ *
11
+ * Fields of the scope must not be modified directly.
12
+ * Instead, `JPLRuntimeScope.next` should be used to create a sub scope with the specified modifications.
13
+ */
14
+ export default class JPLRuntimeScope {
15
+ #private;
16
+ constructor(presets?: JPLRuntimeScopeConfig);
17
+ get signal(): JPLRuntimeSignal;
18
+ get vars(): {
19
+ [name: string]: unknown;
20
+ };
21
+ /** Inherit the next scope based on the specified modifications */
22
+ next(modifications: JPLRuntimeScopeConfig): JPLRuntimeScope;
23
+ }
@@ -0,0 +1,25 @@
1
+ /** Runtime signal for managing execution lifecycle */
2
+ export default class JPLRuntimeSignal {
3
+ #private;
4
+ constructor(parent?: JPLRuntimeSignal);
5
+ /** Return the signal's parent */
6
+ get parent(): JPLRuntimeSignal | undefined;
7
+ /** Check whether the current runtime area has been requested to be exited */
8
+ get exited(): boolean;
9
+ /** Check that the current runtime area has not been requested to be exited and throw a fatal error otherwise */
10
+ checkHealth(): void;
11
+ /**
12
+ * Request the current runtime area to be exited.
13
+ * This also involves all child areas (introduced using `JPLRuntimeSignal.next`).
14
+ */
15
+ exit: () => void;
16
+ /**
17
+ * Subscribe for when the current runtime area is requested to be exited.
18
+ * This also involves all parent areas.
19
+ * The function returns an unsubscription hook which must be called when completed in order to prevent memory leaks.
20
+ * If the area has already been exited when subscribing, the callback is called immediately after the current event cycle.
21
+ */
22
+ subscribe: (cb: () => void) => (() => void);
23
+ /** Inherit the next child area for the current one */
24
+ next: () => JPLRuntimeSignal;
25
+ }