fact-kit-facts 0.6.2 → 0.7.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/dist/index.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
- "indexFormat": "1.2",
2
+ "indexFormat": "2.0",
3
+ "formatVersion": "2.0",
3
4
  "package": "fact-kit-facts",
4
5
  "entry": ".",
5
6
  "component": "fact-kit-facts.npm",
6
7
  "describes": {
7
- "fact-kit-js": "0.11.1"
8
+ "fact-kit-js": "0.12.0"
8
9
  },
9
10
  "publish": {
10
11
  "target": "npm",
@@ -949,6 +950,203 @@
949
950
  }
950
951
  ]
951
952
  }
953
+ },
954
+ {
955
+ "since": "0.12.0-alpha.1",
956
+ "content": {
957
+ "value": [
958
+ {
959
+ "code": "format",
960
+ "rule": "A fact, index, schema file or example does not fit its meta-schema.",
961
+ "reads": "sources and built indexes"
962
+ },
963
+ {
964
+ "code": "duplicate-id",
965
+ "rule": "Two facts have one id.",
966
+ "reads": "sources and built indexes"
967
+ },
968
+ {
969
+ "code": "id-prefix",
970
+ "rule": "A fact id does not start with its tool and a dot.",
971
+ "reads": "sources and built indexes"
972
+ },
973
+ {
974
+ "code": "local-path",
975
+ "rule": "A fact holds a local absolute path.",
976
+ "reads": "sources and built indexes"
977
+ },
978
+ {
979
+ "code": "unregistered-domain",
980
+ "rule": "A fact holds a URL whose host is not in `allowedDomains`.",
981
+ "reads": "sources and built indexes"
982
+ },
983
+ {
984
+ "code": "unknown-fact-id",
985
+ "rule": "`replacement`, `derivedFrom` or an example names a fact that does not exist.",
986
+ "reads": "sources and built indexes"
987
+ },
988
+ {
989
+ "code": "missing-schema-file",
990
+ "rule": "A `$ref` points at a file under `schemas/` that is not there.",
991
+ "reads": "sources and built indexes"
992
+ },
993
+ {
994
+ "code": "describes",
995
+ "rule": "`describes` names more than one component, or the entries of one package disagree (different components, or `{}` mixed with one).",
996
+ "reads": "sources"
997
+ },
998
+ {
999
+ "code": "publish",
1000
+ "rule": "The entries of one package disagree on `publish` (different targets or names, or one entry without it).",
1001
+ "reads": "sources"
1002
+ },
1003
+ {
1004
+ "code": "since-format",
1005
+ "rule": "A `since` is not a version, `next`, or an array of versions that may end in `next`.",
1006
+ "reads": "sources and built indexes"
1007
+ },
1008
+ {
1009
+ "code": "same-line",
1010
+ "rule": "A `since` array has two versions on one release line.",
1011
+ "reads": "sources and built indexes"
1012
+ },
1013
+ {
1014
+ "code": "ambiguous-rows",
1015
+ "rule": "Two rows apply to the same readers with the same bound, so a reader can not choose.",
1016
+ "reads": "sources and built indexes"
1017
+ },
1018
+ {
1019
+ "code": "relation-cycle",
1020
+ "rule": "Facts are derived from each other in a loop through `derivedFrom`.",
1021
+ "reads": "sources and built indexes"
1022
+ },
1023
+ {
1024
+ "code": "relates-foreign",
1025
+ "rule": "`relates` or `factLink` holds a fact object that is not a fact of this package, such as one imported from another package.",
1026
+ "reads": "sources"
1027
+ },
1028
+ {
1029
+ "code": "history",
1030
+ "rule": "A `history` row does not fit: a key that matches no item, a key that is already there, an array that is not keyed, a bad pointer, or a pointer that goes into an array by index. Name an item by its key, or replace the whole array.",
1031
+ "reads": "sources"
1032
+ },
1033
+ {
1034
+ "code": "derive",
1035
+ "rule": "`derive` finds no installed upstream package, no such fact in it, or `map` returns something that is not an object.",
1036
+ "reads": "the installed upstream package"
1037
+ },
1038
+ {
1039
+ "code": "derive-version",
1040
+ "rule": "`derived.lock.json`, or a built index passed with `--index`, records another upstream version than the one installed.",
1041
+ "reads": "the installed upstream package, `derived.lock.json`"
1042
+ },
1043
+ {
1044
+ "code": "lib-rows",
1045
+ "rule": "A row with `since` in `facts/_lib`, which holds only functions and constants.",
1046
+ "reads": "source code, parsed with oxc"
1047
+ },
1048
+ {
1049
+ "code": "since-ahead",
1050
+ "rule": "A `since` is newer than `describes`, or than the `--train` version of its component when one is given.",
1051
+ "reads": "sources, `--train`"
1052
+ },
1053
+ {
1054
+ "code": "train-next",
1055
+ "rule": "A component named by `--train` still has a row that says `next` and is not pending.",
1056
+ "reads": "sources, `--train`"
1057
+ },
1058
+ {
1059
+ "code": "pending-untested",
1060
+ "rule": "A `pending` label is not passed as `include` by any test in `testDirs`.",
1061
+ "reads": "`testDirs`, parsed with oxc"
1062
+ },
1063
+ {
1064
+ "code": "doc-unknown-id",
1065
+ "rule": "A `fact:<id>` or `fact:<spec>:<id>` in `docsDirs` names a fact that does not exist.",
1066
+ "reads": "`docsDirs`"
1067
+ },
1068
+ {
1069
+ "code": "impl-imports-facts",
1070
+ "rule": "Code in `implDirs` imports a `-facts` package (with or without the publish target suffix), a `.facts.ts` or `.doc.ts` file (with or without the extension), or a path inside the `factsDir` of the package by a relative or absolute specifier. A path that holds `facts/dist` is left to `impl-reads-facts-dist`. See `fact-kit.impl-rules-basis`.",
1071
+ "reads": "`implDirs`, parsed with oxc"
1072
+ },
1073
+ {
1074
+ "code": "impl-reads-facts-dist",
1075
+ "rule": "A string in `implDirs` code, or a fixed part of a template, holds `facts/dist` as a path part (bounded by the start, the end, `/` or `\\`). It covers an import, `require`, `readFileSync` and `new URL`. It matches the literal text, so a path built as `join('facts', 'dist')` is not found, and implementations in other languages are out of scope.",
1076
+ "reads": "`implDirs`, parsed with oxc"
1077
+ },
1078
+ {
1079
+ "code": "impl-depends-on-facts",
1080
+ "rule": "A package that is not a facts package lists a `-facts` package in `dependencies`. A name with the publish target suffix, such as `fact-kit-facts.npm`, is a `-facts` package too.",
1081
+ "reads": "every package.json under `repoRoot`"
1082
+ },
1083
+ {
1084
+ "code": "top-level-content",
1085
+ "rule": "A warning. No row applies to a reader that names no platform, so the top-level content is a guess.",
1086
+ "reads": "sources and built indexes"
1087
+ },
1088
+ {
1089
+ "code": "load",
1090
+ "rule": "A source module, example or index file can not be run or parsed.",
1091
+ "reads": "sources"
1092
+ },
1093
+ {
1094
+ "code": "builder",
1095
+ "rule": "A builder, `mf.*`, `contentOf` or `subsetOf` got input that does not fit, such as a name with a leading dot, rows whose first row is not the kind of the method, a subset whose parent is not a fact object, or a state machine, relations or sequence with an end that is not declared, or an entity, value object, aggregate or use case whose names do not match (an identity or `required` name that is not a field, a layer that is not one of three). `history` also raises it when a row makes what a builder checked invalid. The message names the row and the key. Only `check` prints the code. `build` stops with the message.",
1096
+ "reads": "sources"
1097
+ },
1098
+ {
1099
+ "code": "subset-of",
1100
+ "rule": "A list declared with `subsetOf` has, at some version boundary, a value that the list of its parent lacks, or the parent has no row that applies there. The boundaries are those of `ambiguous-rows`, taken over the rows of both facts. The message names the oldest version where it happens and the value. `build` runs this rule too.",
1101
+ "reads": "sources"
1102
+ },
1103
+ {
1104
+ "code": "ref",
1105
+ "rule": "A `ref(fact, field?)` does not resolve. At some version boundary of the two facts, the reader gets a row of the fact that writes the `ref` but no row of the target applies, the target lacks the field (a field name with a dot can not be referenced), the target is a statement and the `ref` has a field, or the target is not a schema where the `ref` is a `$ref`. Also: a field path with an empty part, `$defs` that already has the key with another schema, schemas that embed each other in a loop, a schema of another entry with a file `$ref` embedded here, a `$dynamicRef` or `$recursiveRef`, or a `$ref` to the root inside a subschema with an `$id`, in an embedded schema, which can not be moved into the schema that embeds it, and a target with several rows whose rows can not be aligned with the rows of the fact that writes the `ref`, so some reader gets a schema in `$defs` that is not the one it gets from the target. The message names the oldest version where it happens. `build` runs this rule too.",
1106
+ "reads": "sources"
1107
+ },
1108
+ {
1109
+ "code": "schema-property",
1110
+ "rule": "An `x-identity` names a field that is not in the `properties` of the same schema. It reads every schema of a fact, in every row, and every file under `schemas/`. A `required` list that builders make is checked by `builder`, not by this rule.",
1111
+ "reads": "sources and built indexes"
1112
+ },
1113
+ {
1114
+ "code": "policy-scope",
1115
+ "rule": "The `release-policy.json` at `repoRoot` has `access: \"restricted\"` at the top or in a unit, and no top-level `scope`. `check` reports it itself and does not leave it to the schema of the policy. A repository with no `release-policy.json` is not checked. See `fact-kit.facts-package-naming`.",
1116
+ "reads": "`release-policy.json`"
1117
+ },
1118
+ {
1119
+ "code": "facts-name",
1120
+ "rule": "In an aggregate package (the config has `aggregate`), the name of the aggregate or of a component package is not the one `fact-kit.facts-package-naming` works out from `release-policy.json`: a missing or extra `@<scope>/` prefix, a missing or extra publish target suffix, or a shared base name with no publish target to tell the packages apart. The message names the expected name. A repository with no `release-policy.json` is not checked. A component that is not found in node_modules or in the workspace, or whose facts cannot be loaded, gets a warning with code `facts-name` and is not checked.",
1121
+ "reads": "`release-policy.json`, `release-please-config.json`, the component packages and their facts sources"
1122
+ },
1123
+ {
1124
+ "code": "facts-file-orphan",
1125
+ "rule": "A `*.facts.ts` is under no entry (no `index.ts` in its directory or above it, below the facts directory), or is in a directory whose name starts with `_` or below one. See `fact-kit.facts-file-collection`.",
1126
+ "reads": "the files under `factsDir`"
1127
+ },
1128
+ {
1129
+ "code": "split-topic",
1130
+ "rule": "The facts of one `*.facts.ts` have more than one value of `topics[0]`. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1131
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1132
+ },
1133
+ {
1134
+ "code": "split-size",
1135
+ "rule": "A `*.facts.ts` holds more facts than `maxFactsPerFile`, 40 unless the config says otherwise. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1136
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1137
+ },
1138
+ {
1139
+ "code": "split-index",
1140
+ "rule": "The `index.ts` of an entry that has `*.facts.ts` files holds a fact object. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1141
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1142
+ },
1143
+ {
1144
+ "code": "split-tool",
1145
+ "rule": "A `tool` is written in a `*.facts.ts` anywhere but in the argument of `factsOf(`. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1146
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1147
+ }
1148
+ ]
1149
+ }
952
1150
  }
953
1151
  ],
954
1152
  "tool": "fact-kit",
@@ -1069,7 +1267,7 @@
1069
1267
  },
1070
1268
  {
1071
1269
  "code": "impl-imports-facts",
1072
- "rule": "Code in `implDirs` imports a `-facts` package, with or without the publish target suffix `.<target>` of `fact-kit.facts-package-naming`, as in `fact-kit-facts.npm`.",
1270
+ "rule": "Code in `implDirs` imports a `-facts` package (with or without the publish target suffix), a `.facts.ts` or `.doc.ts` file (with or without the extension), or a path inside the `factsDir` of the package by a relative or absolute specifier. A path that holds `facts/dist` is left to `impl-reads-facts-dist`. See `fact-kit.impl-rules-basis`.",
1073
1271
  "reads": "`implDirs`, parsed with oxc"
1074
1272
  },
1075
1273
  {
@@ -1121,6 +1319,31 @@
1121
1319
  "code": "facts-name",
1122
1320
  "rule": "In an aggregate package (the config has `aggregate`), the name of the aggregate or of a component package is not the one `fact-kit.facts-package-naming` works out from `release-policy.json`: a missing or extra `@<scope>/` prefix, a missing or extra publish target suffix, or a shared base name with no publish target to tell the packages apart. The message names the expected name. A repository with no `release-policy.json` is not checked. A component that is not found in node_modules or in the workspace, or whose facts cannot be loaded, gets a warning with code `facts-name` and is not checked.",
1123
1321
  "reads": "`release-policy.json`, `release-please-config.json`, the component packages and their facts sources"
1322
+ },
1323
+ {
1324
+ "code": "facts-file-orphan",
1325
+ "rule": "A `*.facts.ts` is under no entry (no `index.ts` in its directory or above it, below the facts directory), or is in a directory whose name starts with `_` or below one. See `fact-kit.facts-file-collection`.",
1326
+ "reads": "the files under `factsDir`"
1327
+ },
1328
+ {
1329
+ "code": "split-topic",
1330
+ "rule": "The facts of one `*.facts.ts` have more than one value of `topics[0]`. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1331
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1332
+ },
1333
+ {
1334
+ "code": "split-size",
1335
+ "rule": "A `*.facts.ts` holds more facts than `maxFactsPerFile`, 40 unless the config says otherwise. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1336
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1337
+ },
1338
+ {
1339
+ "code": "split-index",
1340
+ "rule": "The `index.ts` of an entry that has `*.facts.ts` files holds a fact object. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1341
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1342
+ },
1343
+ {
1344
+ "code": "split-tool",
1345
+ "rule": "A `tool` is written in a `*.facts.ts` anywhere but in the argument of `factsOf(`. Runs only when `splitRules` is `true` in the config. See `fact-kit.split-rules`.",
1346
+ "reads": "`*.facts.ts` files and `index.ts`, parsed with oxc"
1124
1347
  }
1125
1348
  ]
1126
1349
  }
@@ -1634,69 +1857,158 @@
1634
1857
  }
1635
1858
  }
1636
1859
  }
1637
- }
1638
- ],
1639
- "tool": "fact-kit",
1640
- "source": {
1641
- "kind": "published"
1642
- },
1643
- "content": {
1644
- "schema": {
1645
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1646
- "title": "Fact index (dist/<entry>/index.json)",
1647
- "type": "object",
1648
- "required": [
1649
- "package",
1650
- "entry",
1651
- "describes",
1652
- "facts"
1653
- ],
1654
- "properties": {
1655
- "indexFormat": {
1656
- "type": "string",
1657
- "pattern": "^[0-9]+\\.[0-9]+$",
1658
- "description": "`1.2` for what this version builds. A missing field reads as `1.0`. Readers take any `1.x`."
1659
- },
1660
- "package": {
1661
- "type": "string",
1662
- "minLength": 1
1663
- },
1664
- "entry": {
1665
- "type": "string",
1666
- "minLength": 1,
1667
- "description": "Sub-path of the entry, e.g. `claude-code`. In an aggregate package it is the path of the index in that package, and `.` for the root."
1668
- },
1669
- "component": {
1670
- "type": "string",
1671
- "minLength": 1,
1672
- "description": "Aggregate package only: the name of the component package the index was built in."
1673
- },
1674
- "formatVersion": {
1675
- "type": "string",
1676
- "minLength": 1
1677
- },
1678
- "describes": {
1679
- "description": "The component this entry describes and the latest published version it covers, e.g. `{ \"claude-code\": \"2.1.308\" }`. `{}` means the described thing has no version. `check` rejects an entry with several keys, and entries of one package that disagree (different components, or `{}` mixed with a component).",
1680
- "type": "object",
1681
- "additionalProperties": {
1682
- "type": "string",
1683
- "minLength": 1
1684
- }
1685
- },
1686
- "facts": {
1687
- "type": "array",
1688
- "items": {
1689
- "$ref": "urn:fact-kit:fact"
1690
- }
1691
- },
1692
- "publish": {
1693
- "description": "Where the described component is published and under what name there (its PublishName), e.g. `{ \"target\": \"npm\", \"name\": \"fact-kit\" }`. `describes` is keyed by the component name, which can differ from the name on the registry. `readFacts` on the JS side uses it to find the installed package when `describes` is not keyed by an npm package name, and only when `target` is `npm`. The readers of the other languages return it and do not check any version. `check` rejects entries of one package that disagree. Left out, `readFacts` takes the `describes` key as the npm package name.",
1860
+ },
1861
+ {
1862
+ "since": "0.12.0-alpha.1",
1863
+ "content": {
1864
+ "schema": {
1865
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1866
+ "title": "Fact index (dist/<entry>/index.json)",
1694
1867
  "type": "object",
1695
1868
  "required": [
1696
- "target",
1697
- "name"
1698
- ],
1699
- "additionalProperties": false,
1869
+ "indexFormat",
1870
+ "formatVersion",
1871
+ "package",
1872
+ "entry",
1873
+ "describes",
1874
+ "facts"
1875
+ ],
1876
+ "properties": {
1877
+ "indexFormat": {
1878
+ "type": "string",
1879
+ "pattern": "^[0-9]+\\.[0-9]+$",
1880
+ "description": "`2.0` for what this version builds. The only key a reader uses to tell the format: a missing field reads as `1.0`, any `1.x` and any `2.x` is read, and any other major version is `unsupported-index-format`."
1881
+ },
1882
+ "formatVersion": {
1883
+ "type": "string",
1884
+ "pattern": "^[0-9]+\\.[0-9]+$",
1885
+ "description": "Written with the same value as `indexFormat` (`2.0`), so that a tool that reads the outputs of several kits finds the format under one key name. The readers of fact-kit do not read it, and when it differs from `indexFormat` only `indexFormat` counts."
1886
+ },
1887
+ "package": {
1888
+ "type": "string",
1889
+ "minLength": 1
1890
+ },
1891
+ "entry": {
1892
+ "type": "string",
1893
+ "minLength": 1,
1894
+ "description": "Sub-path of the entry, e.g. `claude-code`. In an aggregate package it is the path of the index in that package, and `.` for the root."
1895
+ },
1896
+ "component": {
1897
+ "type": "string",
1898
+ "minLength": 1,
1899
+ "description": "Aggregate package only: the name of the component package the index was built in."
1900
+ },
1901
+ "dataFormatVersion": {
1902
+ "type": "string",
1903
+ "minLength": 1,
1904
+ "description": "Optional version of the data format that an entry declares for itself. It was `formatVersion` before 2.0. The readers do not read it and do not return it, so read it from `index.json` directly."
1905
+ },
1906
+ "describes": {
1907
+ "description": "The component this entry describes and the latest published version it covers, e.g. `{ \"claude-code\": \"2.1.308\" }`. `{}` means the described thing has no version. `check` rejects an entry with several keys, and entries of one package that disagree (different components, or `{}` mixed with a component).",
1908
+ "type": "object",
1909
+ "additionalProperties": {
1910
+ "type": "string",
1911
+ "minLength": 1
1912
+ }
1913
+ },
1914
+ "publish": {
1915
+ "description": "Where the described component is published and under what name there (its PublishName), e.g. `{ \"target\": \"npm\", \"name\": \"fact-kit\" }`. `describes` is keyed by the component name, which can differ from the name on the registry. `readFacts` on the JS side uses it to find the installed package when `describes` is not keyed by an npm package name, and only when `target` is `npm`. The readers of the other languages return it and do not check any version. `check` rejects entries of one package that disagree. Left out, `readFacts` takes the `describes` key as the npm package name.",
1916
+ "type": "object",
1917
+ "required": [
1918
+ "target",
1919
+ "name"
1920
+ ],
1921
+ "additionalProperties": false,
1922
+ "properties": {
1923
+ "target": {
1924
+ "enum": [
1925
+ "npm",
1926
+ "pypi",
1927
+ "crates",
1928
+ "go",
1929
+ "swift"
1930
+ ]
1931
+ },
1932
+ "name": {
1933
+ "type": "string",
1934
+ "minLength": 1
1935
+ }
1936
+ }
1937
+ },
1938
+ "facts": {
1939
+ "type": "array",
1940
+ "items": {
1941
+ "$ref": "urn:fact-kit:fact"
1942
+ }
1943
+ }
1944
+ }
1945
+ }
1946
+ }
1947
+ }
1948
+ ],
1949
+ "tool": "fact-kit",
1950
+ "source": {
1951
+ "kind": "published"
1952
+ },
1953
+ "content": {
1954
+ "schema": {
1955
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1956
+ "title": "Fact index (dist/<entry>/index.json)",
1957
+ "type": "object",
1958
+ "required": [
1959
+ "indexFormat",
1960
+ "formatVersion",
1961
+ "package",
1962
+ "entry",
1963
+ "describes",
1964
+ "facts"
1965
+ ],
1966
+ "properties": {
1967
+ "indexFormat": {
1968
+ "type": "string",
1969
+ "pattern": "^[0-9]+\\.[0-9]+$",
1970
+ "description": "`2.0` for what this version builds. The only key a reader uses to tell the format: a missing field reads as `1.0`, any `1.x` and any `2.x` is read, and any other major version is `unsupported-index-format`."
1971
+ },
1972
+ "formatVersion": {
1973
+ "type": "string",
1974
+ "pattern": "^[0-9]+\\.[0-9]+$",
1975
+ "description": "Written with the same value as `indexFormat` (`2.0`), so that a tool that reads the outputs of several kits finds the format under one key name. The readers of fact-kit do not read it, and when it differs from `indexFormat` only `indexFormat` counts."
1976
+ },
1977
+ "package": {
1978
+ "type": "string",
1979
+ "minLength": 1
1980
+ },
1981
+ "entry": {
1982
+ "type": "string",
1983
+ "minLength": 1,
1984
+ "description": "Sub-path of the entry, e.g. `claude-code`. In an aggregate package it is the path of the index in that package, and `.` for the root."
1985
+ },
1986
+ "component": {
1987
+ "type": "string",
1988
+ "minLength": 1,
1989
+ "description": "Aggregate package only: the name of the component package the index was built in."
1990
+ },
1991
+ "dataFormatVersion": {
1992
+ "type": "string",
1993
+ "minLength": 1,
1994
+ "description": "Optional version of the data format that an entry declares for itself. It was `formatVersion` before 2.0. The readers do not read it and do not return it, so read it from `index.json` directly."
1995
+ },
1996
+ "describes": {
1997
+ "description": "The component this entry describes and the latest published version it covers, e.g. `{ \"claude-code\": \"2.1.308\" }`. `{}` means the described thing has no version. `check` rejects an entry with several keys, and entries of one package that disagree (different components, or `{}` mixed with a component).",
1998
+ "type": "object",
1999
+ "additionalProperties": {
2000
+ "type": "string",
2001
+ "minLength": 1
2002
+ }
2003
+ },
2004
+ "publish": {
2005
+ "description": "Where the described component is published and under what name there (its PublishName), e.g. `{ \"target\": \"npm\", \"name\": \"fact-kit\" }`. `describes` is keyed by the component name, which can differ from the name on the registry. `readFacts` on the JS side uses it to find the installed package when `describes` is not keyed by an npm package name, and only when `target` is `npm`. The readers of the other languages return it and do not check any version. `check` rejects entries of one package that disagree. Left out, `readFacts` takes the `describes` key as the npm package name.",
2006
+ "type": "object",
2007
+ "required": [
2008
+ "target",
2009
+ "name"
2010
+ ],
2011
+ "additionalProperties": false,
1700
2012
  "properties": {
1701
2013
  "target": {
1702
2014
  "enum": [
@@ -1712,6 +2024,12 @@
1712
2024
  "minLength": 1
1713
2025
  }
1714
2026
  }
2027
+ },
2028
+ "facts": {
2029
+ "type": "array",
2030
+ "items": {
2031
+ "$ref": "urn:fact-kit:fact"
2032
+ }
1715
2033
  }
1716
2034
  }
1717
2035
  }
@@ -1823,6 +2141,65 @@
1823
2141
  }
1824
2142
  }
1825
2143
  }
2144
+ },
2145
+ {
2146
+ "since": "0.12.0-alpha.1",
2147
+ "content": {
2148
+ "schema": {
2149
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2150
+ "title": "Default export of facts/<entry>/index.ts",
2151
+ "type": "object",
2152
+ "required": [
2153
+ "describes"
2154
+ ],
2155
+ "additionalProperties": false,
2156
+ "properties": {
2157
+ "describes": {
2158
+ "type": "object",
2159
+ "additionalProperties": {
2160
+ "type": "string",
2161
+ "minLength": 1
2162
+ }
2163
+ },
2164
+ "dataFormatVersion": {
2165
+ "type": "string",
2166
+ "minLength": 1,
2167
+ "description": "Written to `dataFormatVersion` of the index. A source that still writes `formatVersion` fails with `format`, because `formatVersion` of the index is now written by the build from `indexFormat`."
2168
+ },
2169
+ "publish": {
2170
+ "description": "Where the described component is published and under what name there (its PublishName), e.g. `{ \"target\": \"npm\", \"name\": \"fact-kit\" }`. `describes` is keyed by the component name, which can differ from the name on the registry. `readFacts` on the JS side uses it to find the installed package when `describes` is not keyed by an npm package name, and only when `target` is `npm`. The readers of the other languages return it and do not check any version. `check` rejects entries of one package that disagree. Left out, `readFacts` takes the `describes` key as the npm package name.",
2171
+ "type": "object",
2172
+ "required": [
2173
+ "target",
2174
+ "name"
2175
+ ],
2176
+ "additionalProperties": false,
2177
+ "properties": {
2178
+ "target": {
2179
+ "enum": [
2180
+ "npm",
2181
+ "pypi",
2182
+ "crates",
2183
+ "go",
2184
+ "swift"
2185
+ ]
2186
+ },
2187
+ "name": {
2188
+ "type": "string",
2189
+ "minLength": 1
2190
+ }
2191
+ }
2192
+ },
2193
+ "facts": {
2194
+ "description": "Facts as they appear in the index, with three differences that the build resolves. `variants` may be the result of `history(...)`, and `content` may then be left out. `relates` lists other fact objects of this package, which become `derivedFrom`. An item may be `derive(upstreamSpec, id, map?)`, a fact computed from an installed upstream package. Optional: the facts of the entry may all be in `*.facts.ts` files, which the build collects after these (`fact-kit.facts-file-collection`).",
2195
+ "type": "array",
2196
+ "items": {
2197
+ "$ref": "urn:fact-kit:fact"
2198
+ }
2199
+ }
2200
+ }
2201
+ }
2202
+ }
1826
2203
  }
1827
2204
  ],
1828
2205
  "tool": "fact-kit",
@@ -1835,8 +2212,7 @@
1835
2212
  "title": "Default export of facts/<entry>/index.ts",
1836
2213
  "type": "object",
1837
2214
  "required": [
1838
- "describes",
1839
- "facts"
2215
+ "describes"
1840
2216
  ],
1841
2217
  "additionalProperties": false,
1842
2218
  "properties": {
@@ -1847,16 +2223,10 @@
1847
2223
  "minLength": 1
1848
2224
  }
1849
2225
  },
1850
- "formatVersion": {
2226
+ "dataFormatVersion": {
1851
2227
  "type": "string",
1852
- "minLength": 1
1853
- },
1854
- "facts": {
1855
- "description": "Facts as they appear in the index, with three differences that the build resolves. `variants` may be the result of `history(...)`, and `content` may then be left out. `relates` lists other fact objects of this package, which become `derivedFrom`. An item may be `derive(upstreamSpec, id, map?)`, a fact computed from an installed upstream package.",
1856
- "type": "array",
1857
- "items": {
1858
- "$ref": "urn:fact-kit:fact"
1859
- }
2228
+ "minLength": 1,
2229
+ "description": "Written to `dataFormatVersion` of the index. A source that still writes `formatVersion` fails with `format`, because `formatVersion` of the index is now written by the build from `indexFormat`."
1860
2230
  },
1861
2231
  "publish": {
1862
2232
  "description": "Where the described component is published and under what name there (its PublishName), e.g. `{ \"target\": \"npm\", \"name\": \"fact-kit\" }`. `describes` is keyed by the component name, which can differ from the name on the registry. `readFacts` on the JS side uses it to find the installed package when `describes` is not keyed by an npm package name, and only when `target` is `npm`. The readers of the other languages return it and do not check any version. `check` rejects entries of one package that disagree. Left out, `readFacts` takes the `describes` key as the npm package name.",
@@ -1881,66 +2251,278 @@
1881
2251
  "minLength": 1
1882
2252
  }
1883
2253
  }
2254
+ },
2255
+ "facts": {
2256
+ "description": "Facts as they appear in the index, with three differences that the build resolves. `variants` may be the result of `history(...)`, and `content` may then be left out. `relates` lists other fact objects of this package, which become `derivedFrom`. An item may be `derive(upstreamSpec, id, map?)`, a fact computed from an installed upstream package. Optional: the facts of the entry may all be in `*.facts.ts` files, which the build collects after these (`fact-kit.facts-file-collection`).",
2257
+ "type": "array",
2258
+ "items": {
2259
+ "$ref": "urn:fact-kit:fact"
2260
+ }
1884
2261
  }
1885
2262
  }
1886
2263
  }
1887
2264
  }
1888
2265
  },
1889
2266
  {
1890
- "id": "fact-kit.config-file",
2267
+ "id": "fact-kit.index-format-detection",
1891
2268
  "topics": [
1892
- "check",
1893
- "config"
2269
+ "read",
2270
+ "build"
1894
2271
  ],
1895
2272
  "title": {
1896
- "en": "Settings in fact-kit.config.json"
2273
+ "en": "How a reader tells the index format"
1897
2274
  },
1898
2275
  "description": {
1899
- "en": "Command-line options override the file."
2276
+ "en": "The rule of the readers, with the result of seven kinds of index for a new reader (fact-kit with index 2.0) and an old one (JS 0.11.x, Python, Rust, Go and Swift 0.4.x)."
1900
2277
  },
1901
2278
  "variants": [
1902
2279
  {
1903
- "since": "0.7.0",
2280
+ "since": "0.12.0-alpha.1",
1904
2281
  "content": {
1905
- "schema": {
1906
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1907
- "title": "fact-kit.config.json",
1908
- "type": "object",
1909
- "additionalProperties": false,
1910
- "properties": {
1911
- "factsDir": {
1912
- "type": "string",
1913
- "default": "facts",
1914
- "description": "Directory of fact sources, relative to the package."
1915
- },
1916
- "examplesDir": {
1917
- "type": "string",
1918
- "default": "examples",
1919
- "description": "Directory of example files, relative to the package."
2282
+ "value": {
2283
+ "rule": [
2284
+ "A reader looks at `indexFormat` only. A missing `indexFormat` reads as `1.0`.",
2285
+ "Major version 1, with any minor version, and major version 2, with any minor version, are read. Any other major version is `unsupported-index-format`.",
2286
+ "A reader never reads the top-level `formatVersion` to tell the format, and does not return a data format version. The version of the data is `dataFormatVersion` in `index.json`.",
2287
+ "When `indexFormat` and the top-level `formatVersion` differ, only `indexFormat` counts."
2288
+ ],
2289
+ "cases": [
2290
+ {
2291
+ "case": 1,
2292
+ "top": {
2293
+ "indexFormat": "1.x"
2294
+ },
2295
+ "new": "1.x",
2296
+ "old": "1.x"
1920
2297
  },
1921
- "indexFiles": {
1922
- "type": "array",
1923
- "items": {
1924
- "type": "string",
1925
- "minLength": 1
2298
+ {
2299
+ "case": 2,
2300
+ "top": {
2301
+ "indexFormat": "2.0",
2302
+ "formatVersion": "2.0",
2303
+ "dataFormatVersion": "<any>"
1926
2304
  },
1927
- "description": "Built `index.json` files (or directories holding one) that `check` reads as well."
2305
+ "new": "2.0",
2306
+ "old": "unsupported-index-format"
1928
2307
  },
1929
- "allowedDomains": {
1930
- "type": "array",
1931
- "items": {
1932
- "type": "string",
1933
- "minLength": 1
2308
+ {
2309
+ "case": 3,
2310
+ "top": {
2311
+ "formatVersion": "2.0"
1934
2312
  },
1935
- "description": "Hosts URLs in facts may point at. A subdomain of an entry is allowed too."
2313
+ "new": "1.0",
2314
+ "old": "1.0"
1936
2315
  },
1937
- "aggregate": {
1938
- "type": "object",
1939
- "additionalProperties": {
1940
- "type": "string",
1941
- "minLength": 1
2316
+ {
2317
+ "case": 4,
2318
+ "top": {
2319
+ "formatVersion": "3.0"
1942
2320
  },
1943
- "description": "Aggregate package only: sub-path (`.` for the root) -> the component package whose built indexes `build` copies there. See `fact-kit.aggregate-layout`."
2321
+ "new": "1.0",
2322
+ "old": "1.0"
2323
+ },
2324
+ {
2325
+ "case": 5,
2326
+ "top": {
2327
+ "formatVersion": "4",
2328
+ "note": "a data format version, not an index format"
2329
+ },
2330
+ "new": "1.0",
2331
+ "old": "1.0"
2332
+ },
2333
+ {
2334
+ "case": 6,
2335
+ "top": {
2336
+ "indexFormat": "2.0",
2337
+ "formatVersion": "3.0"
2338
+ },
2339
+ "new": "2.0",
2340
+ "old": "unsupported-index-format"
2341
+ },
2342
+ {
2343
+ "case": 7,
2344
+ "top": {
2345
+ "indexFormat": "3.0"
2346
+ },
2347
+ "new": "unsupported-index-format",
2348
+ "old": "unsupported-index-format"
2349
+ }
2350
+ ]
2351
+ }
2352
+ }
2353
+ }
2354
+ ],
2355
+ "tool": "fact-kit",
2356
+ "source": {
2357
+ "kind": "published"
2358
+ },
2359
+ "content": {
2360
+ "value": {
2361
+ "rule": [
2362
+ "A reader looks at `indexFormat` only. A missing `indexFormat` reads as `1.0`.",
2363
+ "Major version 1, with any minor version, and major version 2, with any minor version, are read. Any other major version is `unsupported-index-format`.",
2364
+ "A reader never reads the top-level `formatVersion` to tell the format, and does not return a data format version. The version of the data is `dataFormatVersion` in `index.json`.",
2365
+ "When `indexFormat` and the top-level `formatVersion` differ, only `indexFormat` counts."
2366
+ ],
2367
+ "cases": [
2368
+ {
2369
+ "case": 1,
2370
+ "top": {
2371
+ "indexFormat": "1.x"
2372
+ },
2373
+ "new": "1.x",
2374
+ "old": "1.x"
2375
+ },
2376
+ {
2377
+ "case": 2,
2378
+ "top": {
2379
+ "indexFormat": "2.0",
2380
+ "formatVersion": "2.0",
2381
+ "dataFormatVersion": "<any>"
2382
+ },
2383
+ "new": "2.0",
2384
+ "old": "unsupported-index-format"
2385
+ },
2386
+ {
2387
+ "case": 3,
2388
+ "top": {
2389
+ "formatVersion": "2.0"
2390
+ },
2391
+ "new": "1.0",
2392
+ "old": "1.0"
2393
+ },
2394
+ {
2395
+ "case": 4,
2396
+ "top": {
2397
+ "formatVersion": "3.0"
2398
+ },
2399
+ "new": "1.0",
2400
+ "old": "1.0"
2401
+ },
2402
+ {
2403
+ "case": 5,
2404
+ "top": {
2405
+ "formatVersion": "4",
2406
+ "note": "a data format version, not an index format"
2407
+ },
2408
+ "new": "1.0",
2409
+ "old": "1.0"
2410
+ },
2411
+ {
2412
+ "case": 6,
2413
+ "top": {
2414
+ "indexFormat": "2.0",
2415
+ "formatVersion": "3.0"
2416
+ },
2417
+ "new": "2.0",
2418
+ "old": "unsupported-index-format"
2419
+ },
2420
+ {
2421
+ "case": 7,
2422
+ "top": {
2423
+ "indexFormat": "3.0"
2424
+ },
2425
+ "new": "unsupported-index-format",
2426
+ "old": "unsupported-index-format"
2427
+ }
2428
+ ]
2429
+ }
2430
+ }
2431
+ },
2432
+ {
2433
+ "id": "fact-kit.index-format-boundaries",
2434
+ "topics": [
2435
+ "build"
2436
+ ],
2437
+ "title": {
2438
+ "en": "Edge cases of building index format 2.0"
2439
+ },
2440
+ "description": {
2441
+ "en": "What an aggregate does with a 1.x component index, and what happens to a source that still writes `formatVersion`. Which key a reader takes when the two format keys differ is in `fact-kit.index-format-detection`."
2442
+ },
2443
+ "variants": [
2444
+ {
2445
+ "since": "0.12.0-alpha.1",
2446
+ "content": {
2447
+ "value": {
2448
+ "aggregate": "An aggregate build copies a component index of format 1.x as it is: `indexFormat` and the top-level `formatVersion` are not changed, and the index is not turned into 2.0. A reader tells the format of each index on its own, and a conversion would have to guess whether the old `formatVersion` was a data format version.",
2449
+ "oldSourceKey": {
2450
+ "code": "format",
2451
+ "rule": "A `FactsSource` or entry module that still writes `formatVersion` makes `build` and `check` report `format`, because the entry module has no such key any more. Write `dataFormatVersion` instead."
2452
+ }
2453
+ }
2454
+ }
2455
+ }
2456
+ ],
2457
+ "tool": "fact-kit",
2458
+ "source": {
2459
+ "kind": "published"
2460
+ },
2461
+ "content": {
2462
+ "value": {
2463
+ "aggregate": "An aggregate build copies a component index of format 1.x as it is: `indexFormat` and the top-level `formatVersion` are not changed, and the index is not turned into 2.0. A reader tells the format of each index on its own, and a conversion would have to guess whether the old `formatVersion` was a data format version.",
2464
+ "oldSourceKey": {
2465
+ "code": "format",
2466
+ "rule": "A `FactsSource` or entry module that still writes `formatVersion` makes `build` and `check` report `format`, because the entry module has no such key any more. Write `dataFormatVersion` instead."
2467
+ }
2468
+ }
2469
+ }
2470
+ },
2471
+ {
2472
+ "id": "fact-kit.config-file",
2473
+ "topics": [
2474
+ "check",
2475
+ "config"
2476
+ ],
2477
+ "title": {
2478
+ "en": "Settings in fact-kit.config.json"
2479
+ },
2480
+ "description": {
2481
+ "en": "Command-line options override the file."
2482
+ },
2483
+ "variants": [
2484
+ {
2485
+ "since": "0.7.0",
2486
+ "content": {
2487
+ "schema": {
2488
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2489
+ "title": "fact-kit.config.json",
2490
+ "type": "object",
2491
+ "additionalProperties": false,
2492
+ "properties": {
2493
+ "factsDir": {
2494
+ "type": "string",
2495
+ "default": "facts",
2496
+ "description": "Directory of fact sources, relative to the package."
2497
+ },
2498
+ "examplesDir": {
2499
+ "type": "string",
2500
+ "default": "examples",
2501
+ "description": "Directory of example files, relative to the package."
2502
+ },
2503
+ "indexFiles": {
2504
+ "type": "array",
2505
+ "items": {
2506
+ "type": "string",
2507
+ "minLength": 1
2508
+ },
2509
+ "description": "Built `index.json` files (or directories holding one) that `check` reads as well."
2510
+ },
2511
+ "allowedDomains": {
2512
+ "type": "array",
2513
+ "items": {
2514
+ "type": "string",
2515
+ "minLength": 1
2516
+ },
2517
+ "description": "Hosts URLs in facts may point at. A subdomain of an entry is allowed too."
2518
+ },
2519
+ "aggregate": {
2520
+ "type": "object",
2521
+ "additionalProperties": {
2522
+ "type": "string",
2523
+ "minLength": 1
2524
+ },
2525
+ "description": "Aggregate package only: sub-path (`.` for the root) -> the component package whose built indexes `build` copies there. See `fact-kit.aggregate-layout`."
1944
2526
  },
1945
2527
  "repoRoot": {
1946
2528
  "type": "string",
@@ -2050,6 +2632,100 @@
2050
2632
  }
2051
2633
  }
2052
2634
  }
2635
+ },
2636
+ {
2637
+ "since": "0.12.0-alpha.1",
2638
+ "content": {
2639
+ "schema": {
2640
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2641
+ "title": "fact-kit.config.json",
2642
+ "type": "object",
2643
+ "additionalProperties": false,
2644
+ "properties": {
2645
+ "factsDir": {
2646
+ "type": "string",
2647
+ "default": "facts",
2648
+ "description": "Directory of fact sources, relative to the package. `build`, `check` and `pin` read it, and `--facts-dir` wins over it."
2649
+ },
2650
+ "examplesDir": {
2651
+ "type": "string",
2652
+ "default": "examples",
2653
+ "description": "Directory of example files, relative to the package. `check` reads them, and `build` writes them to `dist/examples.json` when the package has facts."
2654
+ },
2655
+ "indexFiles": {
2656
+ "type": "array",
2657
+ "items": {
2658
+ "type": "string",
2659
+ "minLength": 1
2660
+ },
2661
+ "description": "Built `index.json` files (or directories holding one) that `check` reads as well. `build` reads them too, to find the facts the examples name."
2662
+ },
2663
+ "allowedDomains": {
2664
+ "type": "array",
2665
+ "items": {
2666
+ "type": "string",
2667
+ "minLength": 1
2668
+ },
2669
+ "description": "Hosts URLs in facts may point at. A subdomain of an entry is allowed too."
2670
+ },
2671
+ "aggregate": {
2672
+ "type": "object",
2673
+ "additionalProperties": {
2674
+ "type": "string",
2675
+ "minLength": 1
2676
+ },
2677
+ "description": "Aggregate package only: sub-path (`.` for the root) -> the component package whose built indexes `build` copies there. See `fact-kit.aggregate-layout`."
2678
+ },
2679
+ "repoRoot": {
2680
+ "type": "string",
2681
+ "default": "the nearest parent that holds .git",
2682
+ "description": "Root of the repository, relative to the package. `check` reads every package.json under it and reports a package that is not a facts package but lists a `-facts` package in `dependencies`."
2683
+ },
2684
+ "testDirs": {
2685
+ "type": "array",
2686
+ "items": {
2687
+ "type": "string",
2688
+ "minLength": 1
2689
+ },
2690
+ "description": "Directories of tests, relative to the package. A `pending` label must be passed as `include` by a test there."
2691
+ },
2692
+ "docsDirs": {
2693
+ "type": "array",
2694
+ "items": {
2695
+ "type": "string",
2696
+ "minLength": 1
2697
+ },
2698
+ "description": "Directories, relative to the package. `check` reports a `fact:<id>` or `fact:<spec>:<id>` in the markdown there that names no fact. `diff --impact` searches them for references to a fact: markdown, and `get`, `value` and `has` calls in TypeScript."
2699
+ },
2700
+ "implDirs": {
2701
+ "type": "array",
2702
+ "items": {
2703
+ "type": "string",
2704
+ "minLength": 1
2705
+ },
2706
+ "description": "Directories of the implementation, relative to the package. Code there must not import a `-facts` package."
2707
+ },
2708
+ "splitRules": {
2709
+ "type": "boolean",
2710
+ "default": false,
2711
+ "description": "Switches on the four split rules (`split-topic`, `split-size`, `split-index`, `split-tool`) of `check`. They are off unless this is `true`. See `fact-kit.split-rules`."
2712
+ },
2713
+ "maxFactsPerFile": {
2714
+ "type": "integer",
2715
+ "minimum": 1,
2716
+ "default": 40,
2717
+ "description": "The most facts one `*.facts.ts` may hold. Only `split-size` reads it, and only when `splitRules` is `true`."
2718
+ },
2719
+ "dataKeys": {
2720
+ "type": "array",
2721
+ "items": {
2722
+ "type": "string"
2723
+ },
2724
+ "description": "Property names whose object value is data, not a row, for `pin` and `merge-since`. Replaces the built-in list. See `fact-kit.row-data-keys`."
2725
+ }
2726
+ }
2727
+ }
2728
+ }
2053
2729
  }
2054
2730
  ],
2055
2731
  "tool": "fact-kit",
@@ -2066,7 +2742,7 @@
2066
2742
  "factsDir": {
2067
2743
  "type": "string",
2068
2744
  "default": "facts",
2069
- "description": "Directory of fact sources, relative to the package."
2745
+ "description": "Directory of fact sources, relative to the package. `build`, `check` and `pin` read it, and `--facts-dir` wins over it."
2070
2746
  },
2071
2747
  "examplesDir": {
2072
2748
  "type": "string",
@@ -2125,6 +2801,24 @@
2125
2801
  "minLength": 1
2126
2802
  },
2127
2803
  "description": "Directories of the implementation, relative to the package. Code there must not import a `-facts` package."
2804
+ },
2805
+ "splitRules": {
2806
+ "type": "boolean",
2807
+ "default": false,
2808
+ "description": "Switches on the four split rules (`split-topic`, `split-size`, `split-index`, `split-tool`) of `check`. They are off unless this is `true`. See `fact-kit.split-rules`."
2809
+ },
2810
+ "maxFactsPerFile": {
2811
+ "type": "integer",
2812
+ "minimum": 1,
2813
+ "default": 40,
2814
+ "description": "The most facts one `*.facts.ts` may hold. Only `split-size` reads it, and only when `splitRules` is `true`."
2815
+ },
2816
+ "dataKeys": {
2817
+ "type": "array",
2818
+ "items": {
2819
+ "type": "string"
2820
+ },
2821
+ "description": "Property names whose object value is data, not a row, for `pin` and `merge-since`. Replaces the built-in list. See `fact-kit.row-data-keys`."
2128
2822
  }
2129
2823
  }
2130
2824
  }
@@ -2643,23 +3337,203 @@
2643
3337
  }
2644
3338
  }
2645
3339
  }
2646
- }
2647
- ],
2648
- "tool": "fact-kit",
2649
- "source": {
2650
- "kind": "published"
2651
- },
2652
- "content": {
2653
- "value": {
2654
- "global": {
2655
- "options": [
2656
- {
2657
- "flag": "-h",
2658
- "alias": "--help",
2659
- "summary": "Show the help text and exit with 0."
3340
+ },
3341
+ {
3342
+ "since": "0.12.0-alpha.1",
3343
+ "content": {
3344
+ "value": {
3345
+ "global": {
3346
+ "options": [
3347
+ {
3348
+ "flag": "-h",
3349
+ "alias": "--help",
3350
+ "summary": "Show the help text and exit with 0."
3351
+ },
3352
+ {
3353
+ "flag": "-v",
3354
+ "alias": "--version",
3355
+ "summary": "Print the fact-kit version."
3356
+ }
3357
+ ],
3358
+ "exitCodes": {
3359
+ "0": "No problem found.",
3360
+ "1": "A problem was found, or the command failed. For `merge-since`: a conflict is left.",
3361
+ "2": "Wrong usage or input: no command, an unknown command or option, the wrong number of arguments, a `--train` that is not `<component>=<version>`, a `pin` with no `--version`, with more than one, or with one that is not semver, a config or index file that can not be read, a source file that can not be parsed, `oxc-parser` that is not installed, or a `merge-since` outside a git merge."
3362
+ }
2660
3363
  },
2661
- {
2662
- "flag": "-v",
3364
+ "check": {
3365
+ "summary": "Validate facts, examples and what must not ship (local paths, unregistered domains).",
3366
+ "arguments": [],
3367
+ "options": [
3368
+ {
3369
+ "flag": "--cwd",
3370
+ "value": "<dir>",
3371
+ "default": "the current directory",
3372
+ "summary": "Package directory."
3373
+ },
3374
+ {
3375
+ "flag": "--config",
3376
+ "value": "<file>",
3377
+ "default": "fact-kit.config.json when present",
3378
+ "summary": "Config file."
3379
+ },
3380
+ {
3381
+ "flag": "--facts-dir",
3382
+ "value": "<dir>",
3383
+ "default": "facts",
3384
+ "summary": "Fact sources, relative to --cwd."
3385
+ },
3386
+ {
3387
+ "flag": "--examples-dir",
3388
+ "value": "<dir>",
3389
+ "default": "examples",
3390
+ "summary": "Example files, relative to --cwd."
3391
+ },
3392
+ {
3393
+ "flag": "--index",
3394
+ "value": "<path>",
3395
+ "default": "none",
3396
+ "summary": "A built index.json (or its directory) to check too.",
3397
+ "repeatable": true
3398
+ },
3399
+ {
3400
+ "flag": "--allow-domain",
3401
+ "value": "<host>",
3402
+ "default": "none",
3403
+ "summary": "Host URLs may point at, subdomains included.",
3404
+ "repeatable": true
3405
+ },
3406
+ {
3407
+ "flag": "--train",
3408
+ "value": "<component>=<version>",
3409
+ "default": "none",
3410
+ "summary": "A component being released at that version: its `since` may be as new as the version, and no row but a pending one may still say `next`.",
3411
+ "repeatable": true
3412
+ },
3413
+ {
3414
+ "flag": "--json",
3415
+ "summary": "Print `{ problems: [{ code, message, location }] }` on stdout instead of the text on stderr."
3416
+ }
3417
+ ]
3418
+ },
3419
+ "build": {
3420
+ "summary": "Build facts/<entry>/index.ts into dist/<entry>/index.json and schemas/, and the example groups of the examples directory into dist/examples.json (nothing is written when there are none). The snippets in the groups are not run. In an aggregate package (`aggregate` in the config) copy the built indexes and examples.json of its component packages into dist/ instead.",
3421
+ "arguments": [],
3422
+ "options": [
3423
+ {
3424
+ "flag": "--cwd",
3425
+ "value": "<dir>",
3426
+ "default": "the current directory",
3427
+ "summary": "Package directory."
3428
+ },
3429
+ {
3430
+ "flag": "--facts-dir",
3431
+ "value": "<dir>",
3432
+ "default": "facts",
3433
+ "summary": "Fact sources."
3434
+ },
3435
+ {
3436
+ "flag": "--out-dir",
3437
+ "value": "<dir>",
3438
+ "default": "dist",
3439
+ "summary": "Output directory."
3440
+ },
3441
+ {
3442
+ "flag": "--write-exports",
3443
+ "summary": "Add the missing \"exports\" entries to package.json."
3444
+ },
3445
+ {
3446
+ "flag": "--accept-upstream",
3447
+ "summary": "Build facts derived from another upstream version than `derived.lock.json` records, and rewrite the lock. Without it the build fails and names both versions."
3448
+ }
3449
+ ],
3450
+ "factsDir": "The fact sources directory. `--facts-dir` wins, then `factsDir` of the config file, then `facts`."
3451
+ },
3452
+ "diff": {
3453
+ "summary": "List the fact ids added, removed and changed between two index.json files. With --impact, list instead what a change to one fact reaches.",
3454
+ "arguments": [
3455
+ "<old>",
3456
+ "<new>"
3457
+ ],
3458
+ "options": [
3459
+ {
3460
+ "flag": "--json",
3461
+ "summary": "Print the result as JSON: { added, removed, changed }, or with --impact { id, facts: [{ id, depth, via }], docs: [{ file, line, id }], examples: [{ spec, group, scenario, id, in }] }."
3462
+ },
3463
+ {
3464
+ "flag": "--impact",
3465
+ "value": "<id>",
3466
+ "summary": "Take no files. Read the built indexes of the components in the aggregate config, follow derivedFrom downstream, and search docsDirs for references. Needs oxc-parser when docsDirs hold TypeScript."
3467
+ },
3468
+ {
3469
+ "flag": "--cwd",
3470
+ "value": "<dir>",
3471
+ "default": "the current directory",
3472
+ "summary": "With --impact: the aggregate package directory."
3473
+ }
3474
+ ]
3475
+ },
3476
+ "pin": {
3477
+ "summary": "Turn every `next` in the `since` of the rows under the facts directory into one version: a `since` that is `next`, or an array that ends in `next`. A row with a `pending` label stays, so do `describes` and `<facts-dir>/_lib`. Only the text of the literal changes, so a second run changes nothing. Needs oxc-parser.",
3478
+ "arguments": [],
3479
+ "options": [
3480
+ {
3481
+ "flag": "--version",
3482
+ "value": "<v>",
3483
+ "default": "none",
3484
+ "summary": "The version `next` becomes. Required, and given once. It must be semver 2.0.0, and a pre-release such as `0.49.0-alpha.1` is written whole."
3485
+ },
3486
+ {
3487
+ "flag": "--cwd",
3488
+ "value": "<dir>",
3489
+ "default": "the current directory",
3490
+ "summary": "Package directory."
3491
+ },
3492
+ {
3493
+ "flag": "--config",
3494
+ "value": "<file>",
3495
+ "default": "fact-kit.config.json when present",
3496
+ "summary": "Config file."
3497
+ },
3498
+ {
3499
+ "flag": "--facts-dir",
3500
+ "value": "<dir>",
3501
+ "default": "facts",
3502
+ "summary": "Fact sources, relative to --cwd."
3503
+ }
3504
+ ]
3505
+ },
3506
+ "merge-since": {
3507
+ "summary": "Run after `git merge`. In the files that `git diff --name-only --diff-filter=U` lists under --cwd, settle each conflict block whose two sides differ only in `since` (normal, `diff3` and `zdiff3` markers): the union of the versions, the smaller one when two are on one release line, ordered by release line with `next` last. Then rewrite a row that only the merged-in side has (the same fact has no row with that `since` in HEAD) whose `since` is one patch version `X.Y.Z` (`Z` above 0, no pre-release) and has no `pending` into `[\"X.Y.Z\", \"next\"]`. It writes what it settled, stages nothing, and prints each conflict left as `<file>:<line> <reason>`. A second run changes nothing. Needs oxc-parser.",
3508
+ "arguments": [],
3509
+ "options": [
3510
+ {
3511
+ "flag": "--cwd",
3512
+ "value": "<dir>",
3513
+ "default": "the current directory",
3514
+ "summary": "A directory in the repository. Only files under it are read."
3515
+ }
3516
+ ]
3517
+ }
3518
+ }
3519
+ }
3520
+ }
3521
+ ],
3522
+ "tool": "fact-kit",
3523
+ "source": {
3524
+ "kind": "published"
3525
+ },
3526
+ "content": {
3527
+ "value": {
3528
+ "global": {
3529
+ "options": [
3530
+ {
3531
+ "flag": "-h",
3532
+ "alias": "--help",
3533
+ "summary": "Show the help text and exit with 0."
3534
+ },
3535
+ {
3536
+ "flag": "-v",
2663
3537
  "alias": "--version",
2664
3538
  "summary": "Print the fact-kit version."
2665
3539
  }
@@ -2755,7 +3629,8 @@
2755
3629
  "flag": "--accept-upstream",
2756
3630
  "summary": "Build facts derived from another upstream version than `derived.lock.json` records, and rewrite the lock. Without it the build fails and names both versions."
2757
3631
  }
2758
- ]
3632
+ ],
3633
+ "factsDir": "The fact sources directory. `--facts-dir` wins, then `factsDir` of the config file, then `facts`."
2759
3634
  },
2760
3635
  "diff": {
2761
3636
  "summary": "List the fact ids added, removed and changed between two index.json files. With --impact, list instead what a change to one fact reaches.",
@@ -2949,6 +3824,51 @@
2949
3824
  "facts-name"
2950
3825
  ]
2951
3826
  }
3827
+ },
3828
+ {
3829
+ "since": "0.12.0-alpha.1",
3830
+ "content": {
3831
+ "value": [
3832
+ "format",
3833
+ "duplicate-id",
3834
+ "id-prefix",
3835
+ "local-path",
3836
+ "unregistered-domain",
3837
+ "unknown-fact-id",
3838
+ "missing-schema-file",
3839
+ "describes",
3840
+ "publish",
3841
+ "since-format",
3842
+ "ambiguous-rows",
3843
+ "top-level-content",
3844
+ "load",
3845
+ "history",
3846
+ "relates-foreign",
3847
+ "derive",
3848
+ "derive-version",
3849
+ "same-line",
3850
+ "relation-cycle",
3851
+ "lib-rows",
3852
+ "since-ahead",
3853
+ "train-next",
3854
+ "pending-untested",
3855
+ "doc-unknown-id",
3856
+ "impl-imports-facts",
3857
+ "impl-reads-facts-dist",
3858
+ "impl-depends-on-facts",
3859
+ "builder",
3860
+ "subset-of",
3861
+ "ref",
3862
+ "schema-property",
3863
+ "policy-scope",
3864
+ "facts-name",
3865
+ "facts-file-orphan",
3866
+ "split-topic",
3867
+ "split-size",
3868
+ "split-index",
3869
+ "split-tool"
3870
+ ]
3871
+ }
2952
3872
  }
2953
3873
  ],
2954
3874
  "tool": "fact-kit",
@@ -2989,7 +3909,12 @@
2989
3909
  "ref",
2990
3910
  "schema-property",
2991
3911
  "policy-scope",
2992
- "facts-name"
3912
+ "facts-name",
3913
+ "facts-file-orphan",
3914
+ "split-topic",
3915
+ "split-size",
3916
+ "split-index",
3917
+ "split-tool"
2993
3918
  ]
2994
3919
  }
2995
3920
  },
@@ -3576,50 +4501,159 @@
3576
4501
  ]
3577
4502
  }
3578
4503
  }
3579
- }
3580
- ],
3581
- "tool": "fact-kit",
3582
- "source": {
3583
- "kind": "published"
3584
- },
3585
- "content": {
3586
- "value": {
3587
- "module": "fact-kit",
3588
- "export": "readFacts",
3589
- "signature": "readFacts(spec, options?) => FactReader",
3590
- "parameters": [
3591
- {
3592
- "name": "spec",
3593
- "type": "string",
3594
- "required": true,
3595
- "summary": "`<package>` or `<package>/<path>`, scoped names included, and the path may have several segments. The package must export `./index.json` or `./<path>/index.json`."
3596
- },
3597
- {
3598
- "name": "options.root",
3599
- "type": "string",
3600
- "required": false,
3601
- "default": "process.cwd()",
3602
- "summary": "Directory the package is resolved from, normally the hub being built."
3603
- },
3604
- {
3605
- "name": "options.version",
3606
- "type": "string",
3607
- "required": false,
3608
- "default": "the installed version of the described component, else the latest published",
3609
- "summary": "Version of the described component the reader runs, or `head` for the unreleased state. Without it, an installed described component sets the version, and one that is not installed leaves the latest published facts."
3610
- },
3611
- {
3612
- "name": "options.include",
3613
- "type": "string[]",
3614
- "required": false,
3615
- "default": "[]",
3616
- "summary": "Labels of `pending` rows that a reader on `head` also gets."
3617
- },
3618
- {
3619
- "name": "options.platform",
3620
- "type": "string",
3621
- "required": false,
3622
- "summary": "Platform of the reader. A row with a `platforms` condition applies only when it lists this one."
4504
+ },
4505
+ {
4506
+ "since": "0.12.0-alpha.1",
4507
+ "content": {
4508
+ "value": {
4509
+ "module": "fact-kit",
4510
+ "export": "readFacts",
4511
+ "signature": "readFacts(spec, options?) => FactReader",
4512
+ "parameters": [
4513
+ {
4514
+ "name": "spec",
4515
+ "type": "string",
4516
+ "required": true,
4517
+ "summary": "`<package>` or `<package>/<path>`, scoped names included, and the path may have several segments. The package must export `./index.json` or `./<path>/index.json`."
4518
+ },
4519
+ {
4520
+ "name": "options.root",
4521
+ "type": "string",
4522
+ "required": false,
4523
+ "default": "process.cwd()",
4524
+ "summary": "Directory the package is resolved from, normally the hub being built."
4525
+ },
4526
+ {
4527
+ "name": "options.version",
4528
+ "type": "string",
4529
+ "required": false,
4530
+ "default": "the installed version of the described component, else the latest published",
4531
+ "summary": "Version of the described component the reader runs, or `head` for the unreleased state. Without it, an installed described component sets the version, and one that is not installed leaves the latest published facts."
4532
+ },
4533
+ {
4534
+ "name": "options.include",
4535
+ "type": "string[]",
4536
+ "required": false,
4537
+ "default": "[]",
4538
+ "summary": "Labels of `pending` rows that a reader on `head` also gets."
4539
+ },
4540
+ {
4541
+ "name": "options.platform",
4542
+ "type": "string",
4543
+ "required": false,
4544
+ "summary": "Platform of the reader. A row with a `platforms` condition applies only when it lists this one."
4545
+ },
4546
+ {
4547
+ "name": "options.os",
4548
+ "type": "\"macos\" | \"linux\" | \"windows\"",
4549
+ "required": false,
4550
+ "summary": "Operating system of the reader. A row with an `os` condition applies only when it lists this one."
4551
+ },
4552
+ {
4553
+ "name": "options.onRead",
4554
+ "type": "(read: { package, version, entry, id, since }) => void",
4555
+ "required": false,
4556
+ "summary": "Called synchronously once per `get`, `value` and `has` that finds the fact, and once per read of a field other than `id` on an element of `facts`. Filtering `facts` by `id` does not call it."
4557
+ }
4558
+ ],
4559
+ "returns": {
4560
+ "members": [
4561
+ {
4562
+ "name": "package",
4563
+ "type": "string"
4564
+ },
4565
+ {
4566
+ "name": "version",
4567
+ "type": "string",
4568
+ "summary": "Version of the installed fact package, from its `package.json`."
4569
+ },
4570
+ {
4571
+ "name": "entry",
4572
+ "type": "string"
4573
+ },
4574
+ {
4575
+ "name": "describes",
4576
+ "type": "Record<string, string>"
4577
+ },
4578
+ {
4579
+ "name": "publish",
4580
+ "type": "{ target: \"npm\" | \"pypi\" | \"crates\" | \"go\" | \"swift\"; name: string } | undefined",
4581
+ "summary": "The `publish` field of the index, as it is. Undefined for an index that has none."
4582
+ },
4583
+ {
4584
+ "name": "facts",
4585
+ "type": "SelectedFact[]",
4586
+ "summary": "The facts this reader sees, each flattened to its row."
4587
+ },
4588
+ {
4589
+ "name": "has",
4590
+ "type": "(id: string) => boolean"
4591
+ },
4592
+ {
4593
+ "name": "get",
4594
+ "type": "(id: string) => SelectedFact",
4595
+ "summary": "Throws when there is no such fact."
4596
+ },
4597
+ {
4598
+ "name": "value",
4599
+ "type": "<T>(id: string) => T",
4600
+ "summary": "The `content.value` of the fact. Throws when the fact has no value content."
4601
+ }
4602
+ ]
4603
+ },
4604
+ "throws": [
4605
+ "The spec is not of the form `<package>` or `<package>/<path>` (`not-found`).",
4606
+ "The package cannot be resolved from `root` (`not-found`).",
4607
+ "The resolved file is not a fact index (`not-an-index`) or has an index format of another major version than 1 and 2 (`unsupported-index-format`). Only `indexFormat` is read, and a missing one reads as `1.0`.",
4608
+ "A version is not semver (`invalid-version`).",
4609
+ "No `version` is given, and the described component is installed under `root` in a newer version than the facts describe (`describes-behind`). The component is looked up as `publish.name` when the index has `publish` with target `npm`, is not looked up when `publish` has another target, and is looked up by the `describes` key when there is no `publish`."
4610
+ ]
4611
+ }
4612
+ }
4613
+ }
4614
+ ],
4615
+ "tool": "fact-kit",
4616
+ "source": {
4617
+ "kind": "published"
4618
+ },
4619
+ "content": {
4620
+ "value": {
4621
+ "module": "fact-kit",
4622
+ "export": "readFacts",
4623
+ "signature": "readFacts(spec, options?) => FactReader",
4624
+ "parameters": [
4625
+ {
4626
+ "name": "spec",
4627
+ "type": "string",
4628
+ "required": true,
4629
+ "summary": "`<package>` or `<package>/<path>`, scoped names included, and the path may have several segments. The package must export `./index.json` or `./<path>/index.json`."
4630
+ },
4631
+ {
4632
+ "name": "options.root",
4633
+ "type": "string",
4634
+ "required": false,
4635
+ "default": "process.cwd()",
4636
+ "summary": "Directory the package is resolved from, normally the hub being built."
4637
+ },
4638
+ {
4639
+ "name": "options.version",
4640
+ "type": "string",
4641
+ "required": false,
4642
+ "default": "the installed version of the described component, else the latest published",
4643
+ "summary": "Version of the described component the reader runs, or `head` for the unreleased state. Without it, an installed described component sets the version, and one that is not installed leaves the latest published facts."
4644
+ },
4645
+ {
4646
+ "name": "options.include",
4647
+ "type": "string[]",
4648
+ "required": false,
4649
+ "default": "[]",
4650
+ "summary": "Labels of `pending` rows that a reader on `head` also gets."
4651
+ },
4652
+ {
4653
+ "name": "options.platform",
4654
+ "type": "string",
4655
+ "required": false,
4656
+ "summary": "Platform of the reader. A row with a `platforms` condition applies only when it lists this one."
3623
4657
  },
3624
4658
  {
3625
4659
  "name": "options.os",
@@ -3682,7 +4716,7 @@
3682
4716
  "throws": [
3683
4717
  "The spec is not of the form `<package>` or `<package>/<path>` (`not-found`).",
3684
4718
  "The package cannot be resolved from `root` (`not-found`).",
3685
- "The resolved file is not a fact index (`not-an-index`) or has an index format other than 1.x (`unsupported-index-format`).",
4719
+ "The resolved file is not a fact index (`not-an-index`) or has an index format of another major version than 1 and 2 (`unsupported-index-format`). Only `indexFormat` is read, and a missing one reads as `1.0`.",
3686
4720
  "A version is not semver (`invalid-version`).",
3687
4721
  "No `version` is given, and the described component is installed under `root` in a newer version than the facts describe (`describes-behind`). The component is looked up as `publish.name` when the index has `publish` with target `npm`, is not looked up when `publish` has another target, and is looked up by the `describes` key when there is no `publish`."
3688
4722
  ]
@@ -4262,390 +5296,387 @@
4262
5296
  ]
4263
5297
  }
4264
5298
  }
4265
- }
4266
- ],
4267
- "tool": "fact-kit",
4268
- "source": {
4269
- "kind": "published"
4270
- },
4271
- "content": {
4272
- "value": {
4273
- "module": "fact-kit",
4274
- "exports": [
4275
- {
4276
- "name": "defineFacts",
4277
- "signature": "defineFacts(module: FactsModule) => FactsModule",
4278
- "summary": "Identity helper that types the default export of `facts/<entry>/index.ts`."
4279
- },
4280
- {
4281
- "name": "history",
4282
- "signature": "history(...rows: HistoryRow[]) => HistoryVariants",
4283
- "summary": "Expands the rows of a fact into `variants`: `variants: history(...)`. Row fields are in `fact-kit.history-row`. Targets are JSON Pointers (RFC 6901) into the content, and `''` is the root. A row that does not fit throws an error that names the key, and `check` reports it as `history`. The result is still an array of variants, and `mf.value(name, history(...))` takes it. After each row, the check of the builder that made the content runs again, and a row that breaks it throws `BuilderError`, which `check` reports as `builder`. `remove` and `add` also work on an object by property name, such as the `properties` of an `entity`."
4284
- },
4285
- {
4286
- "name": "keyed",
4287
- "signature": "keyed<T>(items: T[], keys?: string[]) => T[]",
4288
- "summary": "Declares the fields that identify an item of an array, so `history` can `add`, `remove` and `replace` items by key. Several fields make a key written as an array in that order. Without `keys` the items are scalars and identify themselves. An array that is not keyed can only be replaced whole."
4289
- },
4290
- {
4291
- "name": "factLink",
4292
- "signature": "factLink(fact: Fact) => string",
4293
- "summary": "The location of another fact of this package, to write inside a sentence of `content`: `<id>` in the same entry, `<spec>:<id>` in another. The build adds the fact to `derivedFrom`. `relates: [fact]` adds it without text. A fact object that is not one of this package fails `check` with `relates-foreign`."
4294
- },
4295
- {
4296
- "name": "derive",
4297
- "signature": "derive(upstreamSpec: string, id: string, map?: (upstream: Fact) => Partial<Fact>) => DerivedFact",
4298
- "summary": "A fact computed from a fact of another package, listed in `facts`. The build reads the installed index of `upstreamSpec`, copies the fact `id`, lets `map` change the copy, and sets `source` to `{ kind: 'derived', from: upstreamSpec, version }` with the upstream version installed, and `derivedFrom` to `<upstreamSpec>:<id>`. The build records each upstream spec and version in `derived.lock.json`, which goes into version control. Building with another upstream version installed fails with `derive-version` until `--accept-upstream` rewrites the lock."
4299
- },
4300
- {
4301
- "name": "defineExamples",
4302
- "signature": "defineExamples(examples: ExampleGroupSource | ExampleGroupSource[]) => typeof examples",
4303
- "summary": "Identity helper that types an example file. Each group follows `fact-kit.example-group`. In `outcome` an item may also be `ref(fact)`, `ref(fact, field)` or `statementFrom(fact, render)`, which the build turns into `{ fact, field?, text? }`."
4304
- },
4305
- {
4306
- "name": "exampleFactRefs",
4307
- "signature": "exampleFactRefs(group: ExampleGroup) => { id: string; location: string; in: 'facts' | 'outcome'; field?: string }[]",
4308
- "summary": "Every fact id an example group references, with the JSON pointer where it is referenced. `in` is `facts` for `facts` of the group or of a scenario and `outcome` for a `{ fact }` item of an outcome, and `field` is the field that item names."
4309
- },
4310
- {
4311
- "name": "flattenSchema",
4312
- "signature": "flattenSchema(schema: JsonSchema) => SchemaRow[]",
4313
- "summary": "One row per field of a JSON Schema, for rendering field tables in docs and prompts. Fields of `anyOf` / `oneOf` branches are merged by name: values are the union, required when every branch requires it."
4314
- },
4315
- {
4316
- "name": "schemaRowsToMarkdown",
4317
- "signature": "schemaRowsToMarkdown(rows: SchemaRow[]) => string",
4318
- "summary": "A Markdown table of the rows, with Field, Type, Required, Description and Extensions columns."
4319
- },
4320
- {
4321
- "name": "valueListToMarkdown",
4322
- "signature": "valueListToMarkdown(fact: Fact, options?: { columns?: string[] }) => string",
4323
- "summary": "Renders a fact whose `content.value` is an array: one `- item` line per string, or a table for objects (columns default to the keys). Throws an error naming the fact id when the value is not an array."
4324
- },
4325
- {
4326
- "name": "replaceFactBlocks",
4327
- "signature": "replaceFactBlocks(text: string, blocks: Record<string, string>) => { text: string; changed: boolean }",
4328
- "summary": "Replaces the text between `<!-- facts:begin NAME -->` and `<!-- facts:end NAME -->` with `blocks[NAME]`. `changed` is false when the document is already current, which is what a `--check` exits on. Throws an error naming the block on a missing end, a repeated name, or a name the document lacks."
4329
- },
4330
- {
4331
- "name": "readFacts",
4332
- "signature": "readFacts(spec, options?) => FactReader",
4333
- "summary": "Reads an installed fact package. Parameters and members are in `fact-kit.read-facts`."
4334
- },
4335
- {
4336
- "name": "selectFacts",
4337
- "signature": "selectFacts(index, { version?, include?, platform?, os? }) => SelectedFact[]",
4338
- "summary": "The facts one reader sees in a parsed index of format 1.0 or 1.1. A pure function; `readFacts` is built on it."
4339
- },
4340
- {
4341
- "name": "factsOf",
4342
- "signature": "factsOf({ tool, source, prefix?, topics? }) => FactsFactory",
4343
- "summary": "Writes facts with the repeated fields filled in: `const mf = factsOf({ tool, source })`, then `mf.value(name, value)`, `mf.schema(name, schema)` and `mf.statement(name, text)` return a fact whose id is `<tool>.<prefix>.<name>` (`<tool>.<name>` without a prefix) and whose title is `name`. Each takes a value, a function that returns it, or the rows of `history(...)` as the second argument, and `{ title?, topics?, description?, when?, relates?, verify?, source?, note? }` as the third. The topics are those of `factsOf` and then those of the call. A fact written with one content exposes the fields of an object value as read-only getters that give a tagged copy, so the build adds the fact read to `derivedFrom`. A scalar, or a value built from scalars, carries no tag, so write it as a function (`mf.value(name, () => ...)`): every read of another fact while the function runs goes into `relates`. A fact written with `history(...)` has no getters, so read it with `contentOf`. Throws `BuilderError` for a name that is empty or starts or ends with a dot, and for rows whose first row is not the kind of the method."
4344
- },
4345
- {
4346
- "name": "observedDoc",
4347
- "signature": "observedDoc({ url: string, fetched: string }) => FactSource",
4348
- "summary": "The source `{ kind: 'observed', basis: 'doc', url, fetched }` of a fact read from a page of the documentation."
4349
- },
4350
- {
4351
- "name": "observedSpike",
4352
- "signature": "observedSpike({ fetched: string, url?: string }) => FactSource",
4353
- "summary": "The source `{ kind: 'observed', basis: 'spike', fetched }` of a fact seen in a trial run, with `url` when a page led to it."
4354
- },
4355
- {
4356
- "name": "contentOf",
4357
- "signature": "contentOf(fact: Fact, since?: string) => unknown",
4358
- "summary": "A copy of the value or the schema of one row of a fact, tagged so the build adds the fact to `derivedFrom` where the copy is embedded. A fact with several rows needs `since`, the `since` of the row to read (any one version of a row written as an array). Throws `BuilderError` when there is no such row or no content."
4359
- },
4360
- {
4361
- "name": "statementFrom",
4362
- "signature": "statementFrom(fact: Fact, render: (value) => Text, options?: { since?: string }) => BuiltStatement",
4363
- "summary": "A statement written from the content of another fact: `render` gets the copy that `contentOf` makes and returns the text. Give the result to `mf.statement` or to the `statement` of a `history` row. The fact goes into `relates`, so `derivedFrom` follows it."
4364
- },
4365
- {
4366
- "name": "subsetOf",
4367
- "signature": "subsetOf(parent: Fact, items: T[]) => T[]",
4368
- "summary": "A list that must stay inside the list of `parent`, a fact object. When the parent is a typed list (`mf.value('x', ['A', 'B'])`) the type checker rejects an item it does not have. A parent that comes from a conversion has no type, so `check` and `build` test the list again at every version boundary of the two facts and report `subset-of` with the version. The parent goes into `derivedFrom`. Throws `BuilderError` when `parent` is not a fact object."
4369
- },
4370
- {
4371
- "name": "stateMachine",
4372
- "signature": "stateMachine({ initial, states, transitions }) => StateMachine",
4373
- "summary": "A state machine as a value: `{ initial, states, transitions }`, each transition `{ from, to, event?, guard? }`. `event` is a string, or a list of strings for several events between the same two states, and `guard` is a string that holds for all of them. `states` is keyed by name and `transitions` by `from` and `to`, so a `history` row can `add`, `remove` and `replace` them by key, for example `remove: { '/states': ['blocked'] }` and `remove: { '/transitions': [['active', 'done']] }`. Give it to `mf.value`. Throws `BuilderError` when `initial`, or the `from` or `to` of a transition, is not in `states`, and `history` checks it again after every row, so a row that drops a state a transition still uses fails. `check` reports it as `builder`."
4374
- },
4375
- {
4376
- "name": "relations",
4377
- "signature": "relations({ nodes, edges }) => Relations",
4378
- "summary": "Nodes and named relations as a value: `{ nodes, edges }`, each edge `{ from, to, name, cardinality? }` with `cardinality` `'one'` or `'many'`. `nodes` is keyed by name and `edges` by `from`, `to` and `name`, for example `remove: { '/edges': [['a', 'b', 'has']] }`. Give it to `mf.value`. Throws `BuilderError` when the `from` or `to` of an edge is not in `nodes`, and `history` checks it again after every row."
4379
- },
4380
- {
4381
- "name": "sequence",
4382
- "signature": "sequence({ participants, steps }) => Sequence",
4383
- "summary": "Messages between participants as a value: `{ participants, steps }`, each step `{ from, to, action }`. `participants` is keyed by name and `steps` by `action`, which no two steps share. A `history` row can `add` steps only at the end. To insert in the middle or to rename an `action`, replace the whole list: `replace: { '/steps': keyed([...], ['action']) }`. Throws `BuilderError` when the `from` or `to` of a step is not in `participants`, and `history` checks it again after every row."
4384
- },
4385
- {
4386
- "name": "stateMachineToMermaid",
4387
- "signature": "stateMachineToMermaid(source: StateMachine | Fact) => string",
4388
- "summary": "A `stateDiagram-v2` of a state machine, without a code fence. `source` is the value or a fact whose content is that value. Each state is declared as `state \"<name>\" as s<i>` in the order of `states`, the initial state is `[*] --> s<i>`, and a transition is `s<i> --> s<j>` followed by `: <events joined by \", \"> [<guard>]` when it has either. The ids are generated, so a name with spaces or punctuation is safe, and `#`, `\"`, `;` and `|` in a name become mermaid entities."
4389
- },
4390
- {
4391
- "name": "relationsToMermaid",
4392
- "signature": "relationsToMermaid(source: Relations | Fact) => string",
4393
- "summary": "A `flowchart LR` of nodes and relations, without a code fence. Each node is declared as `n<i>[\"<name>\"]` and each edge is `n<i> -->|<name>| n<j>`. `cardinality` is not drawn. The ids are generated."
4394
- },
4395
- {
4396
- "name": "sequenceToMermaid",
4397
- "signature": "sequenceToMermaid(source: Sequence | UseCase | Fact) => string",
4398
- "summary": "A `sequenceDiagram` of a sequence, without a code fence. Each participant is declared as `participant p<i> as <name>` and each step is `p<i>->>p<j>: <action>`. The ids are generated. A use case from `useCase` is drawn too: the participants are `caller` and then each `layer` in the order of first use, and each step is a message from the layer of the step before it (`caller` for the first) to its own layer."
4399
- },
4400
- {
4401
- "name": "ref",
4402
- "signature": "ref(fact: Fact, field?: string) => FactRef",
4403
- "summary": "A reference to a fact of this package, or to a field of it written with dots such as `'limits.max'`, for the content of another fact. It returns a placeholder that the build replaces. When it is the whole value of a subschema, the build writes `{ $ref: '#/$defs/<id>' }`, or `{ $ref: '#/$defs/<id>/properties/a/properties/b' }` with a field, and puts the schema of the target into `$defs` of the root schema, flat and once per id. Anywhere else (a value, a statement, a longer string, a `const`) it writes the location of the fact, followed by `#a.b` with a field. A `$ref` inside the embedded schema that points to its own root (`#`, `#/properties/x`) is rewritten to `#/$defs/<id>` and `#/$defs/<id>/properties/x`; one into its own `$defs` or to an anchor stays. When the target has several rows, the build aligns them: the fact that writes the `ref` gets one row for each combination of its own row and the rows of the target that some reader gets together (the boundaries of `subset-of`), each with the `$defs` of that combination, so a reader reads a standard JSON Schema and changes nothing. A fact with one row becomes a fact with `variants`. The target goes into `derivedFrom`. A field the type checker knows is not in the target fails to compile. `check` reports `ref` when the field is missing from a row the two facts share, and `relates-foreign` when the target is no fact of any entry of the package. It also fits `guard` of a transition."
4404
- },
4405
- {
4406
- "name": "entity",
4407
- "signature": "entity({ identity, fields, required? }) => EntitySchema",
4408
- "summary": "An entity as a JSON Schema for `mf.schema`: `{ type: 'object', 'x-identity', properties, required? }`, with the topic `ddd:entity`. `identity` is a field name, or a list of at least two different names (a list of one is written as the name), and `fields` maps a name to a schema or to `ref(fact)`. `required` is a keyed list of names. A `history` row drops a field with `remove: { '/properties': ['status'] }`, adds one with `add: { '/properties': { note: {...} } }` and swaps one with `replace: { '/properties/status': {...} }`, and must drop the name from `required` in the same row. Throws `BuilderError` when an identity name or a `required` name is not a field, and `history` checks it again after every row, so a row that leaves one behind fails and `check` reports `builder`."
4409
- },
4410
- {
4411
- "name": "valueObject",
4412
- "signature": "valueObject(fields, options?: { required? }) => ObjectSchema",
4413
- "summary": "A value object as a JSON Schema for `mf.schema`: `{ type: 'object', properties, required? }`, with the topic `ddd:value-object`. A `history` row changes the fields by name in the same way as `entity`, and `required` follows them. Throws `BuilderError` when a `required` name is not a field."
4414
- },
4415
- {
4416
- "name": "domainEvent",
4417
- "signature": "domainEvent(fields, options?: { required? }) => ObjectSchema",
4418
- "summary": "A domain event as a JSON Schema for `mf.schema`, in the shape and with the rules of `valueObject`, with the topic `ddd:domain-event`."
4419
- },
4420
- {
4421
- "name": "aggregate",
4422
- "signature": "aggregate({ root, members }) => Aggregate",
4423
- "summary": "An aggregate as a value for `mf.value`: `{ root, members }`, each member `{ entity, cardinality }` where `cardinality` is `'one'` (the default) or `'many'`. The facts are written as `factLink` placeholders that the build replaces with their location and adds to `derivedFrom`. The topic is `ddd:aggregate`. `members` is keyed by `entity`, so a `history` row names a member by `factLink(entity)`: `remove: { '/members': [factLink(line)] }`. Throws `BuilderError` when `root` is not a fact object or a cardinality is not `'one'` or `'many'`, and `HistoryError` for two members of one entity."
4424
- },
4425
- {
4426
- "name": "invariant",
4427
- "signature": "invariant(subject: Fact, text: Text) => BuiltStatement",
4428
- "summary": "A business rule about an entity or value, for `mf.statement` or the `statement` of a `history` row. It carries the text, and `subject` goes into `relates` so `derivedFrom` follows it. The topic is `ddd:invariant`. A later `history` row rewrites the sentence whole with `statement: invariant(...)`, which also carries the new subject. `set: { '': text }` replaces the sentence but not `relates`. Throws `BuilderError` when `subject` is not a fact object or `text` is empty."
4429
- },
4430
- {
4431
- "name": "useCase",
4432
- "signature": "useCase({ input?, output?, steps, errors? }) => UseCase",
4433
- "summary": "An application use case as a value for `mf.value`: `{ input?, output?, steps, errors }`. `input` and `output` are `ref(fact)` or a schema. A step is `{ layer, action, rule?, emits?, calls? }` where `layer` is `'application'`, `'domain'` or `'infrastructure'` and the facts in `rule`, `emits` and `calls` become `factLink` placeholders. The topic is `ddd:use-case`. `steps` is keyed by `action`, which no two steps share, and a `history` row can `add` steps only at the end, so to insert in the middle replace the whole list. `errors` is a keyed list of codes. `sequenceToMermaid` draws it. Throws `BuilderError` for a layer that is not one of the three or an empty action, and `HistoryError` for a repeated action or code."
4434
- },
4435
- {
4436
- "name": "writeFormatted",
4437
- "signature": "writeFormatted(file: string, text: string) => Promise<void>",
4438
- "summary": "Writes `text` to `file` formatted with the prettier settings that `resolveConfig(file)` finds (none when there is no config), so a rerun gives the same bytes. Creates the parent directories. `prettier` is an optional peer dependency that is loaded when the function runs, and a missing package throws an error that names what to install: `pnpm add -D prettier@3`."
4439
- },
4440
- {
4441
- "name": "stableJson",
4442
- "signature": "stableJson(value: unknown) => string",
4443
- "summary": "JSON with two-space indent and the keys of every object in code-unit order, for generated files. Arrays keep their order. There is no trailing newline."
4444
- },
4445
- {
4446
- "name": "DRAFT_2020_12",
4447
- "signature": "const DRAFT_2020_12: 'https://json-schema.org/draft/2020-12/schema'",
4448
- "summary": "The `$schema` URL of JSON Schema 2020-12. It is the value `interfaceToJsonSchema` and `normalizeSchema` put in `$schema`."
4449
- },
4450
- {
4451
- "name": "NormalizeOptions",
4452
- "signature": "interface NormalizeOptions { describe?, drop?, notes? }",
4453
- "summary": "The options of `normalizeSchema`. `describe(text) => string` is called for each `description` and returns the text to keep. `drop` lists keywords to remove at any depth. `notes` is a `Map<string, number>` that counts what was dropped or rewritten, for the converter report. A type, exported with `export type`."
4454
- },
4455
- {
4456
- "name": "normalizeSchema",
4457
- "signature": "normalizeSchema(input: JsonSchema, options?: NormalizeOptions) => JsonSchema",
4458
- "summary": "Rewrites a JSON Schema from another dialect (draft-07, OpenAPI 3.0) to 2020-12, only where a schema is expected, so a property named `items` or `deprecated` is left alone. `definitions` becomes `$defs` and `#/definitions/` references follow. A tuple `items: [...]` becomes `prefixItems` and `additionalItems` becomes `items`. A string `deprecated` becomes `true` and its message is appended to `description` as `Deprecated: <message>`. `nullable: true` adds `null` to `type`. `dependencies` splits into `dependentRequired` and `dependentSchemas`. `x-` keywords that fact-kit does not register (`X_KEYWORDS`), `$id`, `id` and the keywords in `drop` are removed. The result starts with `$schema` set to `DRAFT_2020_12`."
4459
- },
4460
- {
4461
- "name": "PinnedSource",
4462
- "signature": "interface PinnedSource { repo, commit, path, sha256, license }",
4463
- "summary": "An upstream file pinned to a commit: `repo` is `owner/name`, `commit` is the full SHA, `path` is the file in the repository, `sha256` is the hex digest of its bytes and `license` is an SPDX id. A type, exported with `export type`."
4464
- },
4465
- {
4466
- "name": "sourceUrl",
4467
- "signature": "sourceUrl(source: PinnedSource) => string",
4468
- "summary": "The GitHub page of the pinned file at its commit (`blob/<commit>/<path>` of the repository), where a reader opens it."
4469
- },
4470
- {
4471
- "name": "readPinned",
4472
- "signature": "readPinned(source: PinnedSource, options: { cacheDir: string }) => Promise<string>",
4473
- "summary": "The text of the pinned file. Reads `<cacheDir>/<sha256>.txt` when it exists, otherwise downloads the file at that commit from the raw-content address of GitHub, checks the sha256 and writes the cache. `cacheDir` is required, so the cache place does not depend on the working directory. Throws `<repo>/<path>: sha256 is <actual>, expected <sha256>` when the bytes do not match, also for a cached file, and `<url>: HTTP <status>` when the download fails."
4474
- }
4475
- ],
4476
- "schemaRow": [
4477
- {
4478
- "name": "path",
4479
- "type": "string",
4480
- "summary": "`a.b` for a property, `a[]` for array items, `a.*` for additional properties."
4481
- },
4482
- {
4483
- "name": "type",
4484
- "type": "string",
4485
- "summary": "Empty when the schema says nothing."
4486
- },
4487
- {
4488
- "name": "required",
4489
- "type": "boolean"
4490
- },
4491
- {
4492
- "name": "description",
4493
- "type": "string"
4494
- },
4495
- {
4496
- "name": "values",
4497
- "type": "unknown[]",
4498
- "summary": "Present only when the field lists `enum` or `const` values, merged over `anyOf` / `oneOf` branches."
4499
- },
4500
- {
4501
- "name": "extensions",
4502
- "type": "Record<string, unknown>",
4503
- "summary": "The `x-` keywords of the field."
4504
- },
4505
- {
4506
- "name": "requiredWhen",
4507
- "type": "{ path: string; values: unknown[] }",
4508
- "summary": "Present when only some branches require the field and the branches are told apart by a `const` property: required when that property takes one of `values`."
4509
- }
4510
- ]
4511
- }
4512
- }
4513
- },
4514
- {
4515
- "id": "fact-kit.converters",
4516
- "topics": [
4517
- "convert",
4518
- "authoring"
4519
- ],
4520
- "title": {
4521
- "en": "Converters and the optional TypeScript peer dependency"
4522
- },
4523
- "description": {
4524
- "en": "The converters read TypeScript with the TypeScript 7.1 API, which starts a native compiler process. `typescript` is an optional peer dependency that is loaded when a converter runs, and a converter throws an error that names the package to install when it is missing. `writeFormatted` loads the optional peer dependency `prettier` the same way."
4525
- },
4526
- "variants": [
5299
+ },
4527
5300
  {
4528
- "since": "0.0.0",
5301
+ "since": "0.12.0-alpha.1",
4529
5302
  "content": {
4530
5303
  "value": {
4531
- "requires": {
4532
- "peerDependency": "typescript",
4533
- "range": ">=7.1.0-beta",
4534
- "optional": true,
4535
- "install": "pnpm add -D typescript@7.1.0-beta"
4536
- },
5304
+ "module": "fact-kit",
4537
5305
  "exports": [
4538
5306
  {
4539
- "name": "readStringTuples",
4540
- "signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
4541
- "summary": "The string literal tuples exported by a TypeScript source, by name: `export declare const X: readonly [...]` and `export const X = [...] as const`. Parses only, so imports do not have to resolve."
5307
+ "name": "defineFacts",
5308
+ "signature": "defineFacts(module: FactsModule) => FactsModule",
5309
+ "summary": "Identity helper that types the default export of `facts/<entry>/index.ts`."
4542
5310
  },
4543
5311
  {
4544
- "name": "readStringTuplesFromFile",
4545
- "signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
4546
- "summary": "Reads the file and returns `readStringTuples` of it."
5312
+ "name": "history",
5313
+ "signature": "history(...rows: HistoryRow[]) => HistoryVariants",
5314
+ "summary": "Expands the rows of a fact into `variants`: `variants: history(...)`. Row fields are in `fact-kit.history-row`. Targets are JSON Pointers (RFC 6901) into the content, and `''` is the root. A row that does not fit throws an error that names the key, and `check` reports it as `history`. The result is still an array of variants, and `mf.value(name, history(...))` takes it. After each row, the check of the builder that made the content runs again, and a row that breaks it throws `BuilderError`, which `check` reports as `builder`. `remove` and `add` also work on an object by property name, such as the `properties` of an `entity`."
4547
5315
  },
4548
5316
  {
4549
- "name": "interfaceToJsonSchema",
4550
- "signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
4551
- "summary": "An interface or type alias as a JSON Schema 2020-12 document. Referenced types become `$defs`. Union members and enum values keep the order of the source, `0 | number` keeps both members, and a tuple becomes `prefixItems`. JSDoc becomes `description`, and `descriptions: false` removes every `description`. Type errors in the input are not reported."
5317
+ "name": "keyed",
5318
+ "signature": "keyed<T>(items: T[], keys?: string[]) => T[]",
5319
+ "summary": "Declares the fields that identify an item of an array, so `history` can `add`, `remove` and `replace` items by key. Several fields make a key written as an array in that order. Without `keys` the items are scalars and identify themselves. An array that is not keyed can only be replaced whole."
4552
5320
  },
4553
5321
  {
4554
- "name": "readJsonSchemaFile",
4555
- "signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
4556
- "summary": "Reads a JSON Schema file. Does not need TypeScript."
4557
- }
4558
- ]
4559
- }
4560
- }
4561
- },
4562
- {
4563
- "since": "0.10.0-alpha.1",
4564
- "content": {
4565
- "value": {
4566
- "requires": {
4567
- "peerDependency": "typescript",
4568
- "range": ">=7.1.0-beta",
4569
- "optional": true,
4570
- "install": "pnpm add -D typescript@7.1.0-beta"
4571
- },
4572
- "exports": [
5322
+ "name": "factLink",
5323
+ "signature": "factLink(fact: Fact) => string",
5324
+ "summary": "The location of another fact of this package, to write inside a sentence of `content`: `<id>` in the same entry, `<spec>:<id>` in another. The build adds the fact to `derivedFrom`. `relates: [fact]` adds it without text. A fact object that is not one of this package fails `check` with `relates-foreign`."
5325
+ },
4573
5326
  {
4574
- "name": "readStringTuples",
4575
- "signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
4576
- "summary": "The string literal tuples exported by a TypeScript source, by name: `export declare const X: readonly [...]` and `export const X = [...] as const`. Parses only, so imports do not have to resolve."
5327
+ "name": "derive",
5328
+ "signature": "derive(upstreamSpec: string, id: string, map?: (upstream: Fact) => Partial<Fact>) => DerivedFact",
5329
+ "summary": "A fact computed from a fact of another package, listed in `facts`. The build reads the installed index of `upstreamSpec`, copies the fact `id`, lets `map` change the copy, and sets `source` to `{ kind: 'derived', from: upstreamSpec, version }` with the upstream version installed, and `derivedFrom` to `<upstreamSpec>:<id>`. The build records each upstream spec and version in `derived.lock.json`, which goes into version control. Building with another upstream version installed fails with `derive-version` until `--accept-upstream` rewrites the lock."
4577
5330
  },
4578
5331
  {
4579
- "name": "readStringTuplesFromFile",
4580
- "signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
4581
- "summary": "Reads the file and returns `readStringTuples` of it."
5332
+ "name": "defineExamples",
5333
+ "signature": "defineExamples(examples: ExampleGroupSource | ExampleGroupSource[]) => typeof examples",
5334
+ "summary": "Identity helper that types an example file. Each group follows `fact-kit.example-group`. In `outcome` an item may also be `ref(fact)`, `ref(fact, field)` or `statementFrom(fact, render)`, which the build turns into `{ fact, field?, text? }`."
4582
5335
  },
4583
5336
  {
4584
- "name": "interfaceToJsonSchema",
4585
- "signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
4586
- "summary": "An interface or type alias as a JSON Schema 2020-12 document. Referenced types become `$defs`. Union members and enum values keep the order of the source, `0 | number` keeps both members, and a tuple becomes `prefixItems`. JSDoc becomes `description`, and `descriptions: false` removes every `description`. Type errors in the input are not reported."
5337
+ "name": "exampleFactRefs",
5338
+ "signature": "exampleFactRefs(group: ExampleGroup) => { id: string; location: string; in: 'facts' | 'outcome'; field?: string }[]",
5339
+ "summary": "Every fact id an example group references, with the JSON pointer where it is referenced. `in` is `facts` for `facts` of the group or of a scenario and `outcome` for a `{ fact }` item of an outcome, and `field` is the field that item names."
4587
5340
  },
4588
5341
  {
4589
- "name": "readJsonSchemaFile",
4590
- "signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
4591
- "summary": "Reads a JSON Schema file. Does not need TypeScript."
4592
- }
4593
- ],
4594
- "optionalPeers": [
5342
+ "name": "flattenSchema",
5343
+ "signature": "flattenSchema(schema: JsonSchema) => SchemaRow[]",
5344
+ "summary": "One row per field of a JSON Schema, for rendering field tables in docs and prompts. Fields of `anyOf` / `oneOf` branches are merged by name: values are the union, required when every branch requires it."
5345
+ },
4595
5346
  {
4596
- "peerDependency": "prettier",
4597
- "range": ">=3.0.0",
4598
- "install": "pnpm add -D prettier@3",
4599
- "usedBy": [
4600
- "writeFormatted"
4601
- ]
4602
- }
4603
- ]
4604
- }
4605
- }
4606
- },
4607
- {
4608
- "since": "0.11.1-alpha.1",
4609
- "content": {
4610
- "value": {
4611
- "requires": {
4612
- "peerDependency": "typescript",
4613
- "range": ">=7.1.0-beta",
4614
- "optional": true,
4615
- "install": "pnpm add -D typescript@7.1.0-beta"
4616
- },
4617
- "exports": [
5347
+ "name": "schemaRowsToMarkdown",
5348
+ "signature": "schemaRowsToMarkdown(rows: SchemaRow[]) => string",
5349
+ "summary": "A Markdown table of the rows, with Field, Type, Required, Description and Extensions columns."
5350
+ },
4618
5351
  {
4619
- "name": "readStringTuples",
4620
- "signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
4621
- "summary": "The string literal tuples exported by a TypeScript source, by name: `export declare const X: readonly [...]` and `export const X = [...] as const`. Parses only, so imports do not have to resolve."
5352
+ "name": "valueListToMarkdown",
5353
+ "signature": "valueListToMarkdown(fact: Fact, options?: { columns?: string[] }) => string",
5354
+ "summary": "Renders a fact whose `content.value` is an array: one `- item` line per string, or a table for objects (columns default to the keys). Throws an error naming the fact id when the value is not an array."
4622
5355
  },
4623
5356
  {
4624
- "name": "readStringTuplesFromFile",
4625
- "signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
4626
- "summary": "Reads the file and returns `readStringTuples` of it."
5357
+ "name": "replaceFactBlocks",
5358
+ "signature": "replaceFactBlocks(text: string, blocks: Record<string, string>) => { text: string; changed: boolean }",
5359
+ "summary": "Replaces the text between `<!-- facts:begin NAME -->` and `<!-- facts:end NAME -->` with `blocks[NAME]`. `changed` is false when the document is already current, which is what a `--check` exits on. Throws an error naming the block on a missing end, a repeated name, or a name the document lacks."
4627
5360
  },
4628
5361
  {
4629
- "name": "interfaceToJsonSchema",
4630
- "signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
4631
- "summary": "An interface or type alias as a JSON Schema 2020-12 document. A named interface or alias becomes a `$defs` entry, and a generic instantiation such as `Record<string, unknown>` is written in place. A type that refers to itself is a `$defs` entry that every place it appears references with `$ref`, an instantiation such as `Tree<string>` included. An instantiation is named as TypeScript prints it, such as `Tree<string>`, and a root type that refers to itself is also written out at the top. A generic type that makes a new instantiation at each level, such as `next?: Nest<Box<T>>` inside `Nest<T>`, throws an error that names it. A method is left out, and a property whose type is a function becomes `{ \"$comment\": \"<signature>\" }` with the signature as TypeScript prints it, such as `(n: number) => string`. Union members and enum values keep the order of the source, `0 | number` keeps both members, and a tuple becomes `prefixItems`. JSDoc becomes `description`, and `descriptions: false` removes every `description`. Type errors in the input are not reported. An error thrown while converting is not replaced by an error from closing the compiler process."
5362
+ "name": "readFacts",
5363
+ "signature": "readFacts(spec, options?) => FactReader",
5364
+ "summary": "Reads an installed fact package. Parameters and members are in `fact-kit.read-facts`."
4632
5365
  },
4633
5366
  {
4634
- "name": "readJsonSchemaFile",
4635
- "signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
4636
- "summary": "Reads a JSON Schema file. Does not need TypeScript."
5367
+ "name": "selectFacts",
5368
+ "signature": "selectFacts(index, { version?, include?, platform?, os? }) => SelectedFact[]",
5369
+ "summary": "The facts one reader sees in a parsed index of format 1.0 or 1.1. A pure function; `readFacts` is built on it."
5370
+ },
5371
+ {
5372
+ "name": "factsOf",
5373
+ "signature": "factsOf({ tool, source, prefix?, topics? }) => FactsFactory",
5374
+ "summary": "Writes facts with the repeated fields filled in: `const mf = factsOf({ tool, source })`, then `mf.value(name, value)`, `mf.schema(name, schema)` and `mf.statement(name, text)` return a fact whose id is `<tool>.<prefix>.<name>` (`<tool>.<name>` without a prefix) and whose title is `name`. Each takes a value, a function that returns it, or the rows of `history(...)` as the second argument, and `{ title?, topics?, description?, when?, relates?, verify?, source?, note? }` as the third. The topics are those of `factsOf` and then those of the call. A fact written with one content exposes the fields of an object value as read-only getters that give a tagged copy, so the build adds the fact read to `derivedFrom`. A scalar, or a value built from scalars, carries no tag, so write it as a function (`mf.value(name, () => ...)`): every read of another fact while the function runs goes into `relates`. A fact written with `history(...)` has no getters, so read it with `contentOf`. Throws `BuilderError` for a name that is empty or starts or ends with a dot, and for rows whose first row is not the kind of the method."
5375
+ },
5376
+ {
5377
+ "name": "observedDoc",
5378
+ "signature": "observedDoc({ url: string, fetched: string }) => FactSource",
5379
+ "summary": "The source `{ kind: 'observed', basis: 'doc', url, fetched }` of a fact read from a page of the documentation."
5380
+ },
5381
+ {
5382
+ "name": "observedSpike",
5383
+ "signature": "observedSpike({ fetched: string, url?: string }) => FactSource",
5384
+ "summary": "The source `{ kind: 'observed', basis: 'spike', fetched }` of a fact seen in a trial run, with `url` when a page led to it."
5385
+ },
5386
+ {
5387
+ "name": "contentOf",
5388
+ "signature": "contentOf(fact: Fact, since?: string) => unknown",
5389
+ "summary": "A copy of the value or the schema of one row of a fact, tagged so the build adds the fact to `derivedFrom` where the copy is embedded. A fact with several rows needs `since`, the `since` of the row to read (any one version of a row written as an array). Throws `BuilderError` when there is no such row or no content."
5390
+ },
5391
+ {
5392
+ "name": "statementFrom",
5393
+ "signature": "statementFrom(fact: Fact, render: (value) => Text, options?: { since?: string }) => BuiltStatement",
5394
+ "summary": "A statement written from the content of another fact: `render` gets the copy that `contentOf` makes and returns the text. Give the result to `mf.statement` or to the `statement` of a `history` row. The fact goes into `relates`, so `derivedFrom` follows it."
5395
+ },
5396
+ {
5397
+ "name": "subsetOf",
5398
+ "signature": "subsetOf(parent: Fact, items: T[]) => T[]",
5399
+ "summary": "A list that must stay inside the list of `parent`, a fact object. When the parent is a typed list (`mf.value('x', ['A', 'B'])`) the type checker rejects an item it does not have. A parent that comes from a conversion has no type, so `check` and `build` test the list again at every version boundary of the two facts and report `subset-of` with the version. The parent goes into `derivedFrom`. Throws `BuilderError` when `parent` is not a fact object."
5400
+ },
5401
+ {
5402
+ "name": "stateMachine",
5403
+ "signature": "stateMachine({ initial, states, transitions }) => StateMachine",
5404
+ "summary": "A state machine as a value: `{ initial, states, transitions }`, each transition `{ from, to, event?, guard? }`. `event` is a string, or a list of strings for several events between the same two states, and `guard` is a string that holds for all of them. `states` is keyed by name and `transitions` by `from` and `to`, so a `history` row can `add`, `remove` and `replace` them by key, for example `remove: { '/states': ['blocked'] }` and `remove: { '/transitions': [['active', 'done']] }`. Give it to `mf.value`. Throws `BuilderError` when `initial`, or the `from` or `to` of a transition, is not in `states`, and `history` checks it again after every row, so a row that drops a state a transition still uses fails. `check` reports it as `builder`."
5405
+ },
5406
+ {
5407
+ "name": "relations",
5408
+ "signature": "relations({ nodes, edges }) => Relations",
5409
+ "summary": "Nodes and named relations as a value: `{ nodes, edges }`, each edge `{ from, to, name, cardinality? }` with `cardinality` `'one'` or `'many'`. `nodes` is keyed by name and `edges` by `from`, `to` and `name`, for example `remove: { '/edges': [['a', 'b', 'has']] }`. Give it to `mf.value`. Throws `BuilderError` when the `from` or `to` of an edge is not in `nodes`, and `history` checks it again after every row."
5410
+ },
5411
+ {
5412
+ "name": "sequence",
5413
+ "signature": "sequence({ participants, steps }) => Sequence",
5414
+ "summary": "Messages between participants as a value: `{ participants, steps }`, each step `{ from, to, action }`. `participants` is keyed by name and `steps` by `action`, which no two steps share. A `history` row can `add` steps only at the end. To insert in the middle or to rename an `action`, replace the whole list: `replace: { '/steps': keyed([...], ['action']) }`. Throws `BuilderError` when the `from` or `to` of a step is not in `participants`, and `history` checks it again after every row."
5415
+ },
5416
+ {
5417
+ "name": "stateMachineToMermaid",
5418
+ "signature": "stateMachineToMermaid(source: StateMachine | Fact) => string",
5419
+ "summary": "A `stateDiagram-v2` of a state machine, without a code fence. `source` is the value or a fact whose content is that value. Each state is declared as `state \"<name>\" as s<i>` in the order of `states`, the initial state is `[*] --> s<i>`, and a transition is `s<i> --> s<j>` followed by `: <events joined by \", \"> [<guard>]` when it has either. The ids are generated, so a name with spaces or punctuation is safe, and `#`, `\"`, `;` and `|` in a name become mermaid entities."
5420
+ },
5421
+ {
5422
+ "name": "relationsToMermaid",
5423
+ "signature": "relationsToMermaid(source: Relations | Fact) => string",
5424
+ "summary": "A `flowchart LR` of nodes and relations, without a code fence. Each node is declared as `n<i>[\"<name>\"]` and each edge is `n<i> -->|<name>| n<j>`. `cardinality` is not drawn. The ids are generated."
5425
+ },
5426
+ {
5427
+ "name": "sequenceToMermaid",
5428
+ "signature": "sequenceToMermaid(source: Sequence | UseCase | Fact) => string",
5429
+ "summary": "A `sequenceDiagram` of a sequence, without a code fence. Each participant is declared as `participant p<i> as <name>` and each step is `p<i>->>p<j>: <action>`. The ids are generated. A use case from `useCase` is drawn too: the participants are `caller` and then each `layer` in the order of first use, and each step is a message from the layer of the step before it (`caller` for the first) to its own layer."
5430
+ },
5431
+ {
5432
+ "name": "ref",
5433
+ "signature": "ref(fact: Fact, field?: string) => FactRef",
5434
+ "summary": "A reference to a fact of this package, or to a field of it written with dots such as `'limits.max'`, for the content of another fact. It returns a placeholder that the build replaces. When it is the whole value of a subschema, the build writes `{ $ref: '#/$defs/<id>' }`, or `{ $ref: '#/$defs/<id>/properties/a/properties/b' }` with a field, and puts the schema of the target into `$defs` of the root schema, flat and once per id. Anywhere else (a value, a statement, a longer string, a `const`) it writes the location of the fact, followed by `#a.b` with a field. A `$ref` inside the embedded schema that points to its own root (`#`, `#/properties/x`) is rewritten to `#/$defs/<id>` and `#/$defs/<id>/properties/x`; one into its own `$defs` or to an anchor stays. When the target has several rows, the build aligns them: the fact that writes the `ref` gets one row for each combination of its own row and the rows of the target that some reader gets together (the boundaries of `subset-of`), each with the `$defs` of that combination, so a reader reads a standard JSON Schema and changes nothing. A fact with one row becomes a fact with `variants`. The target goes into `derivedFrom`. A field the type checker knows is not in the target fails to compile. `check` reports `ref` when the field is missing from a row the two facts share, and `relates-foreign` when the target is no fact of any entry of the package. It also fits `guard` of a transition."
5435
+ },
5436
+ {
5437
+ "name": "entity",
5438
+ "signature": "entity({ identity, fields, required? }) => EntitySchema",
5439
+ "summary": "An entity as a JSON Schema for `mf.schema`: `{ type: 'object', 'x-identity', properties, required? }`, with the topic `ddd:entity`. `identity` is a field name, or a list of at least two different names (a list of one is written as the name), and `fields` maps a name to a schema or to `ref(fact)`. `required` is a keyed list of names. A `history` row drops a field with `remove: { '/properties': ['status'] }`, adds one with `add: { '/properties': { note: {...} } }` and swaps one with `replace: { '/properties/status': {...} }`, and must drop the name from `required` in the same row. Throws `BuilderError` when an identity name or a `required` name is not a field, and `history` checks it again after every row, so a row that leaves one behind fails and `check` reports `builder`."
5440
+ },
5441
+ {
5442
+ "name": "valueObject",
5443
+ "signature": "valueObject(fields, options?: { required? }) => ObjectSchema",
5444
+ "summary": "A value object as a JSON Schema for `mf.schema`: `{ type: 'object', properties, required? }`, with the topic `ddd:value-object`. A `history` row changes the fields by name in the same way as `entity`, and `required` follows them. Throws `BuilderError` when a `required` name is not a field."
5445
+ },
5446
+ {
5447
+ "name": "domainEvent",
5448
+ "signature": "domainEvent(fields, options?: { required? }) => ObjectSchema",
5449
+ "summary": "A domain event as a JSON Schema for `mf.schema`, in the shape and with the rules of `valueObject`, with the topic `ddd:domain-event`."
5450
+ },
5451
+ {
5452
+ "name": "aggregate",
5453
+ "signature": "aggregate({ root, members }) => Aggregate",
5454
+ "summary": "An aggregate as a value for `mf.value`: `{ root, members }`, each member `{ entity, cardinality }` where `cardinality` is `'one'` (the default) or `'many'`. The facts are written as `factLink` placeholders that the build replaces with their location and adds to `derivedFrom`. The topic is `ddd:aggregate`. `members` is keyed by `entity`, so a `history` row names a member by `factLink(entity)`: `remove: { '/members': [factLink(line)] }`. Throws `BuilderError` when `root` is not a fact object or a cardinality is not `'one'` or `'many'`, and `HistoryError` for two members of one entity."
5455
+ },
5456
+ {
5457
+ "name": "invariant",
5458
+ "signature": "invariant(subject: Fact, text: Text) => BuiltStatement",
5459
+ "summary": "A business rule about an entity or value, for `mf.statement` or the `statement` of a `history` row. It carries the text, and `subject` goes into `relates` so `derivedFrom` follows it. The topic is `ddd:invariant`. A later `history` row rewrites the sentence whole with `statement: invariant(...)`, which also carries the new subject. `set: { '': text }` replaces the sentence but not `relates`. Throws `BuilderError` when `subject` is not a fact object or `text` is empty."
5460
+ },
5461
+ {
5462
+ "name": "useCase",
5463
+ "signature": "useCase({ input?, output?, steps, errors? }) => UseCase",
5464
+ "summary": "An application use case as a value for `mf.value`: `{ input?, output?, steps, errors }`. `input` and `output` are `ref(fact)` or a schema. A step is `{ layer, action, rule?, emits?, calls? }` where `layer` is `'application'`, `'domain'` or `'infrastructure'` and the facts in `rule`, `emits` and `calls` become `factLink` placeholders. The topic is `ddd:use-case`. `steps` is keyed by `action`, which no two steps share, and a `history` row can `add` steps only at the end, so to insert in the middle replace the whole list. `errors` is a keyed list of codes. `sequenceToMermaid` draws it. Throws `BuilderError` for a layer that is not one of the three or an empty action, and `HistoryError` for a repeated action or code."
5465
+ },
5466
+ {
5467
+ "name": "writeFormatted",
5468
+ "signature": "writeFormatted(file: string, text: string) => Promise<void>",
5469
+ "summary": "Writes `text` to `file` formatted with the prettier settings that `resolveConfig(file)` finds (none when there is no config), so a rerun gives the same bytes. Creates the parent directories. `prettier` is an optional peer dependency that is loaded when the function runs, and a missing package throws an error that names what to install: `pnpm add -D prettier@3`."
5470
+ },
5471
+ {
5472
+ "name": "stableJson",
5473
+ "signature": "stableJson(value: unknown) => string",
5474
+ "summary": "JSON with two-space indent and the keys of every object in code-unit order, for generated files. Arrays keep their order. There is no trailing newline."
5475
+ },
5476
+ {
5477
+ "name": "DRAFT_2020_12",
5478
+ "signature": "const DRAFT_2020_12: 'https://json-schema.org/draft/2020-12/schema'",
5479
+ "summary": "The `$schema` URL of JSON Schema 2020-12. It is the value `interfaceToJsonSchema` and `normalizeSchema` put in `$schema`."
5480
+ },
5481
+ {
5482
+ "name": "NormalizeOptions",
5483
+ "signature": "interface NormalizeOptions { describe?, drop?, notes? }",
5484
+ "summary": "The options of `normalizeSchema`. `describe(text) => string` is called for each `description` and returns the text to keep. `drop` lists keywords to remove at any depth. `notes` is a `Map<string, number>` that counts what was dropped or rewritten, for the converter report. A type, exported with `export type`."
5485
+ },
5486
+ {
5487
+ "name": "normalizeSchema",
5488
+ "signature": "normalizeSchema(input: JsonSchema, options?: NormalizeOptions) => JsonSchema",
5489
+ "summary": "Rewrites a JSON Schema from another dialect (draft-07, OpenAPI 3.0) to 2020-12, only where a schema is expected, so a property named `items` or `deprecated` is left alone. `definitions` becomes `$defs` and `#/definitions/` references follow. A tuple `items: [...]` becomes `prefixItems` and `additionalItems` becomes `items`. A string `deprecated` becomes `true` and its message is appended to `description` as `Deprecated: <message>`. `nullable: true` adds `null` to `type`. `dependencies` splits into `dependentRequired` and `dependentSchemas`. `x-` keywords that fact-kit does not register (`X_KEYWORDS`), `$id`, `id` and the keywords in `drop` are removed. The result starts with `$schema` set to `DRAFT_2020_12`."
5490
+ },
5491
+ {
5492
+ "name": "PinnedSource",
5493
+ "signature": "interface PinnedSource { repo, commit, path, sha256, license }",
5494
+ "summary": "An upstream file pinned to a commit: `repo` is `owner/name`, `commit` is the full SHA, `path` is the file in the repository, `sha256` is the hex digest of its bytes and `license` is an SPDX id. A type, exported with `export type`."
5495
+ },
5496
+ {
5497
+ "name": "sourceUrl",
5498
+ "signature": "sourceUrl(source: PinnedSource) => string",
5499
+ "summary": "The GitHub page of the pinned file at its commit (`blob/<commit>/<path>` of the repository), where a reader opens it."
5500
+ },
5501
+ {
5502
+ "name": "readPinned",
5503
+ "signature": "readPinned(source: PinnedSource, options: { cacheDir: string }) => Promise<string>",
5504
+ "summary": "The text of the pinned file. Reads `<cacheDir>/<sha256>.txt` when it exists, otherwise downloads the file at that commit from the raw-content address of GitHub, checks the sha256 and writes the cache. `cacheDir` is required, so the cache place does not depend on the working directory. Throws `<repo>/<path>: sha256 is <actual>, expected <sha256>` when the bytes do not match, also for a cached file, and `<url>: HTTP <status>` when the download fails."
5505
+ },
5506
+ {
5507
+ "name": "registerBuilderCheck",
5508
+ "kind": "function",
5509
+ "signature": "registerBuilderCheck(name: string, check: BuilderCheck, about?: BuilderAbout) => void",
5510
+ "summary": "Registers the check of a builder: `check(root)` returns a message that names the key at fault, or undefined. `history` runs it again after every row of a fact whose content carries the mark of that builder. `about` gives the kind of content the builder makes and the topic `mf.*` adds."
5511
+ },
5512
+ {
5513
+ "name": "setMark",
5514
+ "kind": "function",
5515
+ "signature": "setMark(target: object, mark: symbol, value: unknown) => void",
5516
+ "summary": "Puts a tag on `target` as a non-enumerable property under the symbol `mark`, so it is not written to the index."
5517
+ },
5518
+ {
5519
+ "name": "makeBuilt",
5520
+ "kind": "function",
5521
+ "signature": "makeBuilt(text: unknown, relates: readonly object[], builder?: string) => BuiltStatement",
5522
+ "summary": "A statement a builder made: the text plus the fact objects it relates to. With `builder`, it carries the `BUILDER` mark of that name."
5523
+ },
5524
+ {
5525
+ "name": "isText",
5526
+ "kind": "function",
5527
+ "signature": "isText(value: unknown) => boolean",
5528
+ "summary": "True for a non-empty string, or an object with at least one language."
5529
+ },
5530
+ {
5531
+ "name": "isObject",
5532
+ "kind": "function",
5533
+ "signature": "isObject(value: unknown) => value is Record<string, unknown>",
5534
+ "summary": "True for an object that is not null and not an array."
5535
+ },
5536
+ {
5537
+ "name": "parseVersion",
5538
+ "kind": "function",
5539
+ "signature": "parseVersion(text: string) => Semver | undefined",
5540
+ "summary": "Parses a semver 2.0.0 version into `{ major, minor, patch, pre }`, or returns undefined. Build metadata is accepted and ignored."
5541
+ },
5542
+ {
5543
+ "name": "mustParse",
5544
+ "kind": "function",
5545
+ "signature": "mustParse(text: string, what: string) => Semver",
5546
+ "summary": "Like `parseVersion`, and throws `FactReadError` with code `invalid-version` that names `what` when the text is not semver."
5547
+ },
5548
+ {
5549
+ "name": "compareSemver",
5550
+ "kind": "function",
5551
+ "signature": "compareSemver(a: Semver, b: Semver) => -1 | 0 | 1",
5552
+ "summary": "The semver 2.0.0 precedence of `a` against `b`, a pre-release below its release."
5553
+ },
5554
+ {
5555
+ "name": "sinceIssue",
5556
+ "kind": "function",
5557
+ "signature": "sinceIssue(since: Since) => SinceIssue | undefined",
5558
+ "summary": "Why a `since` is not one of the three allowed forms (`since-format`) or has two versions on one release line (`same-line`), or undefined when it is fine."
5559
+ },
5560
+ {
5561
+ "name": "findRows",
5562
+ "kind": "function",
5563
+ "signature": "findRows(program: unknown, options?: { dataKeys?: readonly string[] }) => SinceRow[]",
5564
+ "summary": "Every object with a `since` in a parsed program, in source order, each with the position of the `since` text and whether it has a `pending` label. Fact content is not searched. `options.dataKeys` is described in `fact-kit.row-data-keys`."
5565
+ },
5566
+ {
5567
+ "name": "applyEdits",
5568
+ "kind": "function",
5569
+ "signature": "applyEdits(source: string, edits: readonly Edit[]) => string",
5570
+ "summary": "Applies text edits `{ start, end, text }` that do not overlap, from the last to the first, so the offsets stay right."
5571
+ },
5572
+ {
5573
+ "name": "splitSpec",
5574
+ "kind": "function",
5575
+ "signature": "splitSpec(spec: string) => { packageName: string; entry: string }",
5576
+ "summary": "Splits `@scope/name/path` or `name/path` into the package name and the sub-path, which is empty when the spec names only the package. Throws `FactReadError` with code `not-found` for a spec that is not of that form."
5577
+ },
5578
+ {
5579
+ "name": "loadInstalledJson",
5580
+ "kind": "function",
5581
+ "signature": "loadInstalledJson(spec: string, root: string) => InstalledJson",
5582
+ "summary": "Finds and parses the installed `<package>[/<entry>]/index.json` as installed under `root`, and does not check what is in it. Returns `{ data: unknown, file, packageName, entry, packageVersion }`. Throws `FactReadError` with code `not-found` when the file can not be resolved, and with code `not-an-index` when it is not JSON, with the same messages as `loadInstalledIndex` has today. Use it when the caller checks the contents itself."
5583
+ },
5584
+ {
5585
+ "name": "loadInstalledIndex",
5586
+ "kind": "function",
5587
+ "signature": "loadInstalledIndex(spec: string, root: string) => InstalledIndex",
5588
+ "summary": "Finds and parses the built `index.json` of `<package>` or `<package>/<path>` as installed under `root`, and returns it with the file, the package name, the entry and the package version. It is `loadInstalledJson` followed by `assertIndex`, and its behavior and messages do not change. Throws `FactReadError` when it can not be found or is not an index."
5589
+ },
5590
+ {
5591
+ "name": "installedVersion",
5592
+ "kind": "function",
5593
+ "signature": "installedVersion(root: string, name: string) => string | undefined",
5594
+ "summary": "The version in the `package.json` of the first `node_modules/<name>` found going up from `root`, or undefined."
5595
+ },
5596
+ {
5597
+ "name": "assertIndex",
5598
+ "kind": "function",
5599
+ "signature": "assertIndex(index: unknown, label?: string) => readonly Fact[]",
5600
+ "summary": "Checks the top of a parsed index and returns its facts. Throws `FactReadError` with code `not-an-index` or `unsupported-index-format`."
5601
+ },
5602
+ {
5603
+ "name": "factRows",
5604
+ "kind": "function",
5605
+ "signature": "factRows(fact: Fact) => Row[]",
5606
+ "summary": "The rows of a fact. Without `variants` the whole fact is one row that starts at `when.since`."
5607
+ },
5608
+ {
5609
+ "name": "registerImpactExtractor",
5610
+ "kind": "function",
5611
+ "signature": "registerImpactExtractor(extractor: ImpactExtractor) => () => void",
5612
+ "summary": "Registers a reference extractor for `impactOf`. See `fact-kit.impact-extractors`."
5613
+ },
5614
+ {
5615
+ "name": "InstalledJson",
5616
+ "kind": "type",
5617
+ "signature": "interface InstalledJson { data: unknown; file: string; packageName: string; entry: string; packageVersion: string }",
5618
+ "summary": "What `loadInstalledJson` returns. A type, exported with `export type`, with no runtime value."
5619
+ },
5620
+ {
5621
+ "name": "BUILDER",
5622
+ "kind": "symbol",
5623
+ "signature": "const BUILDER: symbol (Symbol.for('fact-kit.builder'))",
5624
+ "summary": "The tag that holds the name of the builder that made a value. It is a Symbol, so `typeof` gives `symbol`, and `Symbol.for` makes it the same one in every copy of the package."
5625
+ },
5626
+ {
5627
+ "name": "Row",
5628
+ "kind": "type",
5629
+ "signature": "interface Row { since, content, pending?, stability?, platforms?, os? }",
5630
+ "summary": "A row of a fact as `factRows` returns it. A type, exported with `export type`, with no runtime value."
5631
+ },
5632
+ {
5633
+ "name": "ImpactExtractor",
5634
+ "kind": "type",
5635
+ "signature": "interface ImpactExtractor { name, extensions, extract }",
5636
+ "summary": "The shape of an extractor in `fact-kit.impact-extractors`. A type, exported with `export type`."
4637
5637
  }
4638
5638
  ],
4639
- "optionalPeers": [
5639
+ "schemaRow": [
4640
5640
  {
4641
- "peerDependency": "prettier",
4642
- "range": ">=3.0.0",
4643
- "install": "pnpm add -D prettier@3",
4644
- "usedBy": [
4645
- "writeFormatted"
4646
- ]
5641
+ "name": "path",
5642
+ "type": "string",
5643
+ "summary": "`a.b` for a property, `a[]` for array items, `a.*` for additional properties."
5644
+ },
5645
+ {
5646
+ "name": "type",
5647
+ "type": "string",
5648
+ "summary": "Empty when the schema says nothing."
5649
+ },
5650
+ {
5651
+ "name": "required",
5652
+ "type": "boolean"
5653
+ },
5654
+ {
5655
+ "name": "description",
5656
+ "type": "string"
5657
+ },
5658
+ {
5659
+ "name": "values",
5660
+ "type": "unknown[]",
5661
+ "summary": "Present only when the field lists `enum` or `const` values, merged over `anyOf` / `oneOf` branches."
5662
+ },
5663
+ {
5664
+ "name": "extensions",
5665
+ "type": "Record<string, unknown>",
5666
+ "summary": "The `x-` keywords of the field."
5667
+ },
5668
+ {
5669
+ "name": "requiredWhen",
5670
+ "type": "{ path: string; values: unknown[] }",
5671
+ "summary": "Present when only some branches require the field and the branches are told apart by a `const` property: required when that property takes one of `values`."
4647
5672
  }
4648
- ]
5673
+ ],
5674
+ "kinds": {
5675
+ "function": "A function. `typeof` gives `function`.",
5676
+ "symbol": "A Symbol. `typeof` gives `symbol`.",
5677
+ "constant": "A string constant, such as `DRAFT_2020_12`. `typeof` gives `string`.",
5678
+ "type": "A type or interface, exported with `export type`. It has no runtime value."
5679
+ }
4649
5680
  }
4650
5681
  }
4651
5682
  }
@@ -4656,12 +5687,536 @@
4656
5687
  },
4657
5688
  "content": {
4658
5689
  "value": {
4659
- "requires": {
4660
- "peerDependency": "typescript",
4661
- "range": ">=7.1.0-beta",
4662
- "optional": true,
4663
- "install": "pnpm add -D typescript@7.1.0-beta"
4664
- },
5690
+ "module": "fact-kit",
5691
+ "exports": [
5692
+ {
5693
+ "name": "defineFacts",
5694
+ "signature": "defineFacts(module: FactsModule) => FactsModule",
5695
+ "summary": "Identity helper that types the default export of `facts/<entry>/index.ts`."
5696
+ },
5697
+ {
5698
+ "name": "history",
5699
+ "signature": "history(...rows: HistoryRow[]) => HistoryVariants",
5700
+ "summary": "Expands the rows of a fact into `variants`: `variants: history(...)`. Row fields are in `fact-kit.history-row`. Targets are JSON Pointers (RFC 6901) into the content, and `''` is the root. A row that does not fit throws an error that names the key, and `check` reports it as `history`. The result is still an array of variants, and `mf.value(name, history(...))` takes it. After each row, the check of the builder that made the content runs again, and a row that breaks it throws `BuilderError`, which `check` reports as `builder`. `remove` and `add` also work on an object by property name, such as the `properties` of an `entity`."
5701
+ },
5702
+ {
5703
+ "name": "keyed",
5704
+ "signature": "keyed<T>(items: T[], keys?: string[]) => T[]",
5705
+ "summary": "Declares the fields that identify an item of an array, so `history` can `add`, `remove` and `replace` items by key. Several fields make a key written as an array in that order. Without `keys` the items are scalars and identify themselves. An array that is not keyed can only be replaced whole."
5706
+ },
5707
+ {
5708
+ "name": "factLink",
5709
+ "signature": "factLink(fact: Fact) => string",
5710
+ "summary": "The location of another fact of this package, to write inside a sentence of `content`: `<id>` in the same entry, `<spec>:<id>` in another. The build adds the fact to `derivedFrom`. `relates: [fact]` adds it without text. A fact object that is not one of this package fails `check` with `relates-foreign`."
5711
+ },
5712
+ {
5713
+ "name": "derive",
5714
+ "signature": "derive(upstreamSpec: string, id: string, map?: (upstream: Fact) => Partial<Fact>) => DerivedFact",
5715
+ "summary": "A fact computed from a fact of another package, listed in `facts`. The build reads the installed index of `upstreamSpec`, copies the fact `id`, lets `map` change the copy, and sets `source` to `{ kind: 'derived', from: upstreamSpec, version }` with the upstream version installed, and `derivedFrom` to `<upstreamSpec>:<id>`. The build records each upstream spec and version in `derived.lock.json`, which goes into version control. Building with another upstream version installed fails with `derive-version` until `--accept-upstream` rewrites the lock."
5716
+ },
5717
+ {
5718
+ "name": "defineExamples",
5719
+ "signature": "defineExamples(examples: ExampleGroupSource | ExampleGroupSource[]) => typeof examples",
5720
+ "summary": "Identity helper that types an example file. Each group follows `fact-kit.example-group`. In `outcome` an item may also be `ref(fact)`, `ref(fact, field)` or `statementFrom(fact, render)`, which the build turns into `{ fact, field?, text? }`."
5721
+ },
5722
+ {
5723
+ "name": "exampleFactRefs",
5724
+ "signature": "exampleFactRefs(group: ExampleGroup) => { id: string; location: string; in: 'facts' | 'outcome'; field?: string }[]",
5725
+ "summary": "Every fact id an example group references, with the JSON pointer where it is referenced. `in` is `facts` for `facts` of the group or of a scenario and `outcome` for a `{ fact }` item of an outcome, and `field` is the field that item names."
5726
+ },
5727
+ {
5728
+ "name": "flattenSchema",
5729
+ "signature": "flattenSchema(schema: JsonSchema) => SchemaRow[]",
5730
+ "summary": "One row per field of a JSON Schema, for rendering field tables in docs and prompts. Fields of `anyOf` / `oneOf` branches are merged by name: values are the union, required when every branch requires it."
5731
+ },
5732
+ {
5733
+ "name": "schemaRowsToMarkdown",
5734
+ "signature": "schemaRowsToMarkdown(rows: SchemaRow[]) => string",
5735
+ "summary": "A Markdown table of the rows, with Field, Type, Required, Description and Extensions columns."
5736
+ },
5737
+ {
5738
+ "name": "valueListToMarkdown",
5739
+ "signature": "valueListToMarkdown(fact: Fact, options?: { columns?: string[] }) => string",
5740
+ "summary": "Renders a fact whose `content.value` is an array: one `- item` line per string, or a table for objects (columns default to the keys). Throws an error naming the fact id when the value is not an array."
5741
+ },
5742
+ {
5743
+ "name": "replaceFactBlocks",
5744
+ "signature": "replaceFactBlocks(text: string, blocks: Record<string, string>) => { text: string; changed: boolean }",
5745
+ "summary": "Replaces the text between `<!-- facts:begin NAME -->` and `<!-- facts:end NAME -->` with `blocks[NAME]`. `changed` is false when the document is already current, which is what a `--check` exits on. Throws an error naming the block on a missing end, a repeated name, or a name the document lacks."
5746
+ },
5747
+ {
5748
+ "name": "readFacts",
5749
+ "signature": "readFacts(spec, options?) => FactReader",
5750
+ "summary": "Reads an installed fact package. Parameters and members are in `fact-kit.read-facts`."
5751
+ },
5752
+ {
5753
+ "name": "selectFacts",
5754
+ "signature": "selectFacts(index, { version?, include?, platform?, os? }) => SelectedFact[]",
5755
+ "summary": "The facts one reader sees in a parsed index of format 1.0 or 1.1. A pure function; `readFacts` is built on it."
5756
+ },
5757
+ {
5758
+ "name": "factsOf",
5759
+ "signature": "factsOf({ tool, source, prefix?, topics? }) => FactsFactory",
5760
+ "summary": "Writes facts with the repeated fields filled in: `const mf = factsOf({ tool, source })`, then `mf.value(name, value)`, `mf.schema(name, schema)` and `mf.statement(name, text)` return a fact whose id is `<tool>.<prefix>.<name>` (`<tool>.<name>` without a prefix) and whose title is `name`. Each takes a value, a function that returns it, or the rows of `history(...)` as the second argument, and `{ title?, topics?, description?, when?, relates?, verify?, source?, note? }` as the third. The topics are those of `factsOf` and then those of the call. A fact written with one content exposes the fields of an object value as read-only getters that give a tagged copy, so the build adds the fact read to `derivedFrom`. A scalar, or a value built from scalars, carries no tag, so write it as a function (`mf.value(name, () => ...)`): every read of another fact while the function runs goes into `relates`. A fact written with `history(...)` has no getters, so read it with `contentOf`. Throws `BuilderError` for a name that is empty or starts or ends with a dot, and for rows whose first row is not the kind of the method."
5761
+ },
5762
+ {
5763
+ "name": "observedDoc",
5764
+ "signature": "observedDoc({ url: string, fetched: string }) => FactSource",
5765
+ "summary": "The source `{ kind: 'observed', basis: 'doc', url, fetched }` of a fact read from a page of the documentation."
5766
+ },
5767
+ {
5768
+ "name": "observedSpike",
5769
+ "signature": "observedSpike({ fetched: string, url?: string }) => FactSource",
5770
+ "summary": "The source `{ kind: 'observed', basis: 'spike', fetched }` of a fact seen in a trial run, with `url` when a page led to it."
5771
+ },
5772
+ {
5773
+ "name": "contentOf",
5774
+ "signature": "contentOf(fact: Fact, since?: string) => unknown",
5775
+ "summary": "A copy of the value or the schema of one row of a fact, tagged so the build adds the fact to `derivedFrom` where the copy is embedded. A fact with several rows needs `since`, the `since` of the row to read (any one version of a row written as an array). Throws `BuilderError` when there is no such row or no content."
5776
+ },
5777
+ {
5778
+ "name": "statementFrom",
5779
+ "signature": "statementFrom(fact: Fact, render: (value) => Text, options?: { since?: string }) => BuiltStatement",
5780
+ "summary": "A statement written from the content of another fact: `render` gets the copy that `contentOf` makes and returns the text. Give the result to `mf.statement` or to the `statement` of a `history` row. The fact goes into `relates`, so `derivedFrom` follows it."
5781
+ },
5782
+ {
5783
+ "name": "subsetOf",
5784
+ "signature": "subsetOf(parent: Fact, items: T[]) => T[]",
5785
+ "summary": "A list that must stay inside the list of `parent`, a fact object. When the parent is a typed list (`mf.value('x', ['A', 'B'])`) the type checker rejects an item it does not have. A parent that comes from a conversion has no type, so `check` and `build` test the list again at every version boundary of the two facts and report `subset-of` with the version. The parent goes into `derivedFrom`. Throws `BuilderError` when `parent` is not a fact object."
5786
+ },
5787
+ {
5788
+ "name": "stateMachine",
5789
+ "signature": "stateMachine({ initial, states, transitions }) => StateMachine",
5790
+ "summary": "A state machine as a value: `{ initial, states, transitions }`, each transition `{ from, to, event?, guard? }`. `event` is a string, or a list of strings for several events between the same two states, and `guard` is a string that holds for all of them. `states` is keyed by name and `transitions` by `from` and `to`, so a `history` row can `add`, `remove` and `replace` them by key, for example `remove: { '/states': ['blocked'] }` and `remove: { '/transitions': [['active', 'done']] }`. Give it to `mf.value`. Throws `BuilderError` when `initial`, or the `from` or `to` of a transition, is not in `states`, and `history` checks it again after every row, so a row that drops a state a transition still uses fails. `check` reports it as `builder`."
5791
+ },
5792
+ {
5793
+ "name": "relations",
5794
+ "signature": "relations({ nodes, edges }) => Relations",
5795
+ "summary": "Nodes and named relations as a value: `{ nodes, edges }`, each edge `{ from, to, name, cardinality? }` with `cardinality` `'one'` or `'many'`. `nodes` is keyed by name and `edges` by `from`, `to` and `name`, for example `remove: { '/edges': [['a', 'b', 'has']] }`. Give it to `mf.value`. Throws `BuilderError` when the `from` or `to` of an edge is not in `nodes`, and `history` checks it again after every row."
5796
+ },
5797
+ {
5798
+ "name": "sequence",
5799
+ "signature": "sequence({ participants, steps }) => Sequence",
5800
+ "summary": "Messages between participants as a value: `{ participants, steps }`, each step `{ from, to, action }`. `participants` is keyed by name and `steps` by `action`, which no two steps share. A `history` row can `add` steps only at the end. To insert in the middle or to rename an `action`, replace the whole list: `replace: { '/steps': keyed([...], ['action']) }`. Throws `BuilderError` when the `from` or `to` of a step is not in `participants`, and `history` checks it again after every row."
5801
+ },
5802
+ {
5803
+ "name": "stateMachineToMermaid",
5804
+ "signature": "stateMachineToMermaid(source: StateMachine | Fact) => string",
5805
+ "summary": "A `stateDiagram-v2` of a state machine, without a code fence. `source` is the value or a fact whose content is that value. Each state is declared as `state \"<name>\" as s<i>` in the order of `states`, the initial state is `[*] --> s<i>`, and a transition is `s<i> --> s<j>` followed by `: <events joined by \", \"> [<guard>]` when it has either. The ids are generated, so a name with spaces or punctuation is safe, and `#`, `\"`, `;` and `|` in a name become mermaid entities."
5806
+ },
5807
+ {
5808
+ "name": "relationsToMermaid",
5809
+ "signature": "relationsToMermaid(source: Relations | Fact) => string",
5810
+ "summary": "A `flowchart LR` of nodes and relations, without a code fence. Each node is declared as `n<i>[\"<name>\"]` and each edge is `n<i> -->|<name>| n<j>`. `cardinality` is not drawn. The ids are generated."
5811
+ },
5812
+ {
5813
+ "name": "sequenceToMermaid",
5814
+ "signature": "sequenceToMermaid(source: Sequence | UseCase | Fact) => string",
5815
+ "summary": "A `sequenceDiagram` of a sequence, without a code fence. Each participant is declared as `participant p<i> as <name>` and each step is `p<i>->>p<j>: <action>`. The ids are generated. A use case from `useCase` is drawn too: the participants are `caller` and then each `layer` in the order of first use, and each step is a message from the layer of the step before it (`caller` for the first) to its own layer."
5816
+ },
5817
+ {
5818
+ "name": "ref",
5819
+ "signature": "ref(fact: Fact, field?: string) => FactRef",
5820
+ "summary": "A reference to a fact of this package, or to a field of it written with dots such as `'limits.max'`, for the content of another fact. It returns a placeholder that the build replaces. When it is the whole value of a subschema, the build writes `{ $ref: '#/$defs/<id>' }`, or `{ $ref: '#/$defs/<id>/properties/a/properties/b' }` with a field, and puts the schema of the target into `$defs` of the root schema, flat and once per id. Anywhere else (a value, a statement, a longer string, a `const`) it writes the location of the fact, followed by `#a.b` with a field. A `$ref` inside the embedded schema that points to its own root (`#`, `#/properties/x`) is rewritten to `#/$defs/<id>` and `#/$defs/<id>/properties/x`; one into its own `$defs` or to an anchor stays. When the target has several rows, the build aligns them: the fact that writes the `ref` gets one row for each combination of its own row and the rows of the target that some reader gets together (the boundaries of `subset-of`), each with the `$defs` of that combination, so a reader reads a standard JSON Schema and changes nothing. A fact with one row becomes a fact with `variants`. The target goes into `derivedFrom`. A field the type checker knows is not in the target fails to compile. `check` reports `ref` when the field is missing from a row the two facts share, and `relates-foreign` when the target is no fact of any entry of the package. It also fits `guard` of a transition."
5821
+ },
5822
+ {
5823
+ "name": "entity",
5824
+ "signature": "entity({ identity, fields, required? }) => EntitySchema",
5825
+ "summary": "An entity as a JSON Schema for `mf.schema`: `{ type: 'object', 'x-identity', properties, required? }`, with the topic `ddd:entity`. `identity` is a field name, or a list of at least two different names (a list of one is written as the name), and `fields` maps a name to a schema or to `ref(fact)`. `required` is a keyed list of names. A `history` row drops a field with `remove: { '/properties': ['status'] }`, adds one with `add: { '/properties': { note: {...} } }` and swaps one with `replace: { '/properties/status': {...} }`, and must drop the name from `required` in the same row. Throws `BuilderError` when an identity name or a `required` name is not a field, and `history` checks it again after every row, so a row that leaves one behind fails and `check` reports `builder`."
5826
+ },
5827
+ {
5828
+ "name": "valueObject",
5829
+ "signature": "valueObject(fields, options?: { required? }) => ObjectSchema",
5830
+ "summary": "A value object as a JSON Schema for `mf.schema`: `{ type: 'object', properties, required? }`, with the topic `ddd:value-object`. A `history` row changes the fields by name in the same way as `entity`, and `required` follows them. Throws `BuilderError` when a `required` name is not a field."
5831
+ },
5832
+ {
5833
+ "name": "domainEvent",
5834
+ "signature": "domainEvent(fields, options?: { required? }) => ObjectSchema",
5835
+ "summary": "A domain event as a JSON Schema for `mf.schema`, in the shape and with the rules of `valueObject`, with the topic `ddd:domain-event`."
5836
+ },
5837
+ {
5838
+ "name": "aggregate",
5839
+ "signature": "aggregate({ root, members }) => Aggregate",
5840
+ "summary": "An aggregate as a value for `mf.value`: `{ root, members }`, each member `{ entity, cardinality }` where `cardinality` is `'one'` (the default) or `'many'`. The facts are written as `factLink` placeholders that the build replaces with their location and adds to `derivedFrom`. The topic is `ddd:aggregate`. `members` is keyed by `entity`, so a `history` row names a member by `factLink(entity)`: `remove: { '/members': [factLink(line)] }`. Throws `BuilderError` when `root` is not a fact object or a cardinality is not `'one'` or `'many'`, and `HistoryError` for two members of one entity."
5841
+ },
5842
+ {
5843
+ "name": "invariant",
5844
+ "signature": "invariant(subject: Fact, text: Text) => BuiltStatement",
5845
+ "summary": "A business rule about an entity or value, for `mf.statement` or the `statement` of a `history` row. It carries the text, and `subject` goes into `relates` so `derivedFrom` follows it. The topic is `ddd:invariant`. A later `history` row rewrites the sentence whole with `statement: invariant(...)`, which also carries the new subject. `set: { '': text }` replaces the sentence but not `relates`. Throws `BuilderError` when `subject` is not a fact object or `text` is empty."
5846
+ },
5847
+ {
5848
+ "name": "useCase",
5849
+ "signature": "useCase({ input?, output?, steps, errors? }) => UseCase",
5850
+ "summary": "An application use case as a value for `mf.value`: `{ input?, output?, steps, errors }`. `input` and `output` are `ref(fact)` or a schema. A step is `{ layer, action, rule?, emits?, calls? }` where `layer` is `'application'`, `'domain'` or `'infrastructure'` and the facts in `rule`, `emits` and `calls` become `factLink` placeholders. The topic is `ddd:use-case`. `steps` is keyed by `action`, which no two steps share, and a `history` row can `add` steps only at the end, so to insert in the middle replace the whole list. `errors` is a keyed list of codes. `sequenceToMermaid` draws it. Throws `BuilderError` for a layer that is not one of the three or an empty action, and `HistoryError` for a repeated action or code."
5851
+ },
5852
+ {
5853
+ "name": "writeFormatted",
5854
+ "signature": "writeFormatted(file: string, text: string) => Promise<void>",
5855
+ "summary": "Writes `text` to `file` formatted with the prettier settings that `resolveConfig(file)` finds (none when there is no config), so a rerun gives the same bytes. Creates the parent directories. `prettier` is an optional peer dependency that is loaded when the function runs, and a missing package throws an error that names what to install: `pnpm add -D prettier@3`."
5856
+ },
5857
+ {
5858
+ "name": "stableJson",
5859
+ "signature": "stableJson(value: unknown) => string",
5860
+ "summary": "JSON with two-space indent and the keys of every object in code-unit order, for generated files. Arrays keep their order. There is no trailing newline."
5861
+ },
5862
+ {
5863
+ "name": "DRAFT_2020_12",
5864
+ "signature": "const DRAFT_2020_12: 'https://json-schema.org/draft/2020-12/schema'",
5865
+ "summary": "The `$schema` URL of JSON Schema 2020-12. It is the value `interfaceToJsonSchema` and `normalizeSchema` put in `$schema`."
5866
+ },
5867
+ {
5868
+ "name": "NormalizeOptions",
5869
+ "signature": "interface NormalizeOptions { describe?, drop?, notes? }",
5870
+ "summary": "The options of `normalizeSchema`. `describe(text) => string` is called for each `description` and returns the text to keep. `drop` lists keywords to remove at any depth. `notes` is a `Map<string, number>` that counts what was dropped or rewritten, for the converter report. A type, exported with `export type`."
5871
+ },
5872
+ {
5873
+ "name": "normalizeSchema",
5874
+ "signature": "normalizeSchema(input: JsonSchema, options?: NormalizeOptions) => JsonSchema",
5875
+ "summary": "Rewrites a JSON Schema from another dialect (draft-07, OpenAPI 3.0) to 2020-12, only where a schema is expected, so a property named `items` or `deprecated` is left alone. `definitions` becomes `$defs` and `#/definitions/` references follow. A tuple `items: [...]` becomes `prefixItems` and `additionalItems` becomes `items`. A string `deprecated` becomes `true` and its message is appended to `description` as `Deprecated: <message>`. `nullable: true` adds `null` to `type`. `dependencies` splits into `dependentRequired` and `dependentSchemas`. `x-` keywords that fact-kit does not register (`X_KEYWORDS`), `$id`, `id` and the keywords in `drop` are removed. The result starts with `$schema` set to `DRAFT_2020_12`."
5876
+ },
5877
+ {
5878
+ "name": "PinnedSource",
5879
+ "signature": "interface PinnedSource { repo, commit, path, sha256, license }",
5880
+ "summary": "An upstream file pinned to a commit: `repo` is `owner/name`, `commit` is the full SHA, `path` is the file in the repository, `sha256` is the hex digest of its bytes and `license` is an SPDX id. A type, exported with `export type`."
5881
+ },
5882
+ {
5883
+ "name": "sourceUrl",
5884
+ "signature": "sourceUrl(source: PinnedSource) => string",
5885
+ "summary": "The GitHub page of the pinned file at its commit (`blob/<commit>/<path>` of the repository), where a reader opens it."
5886
+ },
5887
+ {
5888
+ "name": "readPinned",
5889
+ "signature": "readPinned(source: PinnedSource, options: { cacheDir: string }) => Promise<string>",
5890
+ "summary": "The text of the pinned file. Reads `<cacheDir>/<sha256>.txt` when it exists, otherwise downloads the file at that commit from the raw-content address of GitHub, checks the sha256 and writes the cache. `cacheDir` is required, so the cache place does not depend on the working directory. Throws `<repo>/<path>: sha256 is <actual>, expected <sha256>` when the bytes do not match, also for a cached file, and `<url>: HTTP <status>` when the download fails."
5891
+ },
5892
+ {
5893
+ "name": "registerBuilderCheck",
5894
+ "kind": "function",
5895
+ "signature": "registerBuilderCheck(name: string, check: BuilderCheck, about?: BuilderAbout) => void",
5896
+ "summary": "Registers the check of a builder: `check(root)` returns a message that names the key at fault, or undefined. `history` runs it again after every row of a fact whose content carries the mark of that builder. `about` gives the kind of content the builder makes and the topic `mf.*` adds."
5897
+ },
5898
+ {
5899
+ "name": "setMark",
5900
+ "kind": "function",
5901
+ "signature": "setMark(target: object, mark: symbol, value: unknown) => void",
5902
+ "summary": "Puts a tag on `target` as a non-enumerable property under the symbol `mark`, so it is not written to the index."
5903
+ },
5904
+ {
5905
+ "name": "makeBuilt",
5906
+ "kind": "function",
5907
+ "signature": "makeBuilt(text: unknown, relates: readonly object[], builder?: string) => BuiltStatement",
5908
+ "summary": "A statement a builder made: the text plus the fact objects it relates to. With `builder`, it carries the `BUILDER` mark of that name."
5909
+ },
5910
+ {
5911
+ "name": "isText",
5912
+ "kind": "function",
5913
+ "signature": "isText(value: unknown) => boolean",
5914
+ "summary": "True for a non-empty string, or an object with at least one language."
5915
+ },
5916
+ {
5917
+ "name": "isObject",
5918
+ "kind": "function",
5919
+ "signature": "isObject(value: unknown) => value is Record<string, unknown>",
5920
+ "summary": "True for an object that is not null and not an array."
5921
+ },
5922
+ {
5923
+ "name": "parseVersion",
5924
+ "kind": "function",
5925
+ "signature": "parseVersion(text: string) => Semver | undefined",
5926
+ "summary": "Parses a semver 2.0.0 version into `{ major, minor, patch, pre }`, or returns undefined. Build metadata is accepted and ignored."
5927
+ },
5928
+ {
5929
+ "name": "mustParse",
5930
+ "kind": "function",
5931
+ "signature": "mustParse(text: string, what: string) => Semver",
5932
+ "summary": "Like `parseVersion`, and throws `FactReadError` with code `invalid-version` that names `what` when the text is not semver."
5933
+ },
5934
+ {
5935
+ "name": "compareSemver",
5936
+ "kind": "function",
5937
+ "signature": "compareSemver(a: Semver, b: Semver) => -1 | 0 | 1",
5938
+ "summary": "The semver 2.0.0 precedence of `a` against `b`, a pre-release below its release."
5939
+ },
5940
+ {
5941
+ "name": "sinceIssue",
5942
+ "kind": "function",
5943
+ "signature": "sinceIssue(since: Since) => SinceIssue | undefined",
5944
+ "summary": "Why a `since` is not one of the three allowed forms (`since-format`) or has two versions on one release line (`same-line`), or undefined when it is fine."
5945
+ },
5946
+ {
5947
+ "name": "findRows",
5948
+ "kind": "function",
5949
+ "signature": "findRows(program: unknown, options?: { dataKeys?: readonly string[] }) => SinceRow[]",
5950
+ "summary": "Every object with a `since` in a parsed program, in source order, each with the position of the `since` text and whether it has a `pending` label. Fact content is not searched. `options.dataKeys` is described in `fact-kit.row-data-keys`."
5951
+ },
5952
+ {
5953
+ "name": "applyEdits",
5954
+ "kind": "function",
5955
+ "signature": "applyEdits(source: string, edits: readonly Edit[]) => string",
5956
+ "summary": "Applies text edits `{ start, end, text }` that do not overlap, from the last to the first, so the offsets stay right."
5957
+ },
5958
+ {
5959
+ "name": "splitSpec",
5960
+ "kind": "function",
5961
+ "signature": "splitSpec(spec: string) => { packageName: string; entry: string }",
5962
+ "summary": "Splits `@scope/name/path` or `name/path` into the package name and the sub-path, which is empty when the spec names only the package. Throws `FactReadError` with code `not-found` for a spec that is not of that form."
5963
+ },
5964
+ {
5965
+ "name": "loadInstalledJson",
5966
+ "kind": "function",
5967
+ "signature": "loadInstalledJson(spec: string, root: string) => InstalledJson",
5968
+ "summary": "Finds and parses the installed `<package>[/<entry>]/index.json` as installed under `root`, and does not check what is in it. Returns `{ data: unknown, file, packageName, entry, packageVersion }`. Throws `FactReadError` with code `not-found` when the file can not be resolved, and with code `not-an-index` when it is not JSON, with the same messages as `loadInstalledIndex` has today. Use it when the caller checks the contents itself."
5969
+ },
5970
+ {
5971
+ "name": "loadInstalledIndex",
5972
+ "kind": "function",
5973
+ "signature": "loadInstalledIndex(spec: string, root: string) => InstalledIndex",
5974
+ "summary": "Finds and parses the built `index.json` of `<package>` or `<package>/<path>` as installed under `root`, and returns it with the file, the package name, the entry and the package version. It is `loadInstalledJson` followed by `assertIndex`, and its behavior and messages do not change. Throws `FactReadError` when it can not be found or is not an index."
5975
+ },
5976
+ {
5977
+ "name": "installedVersion",
5978
+ "kind": "function",
5979
+ "signature": "installedVersion(root: string, name: string) => string | undefined",
5980
+ "summary": "The version in the `package.json` of the first `node_modules/<name>` found going up from `root`, or undefined."
5981
+ },
5982
+ {
5983
+ "name": "assertIndex",
5984
+ "kind": "function",
5985
+ "signature": "assertIndex(index: unknown, label?: string) => readonly Fact[]",
5986
+ "summary": "Checks the top of a parsed index and returns its facts. Throws `FactReadError` with code `not-an-index` or `unsupported-index-format`."
5987
+ },
5988
+ {
5989
+ "name": "factRows",
5990
+ "kind": "function",
5991
+ "signature": "factRows(fact: Fact) => Row[]",
5992
+ "summary": "The rows of a fact. Without `variants` the whole fact is one row that starts at `when.since`."
5993
+ },
5994
+ {
5995
+ "name": "registerImpactExtractor",
5996
+ "kind": "function",
5997
+ "signature": "registerImpactExtractor(extractor: ImpactExtractor) => () => void",
5998
+ "summary": "Registers a reference extractor for `impactOf`. See `fact-kit.impact-extractors`."
5999
+ },
6000
+ {
6001
+ "name": "InstalledJson",
6002
+ "kind": "type",
6003
+ "signature": "interface InstalledJson { data: unknown; file: string; packageName: string; entry: string; packageVersion: string }",
6004
+ "summary": "What `loadInstalledJson` returns. A type, exported with `export type`, with no runtime value."
6005
+ },
6006
+ {
6007
+ "name": "BUILDER",
6008
+ "kind": "symbol",
6009
+ "signature": "const BUILDER: symbol (Symbol.for('fact-kit.builder'))",
6010
+ "summary": "The tag that holds the name of the builder that made a value. It is a Symbol, so `typeof` gives `symbol`, and `Symbol.for` makes it the same one in every copy of the package."
6011
+ },
6012
+ {
6013
+ "name": "Row",
6014
+ "kind": "type",
6015
+ "signature": "interface Row { since, content, pending?, stability?, platforms?, os? }",
6016
+ "summary": "A row of a fact as `factRows` returns it. A type, exported with `export type`, with no runtime value."
6017
+ },
6018
+ {
6019
+ "name": "ImpactExtractor",
6020
+ "kind": "type",
6021
+ "signature": "interface ImpactExtractor { name, extensions, extract }",
6022
+ "summary": "The shape of an extractor in `fact-kit.impact-extractors`. A type, exported with `export type`."
6023
+ }
6024
+ ],
6025
+ "schemaRow": [
6026
+ {
6027
+ "name": "path",
6028
+ "type": "string",
6029
+ "summary": "`a.b` for a property, `a[]` for array items, `a.*` for additional properties."
6030
+ },
6031
+ {
6032
+ "name": "type",
6033
+ "type": "string",
6034
+ "summary": "Empty when the schema says nothing."
6035
+ },
6036
+ {
6037
+ "name": "required",
6038
+ "type": "boolean"
6039
+ },
6040
+ {
6041
+ "name": "description",
6042
+ "type": "string"
6043
+ },
6044
+ {
6045
+ "name": "values",
6046
+ "type": "unknown[]",
6047
+ "summary": "Present only when the field lists `enum` or `const` values, merged over `anyOf` / `oneOf` branches."
6048
+ },
6049
+ {
6050
+ "name": "extensions",
6051
+ "type": "Record<string, unknown>",
6052
+ "summary": "The `x-` keywords of the field."
6053
+ },
6054
+ {
6055
+ "name": "requiredWhen",
6056
+ "type": "{ path: string; values: unknown[] }",
6057
+ "summary": "Present when only some branches require the field and the branches are told apart by a `const` property: required when that property takes one of `values`."
6058
+ }
6059
+ ],
6060
+ "kinds": {
6061
+ "function": "A function. `typeof` gives `function`.",
6062
+ "symbol": "A Symbol. `typeof` gives `symbol`.",
6063
+ "constant": "A string constant, such as `DRAFT_2020_12`. `typeof` gives `string`.",
6064
+ "type": "A type or interface, exported with `export type`. It has no runtime value."
6065
+ }
6066
+ }
6067
+ }
6068
+ },
6069
+ {
6070
+ "id": "fact-kit.converters",
6071
+ "topics": [
6072
+ "convert",
6073
+ "authoring"
6074
+ ],
6075
+ "title": {
6076
+ "en": "Converters and the optional TypeScript peer dependency"
6077
+ },
6078
+ "description": {
6079
+ "en": "The converters read TypeScript with the TypeScript 7.1 API, which starts a native compiler process. `typescript` is an optional peer dependency that is loaded when a converter runs, and a converter throws an error that names the package to install when it is missing. `writeFormatted` loads the optional peer dependency `prettier` the same way."
6080
+ },
6081
+ "variants": [
6082
+ {
6083
+ "since": "0.0.0",
6084
+ "content": {
6085
+ "value": {
6086
+ "requires": {
6087
+ "peerDependency": "typescript",
6088
+ "range": ">=7.1.0-beta",
6089
+ "optional": true,
6090
+ "install": "pnpm add -D typescript@7.1.0-beta"
6091
+ },
6092
+ "exports": [
6093
+ {
6094
+ "name": "readStringTuples",
6095
+ "signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
6096
+ "summary": "The string literal tuples exported by a TypeScript source, by name: `export declare const X: readonly [...]` and `export const X = [...] as const`. Parses only, so imports do not have to resolve."
6097
+ },
6098
+ {
6099
+ "name": "readStringTuplesFromFile",
6100
+ "signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
6101
+ "summary": "Reads the file and returns `readStringTuples` of it."
6102
+ },
6103
+ {
6104
+ "name": "interfaceToJsonSchema",
6105
+ "signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
6106
+ "summary": "An interface or type alias as a JSON Schema 2020-12 document. Referenced types become `$defs`. Union members and enum values keep the order of the source, `0 | number` keeps both members, and a tuple becomes `prefixItems`. JSDoc becomes `description`, and `descriptions: false` removes every `description`. Type errors in the input are not reported."
6107
+ },
6108
+ {
6109
+ "name": "readJsonSchemaFile",
6110
+ "signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
6111
+ "summary": "Reads a JSON Schema file. Does not need TypeScript."
6112
+ }
6113
+ ]
6114
+ }
6115
+ }
6116
+ },
6117
+ {
6118
+ "since": "0.10.0-alpha.1",
6119
+ "content": {
6120
+ "value": {
6121
+ "requires": {
6122
+ "peerDependency": "typescript",
6123
+ "range": ">=7.1.0-beta",
6124
+ "optional": true,
6125
+ "install": "pnpm add -D typescript@7.1.0-beta"
6126
+ },
6127
+ "exports": [
6128
+ {
6129
+ "name": "readStringTuples",
6130
+ "signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
6131
+ "summary": "The string literal tuples exported by a TypeScript source, by name: `export declare const X: readonly [...]` and `export const X = [...] as const`. Parses only, so imports do not have to resolve."
6132
+ },
6133
+ {
6134
+ "name": "readStringTuplesFromFile",
6135
+ "signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
6136
+ "summary": "Reads the file and returns `readStringTuples` of it."
6137
+ },
6138
+ {
6139
+ "name": "interfaceToJsonSchema",
6140
+ "signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
6141
+ "summary": "An interface or type alias as a JSON Schema 2020-12 document. Referenced types become `$defs`. Union members and enum values keep the order of the source, `0 | number` keeps both members, and a tuple becomes `prefixItems`. JSDoc becomes `description`, and `descriptions: false` removes every `description`. Type errors in the input are not reported."
6142
+ },
6143
+ {
6144
+ "name": "readJsonSchemaFile",
6145
+ "signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
6146
+ "summary": "Reads a JSON Schema file. Does not need TypeScript."
6147
+ }
6148
+ ],
6149
+ "optionalPeers": [
6150
+ {
6151
+ "peerDependency": "prettier",
6152
+ "range": ">=3.0.0",
6153
+ "install": "pnpm add -D prettier@3",
6154
+ "usedBy": [
6155
+ "writeFormatted"
6156
+ ]
6157
+ }
6158
+ ]
6159
+ }
6160
+ }
6161
+ },
6162
+ {
6163
+ "since": "0.11.1-alpha.1",
6164
+ "content": {
6165
+ "value": {
6166
+ "requires": {
6167
+ "peerDependency": "typescript",
6168
+ "range": ">=7.1.0-beta",
6169
+ "optional": true,
6170
+ "install": "pnpm add -D typescript@7.1.0-beta"
6171
+ },
6172
+ "exports": [
6173
+ {
6174
+ "name": "readStringTuples",
6175
+ "signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
6176
+ "summary": "The string literal tuples exported by a TypeScript source, by name: `export declare const X: readonly [...]` and `export const X = [...] as const`. Parses only, so imports do not have to resolve."
6177
+ },
6178
+ {
6179
+ "name": "readStringTuplesFromFile",
6180
+ "signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
6181
+ "summary": "Reads the file and returns `readStringTuples` of it."
6182
+ },
6183
+ {
6184
+ "name": "interfaceToJsonSchema",
6185
+ "signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
6186
+ "summary": "An interface or type alias as a JSON Schema 2020-12 document. A named interface or alias becomes a `$defs` entry, and a generic instantiation such as `Record<string, unknown>` is written in place. A type that refers to itself is a `$defs` entry that every place it appears references with `$ref`, an instantiation such as `Tree<string>` included. An instantiation is named as TypeScript prints it, such as `Tree<string>`, and a root type that refers to itself is also written out at the top. A generic type that makes a new instantiation at each level, such as `next?: Nest<Box<T>>` inside `Nest<T>`, throws an error that names it. A method is left out, and a property whose type is a function becomes `{ \"$comment\": \"<signature>\" }` with the signature as TypeScript prints it, such as `(n: number) => string`. Union members and enum values keep the order of the source, `0 | number` keeps both members, and a tuple becomes `prefixItems`. JSDoc becomes `description`, and `descriptions: false` removes every `description`. Type errors in the input are not reported. An error thrown while converting is not replaced by an error from closing the compiler process."
6187
+ },
6188
+ {
6189
+ "name": "readJsonSchemaFile",
6190
+ "signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
6191
+ "summary": "Reads a JSON Schema file. Does not need TypeScript."
6192
+ }
6193
+ ],
6194
+ "optionalPeers": [
6195
+ {
6196
+ "peerDependency": "prettier",
6197
+ "range": ">=3.0.0",
6198
+ "install": "pnpm add -D prettier@3",
6199
+ "usedBy": [
6200
+ "writeFormatted"
6201
+ ]
6202
+ }
6203
+ ]
6204
+ }
6205
+ }
6206
+ }
6207
+ ],
6208
+ "tool": "fact-kit",
6209
+ "source": {
6210
+ "kind": "published"
6211
+ },
6212
+ "content": {
6213
+ "value": {
6214
+ "requires": {
6215
+ "peerDependency": "typescript",
6216
+ "range": ">=7.1.0-beta",
6217
+ "optional": true,
6218
+ "install": "pnpm add -D typescript@7.1.0-beta"
6219
+ },
4665
6220
  "exports": [
4666
6221
  {
4667
6222
  "name": "readStringTuples",
@@ -4936,70 +6491,549 @@
4936
6491
  "type": "string",
4937
6492
  "minLength": 1
4938
6493
  },
4939
- {
4940
- "type": "object",
4941
- "required": [
4942
- "fact"
4943
- ],
4944
- "additionalProperties": false,
4945
- "properties": {
4946
- "fact": {
4947
- "type": "string",
4948
- "minLength": 1
4949
- },
4950
- "field": {
6494
+ {
6495
+ "type": "object",
6496
+ "required": [
6497
+ "fact"
6498
+ ],
6499
+ "additionalProperties": false,
6500
+ "properties": {
6501
+ "fact": {
6502
+ "type": "string",
6503
+ "minLength": 1
6504
+ },
6505
+ "field": {
6506
+ "type": "string",
6507
+ "minLength": 1
6508
+ },
6509
+ "text": {
6510
+ "description": "A string, or one string per language. Prompts take `zh-TW` and fall back to `en`.",
6511
+ "oneOf": [
6512
+ {
6513
+ "type": "string",
6514
+ "minLength": 1
6515
+ },
6516
+ {
6517
+ "type": "object",
6518
+ "properties": {
6519
+ "en": {
6520
+ "type": "string",
6521
+ "minLength": 1
6522
+ },
6523
+ "zh-TW": {
6524
+ "type": "string",
6525
+ "minLength": 1
6526
+ }
6527
+ },
6528
+ "additionalProperties": false,
6529
+ "minProperties": 1
6530
+ }
6531
+ ]
6532
+ }
6533
+ }
6534
+ }
6535
+ ]
6536
+ }
6537
+ },
6538
+ "points": {
6539
+ "type": "array",
6540
+ "items": {
6541
+ "type": "string",
6542
+ "minLength": 1
6543
+ }
6544
+ },
6545
+ "facts": {
6546
+ "type": "array",
6547
+ "minItems": 1,
6548
+ "items": {
6549
+ "type": "string",
6550
+ "minLength": 1
6551
+ },
6552
+ "description": "Ids of the facts the scenario demonstrates. Every id must exist."
6553
+ }
6554
+ }
6555
+ }
6556
+ }
6557
+ }
6558
+ }
6559
+ }
6560
+ }
6561
+ ],
6562
+ "tool": "fact-kit",
6563
+ "source": {
6564
+ "kind": "published"
6565
+ },
6566
+ "content": {
6567
+ "schema": {
6568
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
6569
+ "$id": "urn:fact-kit:example-group",
6570
+ "title": "Example group",
6571
+ "type": "object",
6572
+ "required": [
6573
+ "id",
6574
+ "name",
6575
+ "situation",
6576
+ "claim",
6577
+ "scenarios"
6578
+ ],
6579
+ "additionalProperties": false,
6580
+ "properties": {
6581
+ "id": {
6582
+ "type": "string",
6583
+ "pattern": "^[a-z0-9][a-z0-9-]*$"
6584
+ },
6585
+ "name": {
6586
+ "type": "string",
6587
+ "minLength": 1
6588
+ },
6589
+ "situation": {
6590
+ "type": "string",
6591
+ "minLength": 1,
6592
+ "description": "The situation the group answers."
6593
+ },
6594
+ "claim": {
6595
+ "type": "string",
6596
+ "minLength": 1,
6597
+ "description": "What the group shows, one sentence."
6598
+ },
6599
+ "facts": {
6600
+ "type": "array",
6601
+ "items": {
6602
+ "type": "string",
6603
+ "minLength": 1
6604
+ },
6605
+ "description": "Fact ids the whole group demonstrates, on top of those of its scenarios."
6606
+ },
6607
+ "scenarios": {
6608
+ "type": "array",
6609
+ "minItems": 1,
6610
+ "items": {
6611
+ "type": "object",
6612
+ "required": [
6613
+ "title",
6614
+ "situation",
6615
+ "code",
6616
+ "outcome",
6617
+ "points",
6618
+ "facts"
6619
+ ],
6620
+ "additionalProperties": false,
6621
+ "properties": {
6622
+ "title": {
6623
+ "type": "string",
6624
+ "minLength": 1
6625
+ },
6626
+ "situation": {
6627
+ "type": "string",
6628
+ "minLength": 1,
6629
+ "description": "What the reader is trying to do, one sentence."
6630
+ },
6631
+ "code": {
6632
+ "type": "array",
6633
+ "description": "Run by the tool’s own tests, not by fact-kit.",
6634
+ "items": {
6635
+ "type": "object",
6636
+ "required": [
6637
+ "caption",
6638
+ "lang",
6639
+ "source"
6640
+ ],
6641
+ "additionalProperties": false,
6642
+ "properties": {
6643
+ "caption": {
6644
+ "type": "string",
6645
+ "minLength": 1
6646
+ },
6647
+ "lang": {
6648
+ "type": "string",
6649
+ "minLength": 1
6650
+ },
6651
+ "source": {
6652
+ "type": "string"
6653
+ }
6654
+ }
6655
+ }
6656
+ },
6657
+ "outcome": {
6658
+ "description": "What appears on disk or in the terminal after running the code. An item is a string, or `{ fact, field?, text? }` that names a fact: `field` is a dotted path in it and `text` is what to show, such as a sentence rendered from the fact. In a `.ts` example file write `ref(fact)`, `ref(fact, \"a.b\")` or `statementFrom(fact, render)`, and the build writes the object. `fact` must exist (`unknown-fact-id`), and `field` must be in at least one row of the fact (`ref`).",
6659
+ "type": "array",
6660
+ "items": {
6661
+ "oneOf": [
6662
+ {
6663
+ "type": "string",
6664
+ "minLength": 1
6665
+ },
6666
+ {
6667
+ "type": "object",
6668
+ "required": [
6669
+ "fact"
6670
+ ],
6671
+ "additionalProperties": false,
6672
+ "properties": {
6673
+ "fact": {
6674
+ "type": "string",
6675
+ "minLength": 1
6676
+ },
6677
+ "field": {
6678
+ "type": "string",
6679
+ "minLength": 1
6680
+ },
6681
+ "text": {
6682
+ "description": "A string, or one string per language. Prompts take `zh-TW` and fall back to `en`.",
6683
+ "oneOf": [
6684
+ {
4951
6685
  "type": "string",
4952
6686
  "minLength": 1
4953
6687
  },
4954
- "text": {
4955
- "description": "A string, or one string per language. Prompts take `zh-TW` and fall back to `en`.",
4956
- "oneOf": [
4957
- {
6688
+ {
6689
+ "type": "object",
6690
+ "properties": {
6691
+ "en": {
4958
6692
  "type": "string",
4959
6693
  "minLength": 1
4960
6694
  },
4961
- {
4962
- "type": "object",
4963
- "properties": {
4964
- "en": {
4965
- "type": "string",
4966
- "minLength": 1
4967
- },
4968
- "zh-TW": {
4969
- "type": "string",
4970
- "minLength": 1
4971
- }
4972
- },
4973
- "additionalProperties": false,
4974
- "minProperties": 1
6695
+ "zh-TW": {
6696
+ "type": "string",
6697
+ "minLength": 1
4975
6698
  }
4976
- ]
6699
+ },
6700
+ "additionalProperties": false,
6701
+ "minProperties": 1
4977
6702
  }
4978
- }
6703
+ ]
4979
6704
  }
4980
- ]
4981
- }
4982
- },
4983
- "points": {
4984
- "type": "array",
4985
- "items": {
4986
- "type": "string",
4987
- "minLength": 1
6705
+ }
4988
6706
  }
4989
- },
4990
- "facts": {
4991
- "type": "array",
4992
- "minItems": 1,
4993
- "items": {
4994
- "type": "string",
4995
- "minLength": 1
4996
- },
4997
- "description": "Ids of the facts the scenario demonstrates. Every id must exist."
4998
- }
6707
+ ]
6708
+ }
6709
+ },
6710
+ "points": {
6711
+ "type": "array",
6712
+ "items": {
6713
+ "type": "string",
6714
+ "minLength": 1
4999
6715
  }
6716
+ },
6717
+ "facts": {
6718
+ "type": "array",
6719
+ "minItems": 1,
6720
+ "items": {
6721
+ "type": "string",
6722
+ "minLength": 1
6723
+ },
6724
+ "description": "Ids of the facts the scenario demonstrates. Every id must exist."
6725
+ }
6726
+ }
6727
+ }
6728
+ }
6729
+ }
6730
+ }
6731
+ }
6732
+ },
6733
+ {
6734
+ "id": "fact-kit.input-files",
6735
+ "topics": [
6736
+ "pin",
6737
+ "merge-since"
6738
+ ],
6739
+ "title": {
6740
+ "en": "The files that pin and merge-since read"
6741
+ },
6742
+ "description": {
6743
+ "en": "How the code works today, which a reader of the source needs to tell a mistake from a rule."
6744
+ },
6745
+ "when": {
6746
+ "since": "0.7.0"
6747
+ },
6748
+ "content": {
6749
+ "value": {
6750
+ "pin": {
6751
+ "reads": "Every code file (`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`) under the facts directory, except `<facts-dir>/_lib` and everything below it."
6752
+ },
6753
+ "merge-since": {
6754
+ "unmerged": "The files that `git diff --name-only --diff-filter=U` lists, only those under `--cwd`. Of these, a file that has conflict markers gets its conflict blocks settled, whatever its extension.",
6755
+ "changed": "The code files under `--cwd` that differ from our side (`HEAD`, or the first parent when the merge is already committed), except `.d.ts`. A row that only the merged-in side has is rewritten in them.",
6756
+ "not": "It does not read every code file under `--cwd`, and it does not read a file outside it."
6757
+ }
6758
+ }
6759
+ },
6760
+ "tool": "fact-kit",
6761
+ "source": {
6762
+ "kind": "published"
6763
+ }
6764
+ },
6765
+ {
6766
+ "id": "fact-kit.check-index-input",
6767
+ "topics": [
6768
+ "check",
6769
+ "cli"
6770
+ ],
6771
+ "title": {
6772
+ "en": "What check --index reads"
6773
+ },
6774
+ "description": {
6775
+ "en": "The paths `--index` takes, and how each is read."
6776
+ },
6777
+ "when": {
6778
+ "since": "0.7.0"
6779
+ },
6780
+ "content": {
6781
+ "value": {
6782
+ "repeatable": "`--index <path>` may be given any number of times, and `check` reads every path in one run. In the config the same paths are `indexFiles`.",
6783
+ "reads": "A path that is a directory is read as `<dir>/index.json`, and any other path is read as the index file itself. The `schemas/` directory next to the index file is read too.",
6784
+ "unreadable": "A file that can not be read or parsed as JSON exits with 2."
6785
+ }
6786
+ },
6787
+ "tool": "fact-kit",
6788
+ "source": {
6789
+ "kind": "published"
6790
+ }
6791
+ },
6792
+ {
6793
+ "id": "fact-kit.check-id-table",
6794
+ "topics": [
6795
+ "check"
6796
+ ],
6797
+ "title": {
6798
+ "en": "One table of fact ids for the sources and every index of a check run"
6799
+ },
6800
+ "description": {
6801
+ "en": "Where `duplicate-id` comes from when `check` reads more than one index."
6802
+ },
6803
+ "when": {
6804
+ "since": "0.7.0"
6805
+ },
6806
+ "content": {
6807
+ "value": {
6808
+ "table": "One table of fact ids serves the whole run. The facts built from the sources come first, then the facts of each `--index` in the order given.",
6809
+ "duplicate": "The second time an id appears in that table, wherever it comes from, `check` reports `duplicate-id` at the later one and names the first with \"also in\". The first is kept.",
6810
+ "sourceAndBuild": "So a run that reads the sources and also the built output of the same package (`--index dist/<entry>`) reports every fact of the output.",
6811
+ "twoIndexes": "Two `--index` that hold the same id report it too, once for each extra copy."
6812
+ }
6813
+ },
6814
+ "tool": "fact-kit",
6815
+ "source": {
6816
+ "kind": "published"
6817
+ }
6818
+ },
6819
+ {
6820
+ "id": "fact-kit.impl-rules-basis",
6821
+ "topics": [
6822
+ "check"
6823
+ ],
6824
+ "title": {
6825
+ "en": "What impl-imports-facts and impl-reads-facts-dist judge by"
6826
+ },
6827
+ "variants": [
6828
+ {
6829
+ "since": "0.7.0",
6830
+ "content": {
6831
+ "value": {
6832
+ "impl-imports-facts": {
6833
+ "basis": "The package name of an `import` or `export ... from` specifier, a dynamic `import()` and a `require()` call in a code file of `implDirs`. The name ends in `-facts`. Relative and absolute specifiers, and `node:` ones, have no package name and are never reported."
6834
+ },
6835
+ "impl-reads-facts-dist": {
6836
+ "basis": "A string, or the fixed part of a template, in a code file of `implDirs` that holds `facts/dist` as path parts (bounded by the start, the end, `/` or `\\`). It matches the literal text."
6837
+ }
6838
+ }
6839
+ }
6840
+ },
6841
+ {
6842
+ "since": "0.11.0",
6843
+ "content": {
6844
+ "value": {
6845
+ "impl-imports-facts": {
6846
+ "basis": "The package name of an `import` or `export ... from` specifier, a dynamic `import()` and a `require()` call in a code file of `implDirs`. The name ends in `-facts`, with the publish target suffix `.<target>` allowed. Relative and absolute specifiers, and `node:` ones, have no package name and are never reported."
6847
+ },
6848
+ "impl-reads-facts-dist": {
6849
+ "basis": "A string, or the fixed part of a template, in a code file of `implDirs` that holds `facts/dist` as path parts (bounded by the start, the end, `/` or `\\`). It matches the literal text."
6850
+ }
6851
+ }
6852
+ }
6853
+ },
6854
+ {
6855
+ "since": "0.12.0-alpha.1",
6856
+ "content": {
6857
+ "value": {
6858
+ "impl-imports-facts": {
6859
+ "basis": "The specifier of an `import` or `export ... from`, a dynamic `import()` and a `require()` call in a code file of `implDirs`. It is reported when the package name ends in `-facts`, with the publish target suffix `.<target>` allowed, or when it matches one of `violations`. A specifier is reported once. `node:` specifiers are never reported, and a relative or absolute specifier that holds `facts/dist` as path parts is left to `impl-reads-facts-dist`.",
6860
+ "violations": [
6861
+ {
6862
+ "kind": "facts-file",
6863
+ "rule": "The specifier ends in `.facts.ts`."
6864
+ },
6865
+ {
6866
+ "kind": "doc-file",
6867
+ "rule": "The specifier ends in `.doc.ts`."
6868
+ },
6869
+ {
6870
+ "kind": "no-extension",
6871
+ "rule": "The specifier names such a file without the extension: it ends in `.facts` or `.doc`."
6872
+ },
6873
+ {
6874
+ "kind": "relative-facts-dir",
6875
+ "rule": "A relative specifier that resolves to a path inside the `factsDir` of this package."
6876
+ },
6877
+ {
6878
+ "kind": "absolute-facts-dir",
6879
+ "rule": "An absolute specifier that points to a path inside the `factsDir` of this package."
5000
6880
  }
6881
+ ]
6882
+ },
6883
+ "impl-reads-facts-dist": {
6884
+ "basis": "A string, or the fixed part of a template, in a code file of `implDirs` that holds `facts/dist` as path parts (bounded by the start, the end, `/` or `\\`). It matches the literal text."
6885
+ }
6886
+ }
6887
+ }
6888
+ }
6889
+ ],
6890
+ "tool": "fact-kit",
6891
+ "source": {
6892
+ "kind": "published"
6893
+ },
6894
+ "content": {
6895
+ "value": {
6896
+ "impl-imports-facts": {
6897
+ "basis": "The specifier of an `import` or `export ... from`, a dynamic `import()` and a `require()` call in a code file of `implDirs`. It is reported when the package name ends in `-facts`, with the publish target suffix `.<target>` allowed, or when it matches one of `violations`. A specifier is reported once. `node:` specifiers are never reported, and a relative or absolute specifier that holds `facts/dist` as path parts is left to `impl-reads-facts-dist`.",
6898
+ "violations": [
6899
+ {
6900
+ "kind": "facts-file",
6901
+ "rule": "The specifier ends in `.facts.ts`."
6902
+ },
6903
+ {
6904
+ "kind": "doc-file",
6905
+ "rule": "The specifier ends in `.doc.ts`."
6906
+ },
6907
+ {
6908
+ "kind": "no-extension",
6909
+ "rule": "The specifier names such a file without the extension: it ends in `.facts` or `.doc`."
6910
+ },
6911
+ {
6912
+ "kind": "relative-facts-dir",
6913
+ "rule": "A relative specifier that resolves to a path inside the `factsDir` of this package."
6914
+ },
6915
+ {
6916
+ "kind": "absolute-facts-dir",
6917
+ "rule": "An absolute specifier that points to a path inside the `factsDir` of this package."
6918
+ }
6919
+ ]
6920
+ },
6921
+ "impl-reads-facts-dist": {
6922
+ "basis": "A string, or the fixed part of a template, in a code file of `implDirs` that holds `facts/dist` as path parts (bounded by the start, the end, `/` or `\\`). It matches the literal text."
6923
+ }
6924
+ }
6925
+ }
6926
+ },
6927
+ {
6928
+ "id": "fact-kit.facts-file-collection",
6929
+ "topics": [
6930
+ "build",
6931
+ "authoring"
6932
+ ],
6933
+ "title": {
6934
+ "en": "How build collects *.facts.ts into an entry"
6935
+ },
6936
+ "description": {
6937
+ "en": "The facts of an entry may be split into `*.facts.ts` files that the build collects, so `index.ts` does not import them."
6938
+ },
6939
+ "variants": [
6940
+ {
6941
+ "since": "0.12.0-alpha.1",
6942
+ "content": {
6943
+ "value": {
6944
+ "entryFile": "The `index.ts` of a directory under the facts directory declares the entry, as before. Its default export holds the fields of the entry (`describes`, `publish`, `formatVersion`), and `facts` is optional. The facts directory itself is not an entry.",
6945
+ "entryName": "The path of the directory of `index.ts` relative to the facts directory, as before. A `_` or `.` directory is not searched for entries.",
6946
+ "exportPath": "`<entry>/index.json`, as before, so a reader of the built package, such as the `factSet` of prompt-kit, changes nothing.",
6947
+ "collectedFiles": "Every `*.facts.ts` in the directory of the entry and in its subdirectories. A subdirectory that has an `index.ts` of its own is another entry, and the files below it belong to that entry.",
6948
+ "fileExport": "The default export of a `*.facts.ts` is an array of facts, the same items as `facts` of `index.ts`.",
6949
+ "order": [
6950
+ "the `facts` of `index.ts`, when it has any",
6951
+ "the facts of the `*.facts.ts` files, the files sorted by their path relative to the directory of the entry in code-unit order, so the built index is the same on every machine"
6952
+ ],
6953
+ "reported": {
6954
+ "code": "facts-file-orphan",
6955
+ "when": [
6956
+ "A `*.facts.ts` that is under no entry, including one directly in the facts directory.",
6957
+ "A `*.facts.ts` in a directory whose name starts with `_`, or below one, because such a directory is not searched."
6958
+ ]
6959
+ },
6960
+ "duplicates": "A fact that `index.ts` imports and a file also gives is two facts with one id, and the existing `duplicate-id` reports it."
6961
+ }
6962
+ }
6963
+ }
6964
+ ],
6965
+ "tool": "fact-kit",
6966
+ "source": {
6967
+ "kind": "published"
6968
+ },
6969
+ "content": {
6970
+ "value": {
6971
+ "entryFile": "The `index.ts` of a directory under the facts directory declares the entry, as before. Its default export holds the fields of the entry (`describes`, `publish`, `formatVersion`), and `facts` is optional. The facts directory itself is not an entry.",
6972
+ "entryName": "The path of the directory of `index.ts` relative to the facts directory, as before. A `_` or `.` directory is not searched for entries.",
6973
+ "exportPath": "`<entry>/index.json`, as before, so a reader of the built package, such as the `factSet` of prompt-kit, changes nothing.",
6974
+ "collectedFiles": "Every `*.facts.ts` in the directory of the entry and in its subdirectories. A subdirectory that has an `index.ts` of its own is another entry, and the files below it belong to that entry.",
6975
+ "fileExport": "The default export of a `*.facts.ts` is an array of facts, the same items as `facts` of `index.ts`.",
6976
+ "order": [
6977
+ "the `facts` of `index.ts`, when it has any",
6978
+ "the facts of the `*.facts.ts` files, the files sorted by their path relative to the directory of the entry in code-unit order, so the built index is the same on every machine"
6979
+ ],
6980
+ "reported": {
6981
+ "code": "facts-file-orphan",
6982
+ "when": [
6983
+ "A `*.facts.ts` that is under no entry, including one directly in the facts directory.",
6984
+ "A `*.facts.ts` in a directory whose name starts with `_`, or below one, because such a directory is not searched."
6985
+ ]
6986
+ },
6987
+ "duplicates": "A fact that `index.ts` imports and a file also gives is two facts with one id, and the existing `duplicate-id` reports it."
6988
+ }
6989
+ }
6990
+ },
6991
+ {
6992
+ "id": "fact-kit.split-rules",
6993
+ "topics": [
6994
+ "check",
6995
+ "config"
6996
+ ],
6997
+ "title": {
6998
+ "en": "Split rules for *.facts.ts, off by default"
6999
+ },
7000
+ "description": {
7001
+ "en": "Four rules of `check` on how the facts of an entry are split into files and how `tool` is written. A package turns them on with `splitRules` in `fact-kit.config.json`."
7002
+ },
7003
+ "variants": [
7004
+ {
7005
+ "since": "0.12.0-alpha.1",
7006
+ "content": {
7007
+ "value": {
7008
+ "enabledBy": {
7009
+ "setting": "splitRules",
7010
+ "default": false,
7011
+ "summary": "The four rules are off. They run only when `fact-kit.config.json` sets `splitRules` to `true`."
7012
+ },
7013
+ "scope": "Only the entries that have a `*.facts.ts`. `split-topic`, `split-size` and `split-tool` read those `*.facts.ts` files only, and `split-index` reads the `index.ts` of the same entry.",
7014
+ "limit": {
7015
+ "setting": "maxFactsPerFile",
7016
+ "default": 40,
7017
+ "summary": "The most facts one `*.facts.ts` may hold."
7018
+ },
7019
+ "rules": [
7020
+ {
7021
+ "code": "split-topic",
7022
+ "rule": "The facts of one `*.facts.ts` have more than one value of `topics[0]`."
7023
+ },
7024
+ {
7025
+ "code": "split-size",
7026
+ "rule": "A `*.facts.ts` holds more facts than `maxFactsPerFile` (40 unless the config says otherwise)."
7027
+ },
7028
+ {
7029
+ "code": "split-index",
7030
+ "rule": "The `index.ts` of an entry holds a fact object (an object literal with `id` and `content`) instead of leaving the facts to the `*.facts.ts` files."
7031
+ },
7032
+ {
7033
+ "code": "split-tool",
7034
+ "rule": "A `tool` is written anywhere in a `*.facts.ts` except in the argument of `factsOf(`."
5001
7035
  }
5002
- }
7036
+ ]
5003
7037
  }
5004
7038
  }
5005
7039
  }
@@ -5009,170 +7043,176 @@
5009
7043
  "kind": "published"
5010
7044
  },
5011
7045
  "content": {
5012
- "schema": {
5013
- "$schema": "https://json-schema.org/draft/2020-12/schema",
5014
- "$id": "urn:fact-kit:example-group",
5015
- "title": "Example group",
5016
- "type": "object",
5017
- "required": [
5018
- "id",
5019
- "name",
5020
- "situation",
5021
- "claim",
5022
- "scenarios"
5023
- ],
5024
- "additionalProperties": false,
5025
- "properties": {
5026
- "id": {
5027
- "type": "string",
5028
- "pattern": "^[a-z0-9][a-z0-9-]*$"
5029
- },
5030
- "name": {
5031
- "type": "string",
5032
- "minLength": 1
5033
- },
5034
- "situation": {
5035
- "type": "string",
5036
- "minLength": 1,
5037
- "description": "The situation the group answers."
7046
+ "value": {
7047
+ "enabledBy": {
7048
+ "setting": "splitRules",
7049
+ "default": false,
7050
+ "summary": "The four rules are off. They run only when `fact-kit.config.json` sets `splitRules` to `true`."
7051
+ },
7052
+ "scope": "Only the entries that have a `*.facts.ts`. `split-topic`, `split-size` and `split-tool` read those `*.facts.ts` files only, and `split-index` reads the `index.ts` of the same entry.",
7053
+ "limit": {
7054
+ "setting": "maxFactsPerFile",
7055
+ "default": 40,
7056
+ "summary": "The most facts one `*.facts.ts` may hold."
7057
+ },
7058
+ "rules": [
7059
+ {
7060
+ "code": "split-topic",
7061
+ "rule": "The facts of one `*.facts.ts` have more than one value of `topics[0]`."
5038
7062
  },
5039
- "claim": {
5040
- "type": "string",
5041
- "minLength": 1,
5042
- "description": "What the group shows, one sentence."
7063
+ {
7064
+ "code": "split-size",
7065
+ "rule": "A `*.facts.ts` holds more facts than `maxFactsPerFile` (40 unless the config says otherwise)."
5043
7066
  },
5044
- "facts": {
5045
- "type": "array",
5046
- "items": {
5047
- "type": "string",
5048
- "minLength": 1
5049
- },
5050
- "description": "Fact ids the whole group demonstrates, on top of those of its scenarios."
7067
+ {
7068
+ "code": "split-index",
7069
+ "rule": "The `index.ts` of an entry holds a fact object (an object literal with `id` and `content`) instead of leaving the facts to the `*.facts.ts` files."
5051
7070
  },
5052
- "scenarios": {
5053
- "type": "array",
5054
- "minItems": 1,
5055
- "items": {
5056
- "type": "object",
5057
- "required": [
5058
- "title",
5059
- "situation",
5060
- "code",
5061
- "outcome",
5062
- "points",
5063
- "facts"
5064
- ],
5065
- "additionalProperties": false,
5066
- "properties": {
5067
- "title": {
5068
- "type": "string",
5069
- "minLength": 1
5070
- },
5071
- "situation": {
5072
- "type": "string",
5073
- "minLength": 1,
5074
- "description": "What the reader is trying to do, one sentence."
5075
- },
5076
- "code": {
5077
- "type": "array",
5078
- "description": "Run by the tool’s own tests, not by fact-kit.",
5079
- "items": {
5080
- "type": "object",
5081
- "required": [
5082
- "caption",
5083
- "lang",
5084
- "source"
5085
- ],
5086
- "additionalProperties": false,
5087
- "properties": {
5088
- "caption": {
5089
- "type": "string",
5090
- "minLength": 1
5091
- },
5092
- "lang": {
5093
- "type": "string",
5094
- "minLength": 1
5095
- },
5096
- "source": {
5097
- "type": "string"
5098
- }
5099
- }
5100
- }
5101
- },
5102
- "outcome": {
5103
- "description": "What appears on disk or in the terminal after running the code. An item is a string, or `{ fact, field?, text? }` that names a fact: `field` is a dotted path in it and `text` is what to show, such as a sentence rendered from the fact. In a `.ts` example file write `ref(fact)`, `ref(fact, \"a.b\")` or `statementFrom(fact, render)`, and the build writes the object. `fact` must exist (`unknown-fact-id`), and `field` must be in at least one row of the fact (`ref`).",
5104
- "type": "array",
5105
- "items": {
5106
- "oneOf": [
5107
- {
5108
- "type": "string",
5109
- "minLength": 1
5110
- },
5111
- {
5112
- "type": "object",
5113
- "required": [
5114
- "fact"
5115
- ],
5116
- "additionalProperties": false,
5117
- "properties": {
5118
- "fact": {
5119
- "type": "string",
5120
- "minLength": 1
5121
- },
5122
- "field": {
5123
- "type": "string",
5124
- "minLength": 1
5125
- },
5126
- "text": {
5127
- "description": "A string, or one string per language. Prompts take `zh-TW` and fall back to `en`.",
5128
- "oneOf": [
5129
- {
5130
- "type": "string",
5131
- "minLength": 1
5132
- },
5133
- {
5134
- "type": "object",
5135
- "properties": {
5136
- "en": {
5137
- "type": "string",
5138
- "minLength": 1
5139
- },
5140
- "zh-TW": {
5141
- "type": "string",
5142
- "minLength": 1
5143
- }
5144
- },
5145
- "additionalProperties": false,
5146
- "minProperties": 1
5147
- }
5148
- ]
5149
- }
5150
- }
5151
- }
5152
- ]
5153
- }
5154
- },
5155
- "points": {
5156
- "type": "array",
5157
- "items": {
5158
- "type": "string",
5159
- "minLength": 1
5160
- }
5161
- },
5162
- "facts": {
5163
- "type": "array",
5164
- "minItems": 1,
5165
- "items": {
5166
- "type": "string",
5167
- "minLength": 1
5168
- },
5169
- "description": "Ids of the facts the scenario demonstrates. Every id must exist."
5170
- }
7071
+ {
7072
+ "code": "split-tool",
7073
+ "rule": "A `tool` is written anywhere in a `*.facts.ts` except in the argument of `factsOf(`."
7074
+ }
7075
+ ]
7076
+ }
7077
+ }
7078
+ },
7079
+ {
7080
+ "id": "fact-kit.row-data-keys",
7081
+ "topics": [
7082
+ "pin",
7083
+ "merge-since",
7084
+ "config"
7085
+ ],
7086
+ "title": {
7087
+ "en": "Keys that pin and merge-since treat as data"
7088
+ },
7089
+ "description": {
7090
+ "en": "The setting that decides which property names `pin` and `merge-since` do not read rows in."
7091
+ },
7092
+ "variants": [
7093
+ {
7094
+ "since": "0.12.0-alpha.1",
7095
+ "content": {
7096
+ "value": {
7097
+ "setting": "dataKeys",
7098
+ "defaultKeys": [
7099
+ "content",
7100
+ "value",
7101
+ "schema",
7102
+ "statement",
7103
+ "add",
7104
+ "replace",
7105
+ "remove",
7106
+ "set"
7107
+ ],
7108
+ "summary": "The property names whose object value is data, not a row, so `pin` and `merge-since` do not read a `since` inside it. `dataKeys` in the config replaces the default list, it does not add to it, and without the setting the default list applies.",
7109
+ "readBy": [
7110
+ "pin",
7111
+ "merge-since"
7112
+ ],
7113
+ "api": [
7114
+ "findRows(program, { dataKeys? })",
7115
+ "PinOptions.dataKeys",
7116
+ "MergeSinceOptions.dataKeys"
7117
+ ]
7118
+ }
7119
+ }
7120
+ }
7121
+ ],
7122
+ "tool": "fact-kit",
7123
+ "source": {
7124
+ "kind": "published"
7125
+ },
7126
+ "content": {
7127
+ "value": {
7128
+ "setting": "dataKeys",
7129
+ "defaultKeys": [
7130
+ "content",
7131
+ "value",
7132
+ "schema",
7133
+ "statement",
7134
+ "add",
7135
+ "replace",
7136
+ "remove",
7137
+ "set"
7138
+ ],
7139
+ "summary": "The property names whose object value is data, not a row, so `pin` and `merge-since` do not read a `since` inside it. `dataKeys` in the config replaces the default list, it does not add to it, and without the setting the default list applies.",
7140
+ "readBy": [
7141
+ "pin",
7142
+ "merge-since"
7143
+ ],
7144
+ "api": [
7145
+ "findRows(program, { dataKeys? })",
7146
+ "PinOptions.dataKeys",
7147
+ "MergeSinceOptions.dataKeys"
7148
+ ]
7149
+ }
7150
+ }
7151
+ },
7152
+ {
7153
+ "id": "fact-kit.impact-extractors",
7154
+ "topics": [
7155
+ "diff",
7156
+ "authoring"
7157
+ ],
7158
+ "title": {
7159
+ "en": "Reference extractors of impactOf"
7160
+ },
7161
+ "description": {
7162
+ "en": "How a package adds the way `impactOf` finds references to a fact in a kind of file the built-in extractors do not read."
7163
+ },
7164
+ "variants": [
7165
+ {
7166
+ "since": "0.12.0-alpha.1",
7167
+ "content": {
7168
+ "value": {
7169
+ "scope": "The extractors apply to `impactOf` and `diff --impact` in a package, aggregate or not (with or without `aggregate` in the config). Without `aggregate`, `impactOf` reads the indexes the package built itself in `<outDir>/<entry>/index.json` instead of failing.",
7170
+ "register": {
7171
+ "name": "registerImpactExtractor",
7172
+ "signature": "registerImpactExtractor(extractor: ImpactExtractor) => () => void",
7173
+ "summary": "Adds an extractor for the rest of the process and returns a function that removes it. An extractor with the name of one already registered replaces it."
7174
+ },
7175
+ "extractor": {
7176
+ "type": "ImpactExtractor",
7177
+ "fields": {
7178
+ "name": "A string. The built-in extractors are `markdown` and `typescript`.",
7179
+ "extensions": "File extensions with the dot, such as `.mdx`. The extractor reads the files of `docsDirs` that end in one.",
7180
+ "extract": "(input: { file: string; text: string; lookup(reference: string): string | undefined }) => { line: number; id: string }[]. `lookup` returns the id to report for a reference to the fact asked about or to a fact computed from it, and `undefined` for any other."
5171
7181
  }
5172
- }
7182
+ },
7183
+ "options": {
7184
+ "extractors": "`impactOf(id, { extractors })` takes extractors for that call only. They run after the registered ones, and a name given twice keeps the last."
7185
+ },
7186
+ "result": "Each `{ line, id }` becomes an item `{ file, line, id }` of `docs`, as the built-in extractors do."
5173
7187
  }
5174
7188
  }
5175
7189
  }
7190
+ ],
7191
+ "tool": "fact-kit",
7192
+ "source": {
7193
+ "kind": "published"
7194
+ },
7195
+ "content": {
7196
+ "value": {
7197
+ "scope": "The extractors apply to `impactOf` and `diff --impact` in a package, aggregate or not (with or without `aggregate` in the config). Without `aggregate`, `impactOf` reads the indexes the package built itself in `<outDir>/<entry>/index.json` instead of failing.",
7198
+ "register": {
7199
+ "name": "registerImpactExtractor",
7200
+ "signature": "registerImpactExtractor(extractor: ImpactExtractor) => () => void",
7201
+ "summary": "Adds an extractor for the rest of the process and returns a function that removes it. An extractor with the name of one already registered replaces it."
7202
+ },
7203
+ "extractor": {
7204
+ "type": "ImpactExtractor",
7205
+ "fields": {
7206
+ "name": "A string. The built-in extractors are `markdown` and `typescript`.",
7207
+ "extensions": "File extensions with the dot, such as `.mdx`. The extractor reads the files of `docsDirs` that end in one.",
7208
+ "extract": "(input: { file: string; text: string; lookup(reference: string): string | undefined }) => { line: number; id: string }[]. `lookup` returns the id to report for a reference to the fact asked about or to a fact computed from it, and `undefined` for any other."
7209
+ }
7210
+ },
7211
+ "options": {
7212
+ "extractors": "`impactOf(id, { extractors })` takes extractors for that call only. They run after the registered ones, and a name given twice keeps the last."
7213
+ },
7214
+ "result": "Each `{ line, id }` becomes an item `{ file, line, id }` of `docs`, as the built-in extractors do."
7215
+ }
5176
7216
  }
5177
7217
  }
5178
7218
  ]