@procedures/quantity 0.0.0-stage → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +69 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +3 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +1220 -0
- package/dist/manifest.js.map +1 -0
- package/dist/module.d.ts +19 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +23 -0
- package/dist/module.js.map +1 -0
- package/dist/register.d.ts +6 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +8 -0
- package/dist/register.js.map +1 -0
- package/package.json +86 -3
- package/src/index.ts +2 -0
- package/src/manifest.ts +1222 -0
- package/src/module.ts +27 -0
- package/src/register.ts +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @procedures/quantity
|
|
2
|
+
|
|
3
|
+
## 0.62.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 870f429: Four new wraps of kind 1, made from the types of their homes, with no procedure written by hand:
|
|
8
|
+
|
|
9
|
+
- `@procedures/predicates`: 13 of 13 functions of `@mark1russell7/predicates`.
|
|
10
|
+
- `@procedures/quantity`: 27 of 32 functions of `@mark1russell7/quantity`. The other 5 hold a `bigint`.
|
|
11
|
+
- `@procedures/algebra`: 41 of 46 functions of `@mark1russell7/algebra`.
|
|
12
|
+
- `@procedures/optional`: 20 of 23 functions of `@mark1russell7/optional`. The other 3 are overloads.
|
|
13
|
+
|
|
14
|
+
Each wrap is pure. `wraps.programs.json` has three new programs across the libraries: the netem time of a datagram (algebra and quantity), the side of the median point of a sample (predicates and statistics), and the text of a duration that can be absent (optional and quantity).
|
|
15
|
+
|
|
16
|
+
Fixes of the generator of `@procedures/compiler`:
|
|
17
|
+
|
|
18
|
+
- The type `{}` is each JSON value but `null`, as in TypeScript. So `NonNullable<T>` is the schema of `T` without `null`. Before, the schema was an object with no properties, so the output check of `optional.fromNullable` refused a number.
|
|
19
|
+
- `ReadonlyMap` and `ReadonlySet` are not JSON, as `Map` and `Set`. The detail of an exemption now names the type.
|
|
20
|
+
- The description of a parameter has no hyphen of TSDoc. This changes 15 descriptions of `@procedures/statistics` and `@procedures/generators`.
|
|
21
|
+
|
|
22
|
+
PATCH: before 1.0.0, a backward-compatible feature and a fix raise PATCH. The new packages and procedures add to the API, and the fixed schemas take each value that the function takes.
|
|
23
|
+
- Updated dependencies [b7fbc8e]
|
|
24
|
+
- Updated dependencies [14f61a7]
|
|
25
|
+
- Updated dependencies [b3e65e7]
|
|
26
|
+
- Updated dependencies [9efdd12]
|
|
27
|
+
- Updated dependencies [870f429]
|
|
28
|
+
- @procedures/compiler@0.62.0
|
|
29
|
+
- @procedures/client@0.62.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Mark Russell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @procedures/quantity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@procedures/quantity)
|
|
4
|
+
|
|
5
|
+
The functions of [`@mark1russell7/quantity`](https://www.npmjs.com/package/@mark1russell7/quantity) as procedures: amounts in typed units, the conversions between units, sums and means, and the text of an amount. Each procedure is a typed call, an MCP tool and a CLI command.
|
|
6
|
+
|
|
7
|
+
No procedure is written by hand. The generator of `@procedures/compiler` reads the types of the library and writes `src/manifest.ts`. Thus a procedure cannot drift from its function.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @procedures/quantity @procedures/client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
A host registers the procedures with `createRegistry(quantityModule)`, or with `import "@procedures/quantity/register"` for the global registry. The package root and `./module` register nothing.
|
|
16
|
+
|
|
17
|
+
## Procedures
|
|
18
|
+
|
|
19
|
+
The package has 27 procedures in the namespace `quantity`, one for each function of the library with JSON inputs and a JSON output. Each procedure has no effects: it reads nothing and writes nothing.
|
|
20
|
+
|
|
21
|
+
- The input is an object with one property for each parameter of the function, by its name.
|
|
22
|
+
- The JSON Schemas of the input and the output come from the types. A named type has one definition in `$defs`.
|
|
23
|
+
- A `Quantity` is `{ value, unit }`, for example `{ "value": 1500, "unit": "ms" }`.
|
|
24
|
+
- A conversion between two units of different kinds throws an error. The procedure `whyNotConvertible` gives the reason as text.
|
|
25
|
+
|
|
26
|
+
`quantityManifest` gives the names, the schemas and the effects of each procedure.
|
|
27
|
+
|
|
28
|
+
## Example
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createRegistry, invokePath, outputValue } from "@procedures/client";
|
|
32
|
+
import { quantityModule } from "@procedures/quantity";
|
|
33
|
+
|
|
34
|
+
const registry = createRegistry(quantityModule);
|
|
35
|
+
const output = await invokePath(["quantity", "convert"], { amount: { value: 1500, unit: "ms" }, to: "s" }, { registry });
|
|
36
|
+
const value = await outputValue(output);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## The functions with no procedure
|
|
40
|
+
|
|
41
|
+
5 functions of the library have no procedure. The manifest gives each with its reason:
|
|
42
|
+
|
|
43
|
+
| Functions | Reason | The cause |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `convertExact`, `unitSystem` | `input-not-json` | An input holds a `bigint`: the exact factor of a unit. JSON has no `bigint`. |
|
|
46
|
+
| `lookupAtom`, `parseUnit`, `tryParseUnit` | `output-not-json` | The result holds a `bigint`: the exact factor of a unit. |
|
|
47
|
+
|
|
48
|
+
## Update the manifest
|
|
49
|
+
|
|
50
|
+
After an update of `@mark1russell7/quantity`, start this command from the root of the repository:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
node scripts/wraps.ts generate --package quantity
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The command writes `src/manifest.ts`. It also raises the ratchet of the library in `wraps.coverage.json`. CI starts `node scripts/wraps.ts check`. The check fails when the manifest is not current, or when the share of the functions with a procedure falls.
|
|
57
|
+
|
|
58
|
+
## The gate of a pure wrap
|
|
59
|
+
|
|
60
|
+
The wrap is pure: its `wrap.json` has `"pure": true`. So `node scripts/wraps.ts check` also examines these conditions:
|
|
61
|
+
|
|
62
|
+
- Each procedure has no effects.
|
|
63
|
+
- The field `client.browser` lists `.`, `./module` and `./register`.
|
|
64
|
+
- A program of `wraps.programs.json` uses a procedure of the wrap.
|
|
65
|
+
|
|
66
|
+
The programs of `wraps.programs.json`, at the root of the repository, use the procedures of the pure wraps, also across libraries. The check starts each program two times. The two results must be equal, and equal to the recorded result.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,QAAQ,EAAE,eAksCtB,CAAC"}
|