@procedures/client 0.25.0 → 0.26.1

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 (48) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +10 -0
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/browser.d.ts +2 -2
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js +2 -0
  7. package/dist/browser.js.map +1 -1
  8. package/dist/client/client.d.ts +7 -1
  9. package/dist/client/client.d.ts.map +1 -1
  10. package/dist/client/client.js +30 -19
  11. package/dist/client/client.js.map +1 -1
  12. package/dist/procedures/core/index.d.ts +7 -7
  13. package/dist/procedures/core/index.d.ts.map +1 -1
  14. package/dist/procedures/core/index.js +53 -178
  15. package/dist/procedures/core/index.js.map +1 -1
  16. package/dist/procedures/core/operands.d.ts +12 -13
  17. package/dist/procedures/core/operands.d.ts.map +1 -1
  18. package/dist/procedures/core/operands.js +22 -38
  19. package/dist/procedures/core/operands.js.map +1 -1
  20. package/dist/procedures/define-procedure.d.ts.map +1 -1
  21. package/dist/procedures/define-procedure.js +6 -6
  22. package/dist/procedures/define-procedure.js.map +1 -1
  23. package/dist/procedures/envelope.d.ts +20 -11
  24. package/dist/procedures/envelope.d.ts.map +1 -1
  25. package/dist/procedures/envelope.js +51 -20
  26. package/dist/procedures/envelope.js.map +1 -1
  27. package/dist/procedures/index.d.ts +3 -1
  28. package/dist/procedures/index.d.ts.map +1 -1
  29. package/dist/procedures/index.js +3 -1
  30. package/dist/procedures/index.js.map +1 -1
  31. package/dist/procedures/program.d.ts +251 -0
  32. package/dist/procedures/program.d.ts.map +1 -0
  33. package/dist/procedures/program.js +1120 -0
  34. package/dist/procedures/program.js.map +1 -0
  35. package/dist/procedures/ref.d.ts +7 -94
  36. package/dist/procedures/ref.d.ts.map +1 -1
  37. package/dist/procedures/ref.js +16 -279
  38. package/dist/procedures/ref.js.map +1 -1
  39. package/package.json +3 -1
  40. package/src/browser.ts +23 -0
  41. package/src/client/client.ts +35 -23
  42. package/src/procedures/core/index.ts +56 -216
  43. package/src/procedures/core/operands.ts +24 -44
  44. package/src/procedures/define-procedure.ts +5 -7
  45. package/src/procedures/envelope.ts +60 -24
  46. package/src/procedures/index.ts +34 -4
  47. package/src/procedures/program.ts +1371 -0
  48. package/src/procedures/ref.ts +19 -357
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @procedures/client
2
2
 
3
+ ## 0.26.1
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.26.0
8
+
9
+ ### Minor Changes
10
+
11
+ - a16af64: Changed: a program runs on the kernel of coeval (`@mark1russell7/coeval` `^0.5.0`, roadmap item M14, coeval decision D13). The program format and its rules do not change.
12
+
13
+ - The range `^0.5.0` of `@mark1russell7/coeval` has the kernel fixes of 0.4.1 to 0.4.3 (the narrowing of capabilities in `check()`, the place of a compile throw and of a waiting runner, the step parts after a failed `let`, `#DEPTH!` for an endless recursion, unknown `ops.*`/`ext.*` names in `check()`, `docEquals()` on dates and maps). The types of the client that name coeval types stay the same, with one addition: `Machine`, the type that `programMachine()` gives, has the new optional member `known` (coeval 0.4.3). `World`, `Key`, `Json` and `EvalError` do not change.
14
+
15
+ - `desugarProgram()` changes the `$proc` form into a run document of coeval, and one run of the kernel runs it (`runProgram()`). `client.exec()`, `client.execStream()`, `hydrateInput()`, `prepareRootCall()`, `executeRef()`, the control-flow procedures and the body of a defined procedure use this run.
16
+ - Each call of a program is an effect. The client does it with `client.call()`, so `invokeProcedure()` stays the authority for the admission, the validation, the interceptors and the exposure rules of each call. A failed call throws the same error as before, with its message and its code.
17
+ - The logic of `client.chain`, `client.parallel`, `client.conditional`, `client.and`, `client.or`, `client.map`, `client.reduce` and `client.tryCatch` is a runner of the kernel. The procedures keep their registrations and their schemas.
18
+ - The envelope form reads its envelopes with the helpers of coeval. Its literal stays `{ "type": "literal", "value": x }`, as in 0.23.0, and `toEnvelopeProgram()` writes this form. The type `"lit"` (the kind of the kernel, coeval D12) is an alias: `{ "type": "lit", "value": x }` is also a literal.
19
+ - New exports: `runProgram`, `runDocument`, `runControl`, `runOperand`, `programMachine`, `PROGRAM_WORLD`, `desugarProgram`, `desugarInput`, `desugarControlValue`, `originOf`, `documentAt`, `namesOfScope`, `scopeOfNames`, `nameKey`, `nameOfKey` and their types.
20
+ - `@procedures/compiler`: the name rules (`unknown-name`, `use-before-definition`) run through `check()` of the static kit of coeval on the run document. New exports `nameDiagnostics()` and `bindScopes()`. `resolveScopes()` gives the same diagnostics, with the same codes and messages, in a different order (see below).
21
+ - PROGRAM-FORMAT.md revision 2: section 13 "Programs on the kernel of coeval".
22
+
23
+ MINOR (D26): before 1.0.0, a breaking change raises MINOR. These behaviors change:
24
+
25
+ 1. `client.parallel` with `failFast`: the first error comes at once, as before. The other tasks now stop at their next wait, so their later calls do not start. A call that started goes on in its procedure. Before, the other tasks went on in the background to their end.
26
+ 2. `HydrateOptions.parallel`: the refs that start at the same time now always operate with failFast. After the first error, the other refs stop at their next wait. Before, they went on in the background (`Promise.all`).
27
+ 3. A call or an operand that throws `undefined`: the caller now gets `new Error(<reason>)`, with the reason of the kernel. The error of a task of `client.parallel` and the name `error` of `client.tryCatch` get that reason. Before, the caller got `undefined`, and the error text was `"undefined"`. An `Error`, a text and the other values stay as they are.
28
+ 4. `resolveScopes()` of `@procedures/compiler` gives the warnings for the raw input first, and then the diagnostics of the names. Before, the diagnostics came in the order of the program tree.
29
+ 5. In the envelope form, the types `["ref"]` and `["lit"]` (arrays of one key) are the kinds `ref` and `lit` of the kernel. Before, they were calls of the procedures with the paths `["ref"]` and `["lit"]`. A ref into the world, `{ "type": "ref", "value": ["world", "ref"] }`, stays a call of the procedure, and `toEnvelopeProgram()` now writes this type for these two procedures.
30
+
31
+ Migration:
32
+
33
+ - For 1 and 2: when the later calls of the other tasks must run, wait for those tasks yourself (for example, start them in a separate program and join their results), or do not use `failFast` (for 1) or `parallel` (for 2).
34
+ - For 3: throw an `Error`.
35
+ - For 4: sort the diagnostics by `pointer` when the order matters.
36
+ - For 5: for a call of a procedure with the path `["ref"]` or `["lit"]`, write a ref into the world as the type: `{ "type": { "type": "ref", "value": ["world", "ref"] }, "value": input }`. Or keep the program in the `$proc` form: `{ "$proc": ["ref"], "input": input }` is a call, as before.
37
+
38
+ Speed: the property tests that run each program three ways (`equivalence.test.ts` of the compiler) are about 1.4 times slower on the CI runners: 29.4 s before and 40.0 s after, the sum of the Node 22, 24 and 26 jobs, the mean of 3 runs of main and 4 runs of this change. The program tests of the client (`src/procedures/`) take about the same time: 8.5 s and 8.8 s.
39
+
3
40
  ## 0.25.0
4
41
 
5
42
  ### Minor Changes
package/README.md CHANGED
@@ -513,6 +513,16 @@ const result = await client.exec(procedureRef)
513
513
  const hydrated = await hydrateInput(input, executor)
514
514
  ```
515
515
 
516
+ A program runs on the kernel [coeval](https://github.com/mark1russell7/coeval) (`@mark1russell7/coeval`). `desugarProgram()` changes the `$proc` form into a run document, and one run of the kernel runs it. Each call of the program is an effect that the client does with `client.call()`, so each call keeps its admission, its validation and its interceptors. The static kit of coeval (`check()`) reads the same document. The section "Programs on the kernel of coeval" of [PROGRAM-FORMAT.md](../documentation/PROGRAM-FORMAT.md) gives the run document.
517
+
518
+ ```typescript
519
+ import { check } from "@mark1russell7/coeval";
520
+ import { desugarProgram, programMachine, rawInputRule } from "@procedures/client";
521
+
522
+ const doc = desugarProgram(program, { expand: true });
523
+ const issues = check(programMachine({ rawInput: rawInputRule(registry) }), doc); // for example, a name that nothing binds
524
+ ```
525
+
516
526
  ### Components, Collections and the Program Store
517
527
 
518
528
  They are not in the core. See the README of `@procedures/splay` (components), `@procedures/collections` (data structures) and `@procedures/store` (the program store and the storage layer).