fact-kit-facts 0.4.0 → 0.5.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 +383 -6
- package/package.json +1 -1
package/dist/index.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"entry": ".",
|
|
5
5
|
"component": "fact-kit-facts.npm",
|
|
6
6
|
"describes": {
|
|
7
|
-
"fact-kit-js": "0.
|
|
7
|
+
"fact-kit-js": "0.10.0"
|
|
8
8
|
},
|
|
9
9
|
"publish": {
|
|
10
10
|
"target": "npm",
|
|
@@ -3681,6 +3681,251 @@
|
|
|
3681
3681
|
]
|
|
3682
3682
|
}
|
|
3683
3683
|
}
|
|
3684
|
+
},
|
|
3685
|
+
{
|
|
3686
|
+
"since": "0.10.0-alpha.1",
|
|
3687
|
+
"content": {
|
|
3688
|
+
"value": {
|
|
3689
|
+
"module": "fact-kit",
|
|
3690
|
+
"exports": [
|
|
3691
|
+
{
|
|
3692
|
+
"name": "defineFacts",
|
|
3693
|
+
"signature": "defineFacts(module: FactsModule) => FactsModule",
|
|
3694
|
+
"summary": "Identity helper that types the default export of `facts/<entry>/index.ts`."
|
|
3695
|
+
},
|
|
3696
|
+
{
|
|
3697
|
+
"name": "history",
|
|
3698
|
+
"signature": "history(...rows: HistoryRow[]) => HistoryVariants",
|
|
3699
|
+
"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`."
|
|
3700
|
+
},
|
|
3701
|
+
{
|
|
3702
|
+
"name": "keyed",
|
|
3703
|
+
"signature": "keyed<T>(items: T[], keys?: string[]) => T[]",
|
|
3704
|
+
"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."
|
|
3705
|
+
},
|
|
3706
|
+
{
|
|
3707
|
+
"name": "factLink",
|
|
3708
|
+
"signature": "factLink(fact: Fact) => string",
|
|
3709
|
+
"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`."
|
|
3710
|
+
},
|
|
3711
|
+
{
|
|
3712
|
+
"name": "derive",
|
|
3713
|
+
"signature": "derive(upstreamSpec: string, id: string, map?: (upstream: Fact) => Partial<Fact>) => DerivedFact",
|
|
3714
|
+
"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."
|
|
3715
|
+
},
|
|
3716
|
+
{
|
|
3717
|
+
"name": "defineExamples",
|
|
3718
|
+
"signature": "defineExamples(examples: ExampleGroupSource | ExampleGroupSource[]) => typeof examples",
|
|
3719
|
+
"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? }`."
|
|
3720
|
+
},
|
|
3721
|
+
{
|
|
3722
|
+
"name": "exampleFactRefs",
|
|
3723
|
+
"signature": "exampleFactRefs(group: ExampleGroup) => { id: string; location: string; in: 'facts' | 'outcome'; field?: string }[]",
|
|
3724
|
+
"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."
|
|
3725
|
+
},
|
|
3726
|
+
{
|
|
3727
|
+
"name": "flattenSchema",
|
|
3728
|
+
"signature": "flattenSchema(schema: JsonSchema) => SchemaRow[]",
|
|
3729
|
+
"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."
|
|
3730
|
+
},
|
|
3731
|
+
{
|
|
3732
|
+
"name": "schemaRowsToMarkdown",
|
|
3733
|
+
"signature": "schemaRowsToMarkdown(rows: SchemaRow[]) => string",
|
|
3734
|
+
"summary": "A Markdown table of the rows, with Field, Type, Required, Description and Extensions columns."
|
|
3735
|
+
},
|
|
3736
|
+
{
|
|
3737
|
+
"name": "valueListToMarkdown",
|
|
3738
|
+
"signature": "valueListToMarkdown(fact: Fact, options?: { columns?: string[] }) => string",
|
|
3739
|
+
"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."
|
|
3740
|
+
},
|
|
3741
|
+
{
|
|
3742
|
+
"name": "replaceFactBlocks",
|
|
3743
|
+
"signature": "replaceFactBlocks(text: string, blocks: Record<string, string>) => { text: string; changed: boolean }",
|
|
3744
|
+
"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."
|
|
3745
|
+
},
|
|
3746
|
+
{
|
|
3747
|
+
"name": "readFacts",
|
|
3748
|
+
"signature": "readFacts(spec, options?) => FactReader",
|
|
3749
|
+
"summary": "Reads an installed fact package. Parameters and members are in `fact-kit.read-facts`."
|
|
3750
|
+
},
|
|
3751
|
+
{
|
|
3752
|
+
"name": "selectFacts",
|
|
3753
|
+
"signature": "selectFacts(index, { version?, include?, platform?, os? }) => SelectedFact[]",
|
|
3754
|
+
"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."
|
|
3755
|
+
},
|
|
3756
|
+
{
|
|
3757
|
+
"name": "factsOf",
|
|
3758
|
+
"signature": "factsOf({ tool, source, prefix?, topics? }) => FactsFactory",
|
|
3759
|
+
"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."
|
|
3760
|
+
},
|
|
3761
|
+
{
|
|
3762
|
+
"name": "observedDoc",
|
|
3763
|
+
"signature": "observedDoc({ url: string, fetched: string }) => FactSource",
|
|
3764
|
+
"summary": "The source `{ kind: 'observed', basis: 'doc', url, fetched }` of a fact read from a page of the documentation."
|
|
3765
|
+
},
|
|
3766
|
+
{
|
|
3767
|
+
"name": "observedSpike",
|
|
3768
|
+
"signature": "observedSpike({ fetched: string, url?: string }) => FactSource",
|
|
3769
|
+
"summary": "The source `{ kind: 'observed', basis: 'spike', fetched }` of a fact seen in a trial run, with `url` when a page led to it."
|
|
3770
|
+
},
|
|
3771
|
+
{
|
|
3772
|
+
"name": "contentOf",
|
|
3773
|
+
"signature": "contentOf(fact: Fact, since?: string) => unknown",
|
|
3774
|
+
"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."
|
|
3775
|
+
},
|
|
3776
|
+
{
|
|
3777
|
+
"name": "statementFrom",
|
|
3778
|
+
"signature": "statementFrom(fact: Fact, render: (value) => Text, options?: { since?: string }) => BuiltStatement",
|
|
3779
|
+
"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."
|
|
3780
|
+
},
|
|
3781
|
+
{
|
|
3782
|
+
"name": "subsetOf",
|
|
3783
|
+
"signature": "subsetOf(parent: Fact, items: T[]) => T[]",
|
|
3784
|
+
"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."
|
|
3785
|
+
},
|
|
3786
|
+
{
|
|
3787
|
+
"name": "stateMachine",
|
|
3788
|
+
"signature": "stateMachine({ initial, states, transitions }) => StateMachine",
|
|
3789
|
+
"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`."
|
|
3790
|
+
},
|
|
3791
|
+
{
|
|
3792
|
+
"name": "relations",
|
|
3793
|
+
"signature": "relations({ nodes, edges }) => Relations",
|
|
3794
|
+
"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."
|
|
3795
|
+
},
|
|
3796
|
+
{
|
|
3797
|
+
"name": "sequence",
|
|
3798
|
+
"signature": "sequence({ participants, steps }) => Sequence",
|
|
3799
|
+
"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."
|
|
3800
|
+
},
|
|
3801
|
+
{
|
|
3802
|
+
"name": "stateMachineToMermaid",
|
|
3803
|
+
"signature": "stateMachineToMermaid(source: StateMachine | Fact) => string",
|
|
3804
|
+
"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."
|
|
3805
|
+
},
|
|
3806
|
+
{
|
|
3807
|
+
"name": "relationsToMermaid",
|
|
3808
|
+
"signature": "relationsToMermaid(source: Relations | Fact) => string",
|
|
3809
|
+
"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."
|
|
3810
|
+
},
|
|
3811
|
+
{
|
|
3812
|
+
"name": "sequenceToMermaid",
|
|
3813
|
+
"signature": "sequenceToMermaid(source: Sequence | UseCase | Fact) => string",
|
|
3814
|
+
"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."
|
|
3815
|
+
},
|
|
3816
|
+
{
|
|
3817
|
+
"name": "ref",
|
|
3818
|
+
"signature": "ref(fact: Fact, field?: string) => FactRef",
|
|
3819
|
+
"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."
|
|
3820
|
+
},
|
|
3821
|
+
{
|
|
3822
|
+
"name": "entity",
|
|
3823
|
+
"signature": "entity({ identity, fields, required? }) => EntitySchema",
|
|
3824
|
+
"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`."
|
|
3825
|
+
},
|
|
3826
|
+
{
|
|
3827
|
+
"name": "valueObject",
|
|
3828
|
+
"signature": "valueObject(fields, options?: { required? }) => ObjectSchema",
|
|
3829
|
+
"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."
|
|
3830
|
+
},
|
|
3831
|
+
{
|
|
3832
|
+
"name": "domainEvent",
|
|
3833
|
+
"signature": "domainEvent(fields, options?: { required? }) => ObjectSchema",
|
|
3834
|
+
"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`."
|
|
3835
|
+
},
|
|
3836
|
+
{
|
|
3837
|
+
"name": "aggregate",
|
|
3838
|
+
"signature": "aggregate({ root, members }) => Aggregate",
|
|
3839
|
+
"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."
|
|
3840
|
+
},
|
|
3841
|
+
{
|
|
3842
|
+
"name": "invariant",
|
|
3843
|
+
"signature": "invariant(subject: Fact, text: Text) => BuiltStatement",
|
|
3844
|
+
"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."
|
|
3845
|
+
},
|
|
3846
|
+
{
|
|
3847
|
+
"name": "useCase",
|
|
3848
|
+
"signature": "useCase({ input?, output?, steps, errors? }) => UseCase",
|
|
3849
|
+
"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."
|
|
3850
|
+
},
|
|
3851
|
+
{
|
|
3852
|
+
"name": "writeFormatted",
|
|
3853
|
+
"signature": "writeFormatted(file: string, text: string) => Promise<void>",
|
|
3854
|
+
"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`."
|
|
3855
|
+
},
|
|
3856
|
+
{
|
|
3857
|
+
"name": "stableJson",
|
|
3858
|
+
"signature": "stableJson(value: unknown) => string",
|
|
3859
|
+
"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."
|
|
3860
|
+
},
|
|
3861
|
+
{
|
|
3862
|
+
"name": "DRAFT_2020_12",
|
|
3863
|
+
"signature": "const DRAFT_2020_12: 'https://json-schema.org/draft/2020-12/schema'",
|
|
3864
|
+
"summary": "The `$schema` URL of JSON Schema 2020-12. It is the value `interfaceToJsonSchema` and `normalizeSchema` put in `$schema`."
|
|
3865
|
+
},
|
|
3866
|
+
{
|
|
3867
|
+
"name": "NormalizeOptions",
|
|
3868
|
+
"signature": "interface NormalizeOptions { describe?, drop?, notes? }",
|
|
3869
|
+
"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`."
|
|
3870
|
+
},
|
|
3871
|
+
{
|
|
3872
|
+
"name": "normalizeSchema",
|
|
3873
|
+
"signature": "normalizeSchema(input: JsonSchema, options?: NormalizeOptions) => JsonSchema",
|
|
3874
|
+
"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`."
|
|
3875
|
+
},
|
|
3876
|
+
{
|
|
3877
|
+
"name": "PinnedSource",
|
|
3878
|
+
"signature": "interface PinnedSource { repo, commit, path, sha256, license }",
|
|
3879
|
+
"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`."
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
"name": "sourceUrl",
|
|
3883
|
+
"signature": "sourceUrl(source: PinnedSource) => string",
|
|
3884
|
+
"summary": "The GitHub page of the pinned file at its commit (`blob/<commit>/<path>` of the repository), where a reader opens it."
|
|
3885
|
+
},
|
|
3886
|
+
{
|
|
3887
|
+
"name": "readPinned",
|
|
3888
|
+
"signature": "readPinned(source: PinnedSource, options: { cacheDir: string }) => Promise<string>",
|
|
3889
|
+
"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."
|
|
3890
|
+
}
|
|
3891
|
+
],
|
|
3892
|
+
"schemaRow": [
|
|
3893
|
+
{
|
|
3894
|
+
"name": "path",
|
|
3895
|
+
"type": "string",
|
|
3896
|
+
"summary": "`a.b` for a property, `a[]` for array items, `a.*` for additional properties."
|
|
3897
|
+
},
|
|
3898
|
+
{
|
|
3899
|
+
"name": "type",
|
|
3900
|
+
"type": "string",
|
|
3901
|
+
"summary": "Empty when the schema says nothing."
|
|
3902
|
+
},
|
|
3903
|
+
{
|
|
3904
|
+
"name": "required",
|
|
3905
|
+
"type": "boolean"
|
|
3906
|
+
},
|
|
3907
|
+
{
|
|
3908
|
+
"name": "description",
|
|
3909
|
+
"type": "string"
|
|
3910
|
+
},
|
|
3911
|
+
{
|
|
3912
|
+
"name": "values",
|
|
3913
|
+
"type": "unknown[]",
|
|
3914
|
+
"summary": "Present only when the field lists `enum` or `const` values, merged over `anyOf` / `oneOf` branches."
|
|
3915
|
+
},
|
|
3916
|
+
{
|
|
3917
|
+
"name": "extensions",
|
|
3918
|
+
"type": "Record<string, unknown>",
|
|
3919
|
+
"summary": "The `x-` keywords of the field."
|
|
3920
|
+
},
|
|
3921
|
+
{
|
|
3922
|
+
"name": "requiredWhen",
|
|
3923
|
+
"type": "{ path: string; values: unknown[] }",
|
|
3924
|
+
"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`."
|
|
3925
|
+
}
|
|
3926
|
+
]
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3684
3929
|
}
|
|
3685
3930
|
],
|
|
3686
3931
|
"tool": "fact-kit",
|
|
@@ -3850,6 +4095,46 @@
|
|
|
3850
4095
|
"name": "useCase",
|
|
3851
4096
|
"signature": "useCase({ input?, output?, steps, errors? }) => UseCase",
|
|
3852
4097
|
"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."
|
|
4098
|
+
},
|
|
4099
|
+
{
|
|
4100
|
+
"name": "writeFormatted",
|
|
4101
|
+
"signature": "writeFormatted(file: string, text: string) => Promise<void>",
|
|
4102
|
+
"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`."
|
|
4103
|
+
},
|
|
4104
|
+
{
|
|
4105
|
+
"name": "stableJson",
|
|
4106
|
+
"signature": "stableJson(value: unknown) => string",
|
|
4107
|
+
"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."
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
"name": "DRAFT_2020_12",
|
|
4111
|
+
"signature": "const DRAFT_2020_12: 'https://json-schema.org/draft/2020-12/schema'",
|
|
4112
|
+
"summary": "The `$schema` URL of JSON Schema 2020-12. It is the value `interfaceToJsonSchema` and `normalizeSchema` put in `$schema`."
|
|
4113
|
+
},
|
|
4114
|
+
{
|
|
4115
|
+
"name": "NormalizeOptions",
|
|
4116
|
+
"signature": "interface NormalizeOptions { describe?, drop?, notes? }",
|
|
4117
|
+
"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`."
|
|
4118
|
+
},
|
|
4119
|
+
{
|
|
4120
|
+
"name": "normalizeSchema",
|
|
4121
|
+
"signature": "normalizeSchema(input: JsonSchema, options?: NormalizeOptions) => JsonSchema",
|
|
4122
|
+
"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`."
|
|
4123
|
+
},
|
|
4124
|
+
{
|
|
4125
|
+
"name": "PinnedSource",
|
|
4126
|
+
"signature": "interface PinnedSource { repo, commit, path, sha256, license }",
|
|
4127
|
+
"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`."
|
|
4128
|
+
},
|
|
4129
|
+
{
|
|
4130
|
+
"name": "sourceUrl",
|
|
4131
|
+
"signature": "sourceUrl(source: PinnedSource) => string",
|
|
4132
|
+
"summary": "The GitHub page of the pinned file at its commit (`blob/<commit>/<path>` of the repository), where a reader opens it."
|
|
4133
|
+
},
|
|
4134
|
+
{
|
|
4135
|
+
"name": "readPinned",
|
|
4136
|
+
"signature": "readPinned(source: PinnedSource, options: { cacheDir: string }) => Promise<string>",
|
|
4137
|
+
"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."
|
|
3853
4138
|
}
|
|
3854
4139
|
],
|
|
3855
4140
|
"schemaRow": [
|
|
@@ -3900,7 +4185,93 @@
|
|
|
3900
4185
|
"en": "Converters and the optional TypeScript peer dependency"
|
|
3901
4186
|
},
|
|
3902
4187
|
"description": {
|
|
3903
|
-
"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."
|
|
4188
|
+
"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."
|
|
4189
|
+
},
|
|
4190
|
+
"variants": [
|
|
4191
|
+
{
|
|
4192
|
+
"since": "0.0.0",
|
|
4193
|
+
"content": {
|
|
4194
|
+
"value": {
|
|
4195
|
+
"requires": {
|
|
4196
|
+
"peerDependency": "typescript",
|
|
4197
|
+
"range": ">=7.1.0-beta",
|
|
4198
|
+
"optional": true,
|
|
4199
|
+
"install": "pnpm add -D typescript@7.1.0-beta"
|
|
4200
|
+
},
|
|
4201
|
+
"exports": [
|
|
4202
|
+
{
|
|
4203
|
+
"name": "readStringTuples",
|
|
4204
|
+
"signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
|
|
4205
|
+
"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."
|
|
4206
|
+
},
|
|
4207
|
+
{
|
|
4208
|
+
"name": "readStringTuplesFromFile",
|
|
4209
|
+
"signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
|
|
4210
|
+
"summary": "Reads the file and returns `readStringTuples` of it."
|
|
4211
|
+
},
|
|
4212
|
+
{
|
|
4213
|
+
"name": "interfaceToJsonSchema",
|
|
4214
|
+
"signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
|
|
4215
|
+
"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."
|
|
4216
|
+
},
|
|
4217
|
+
{
|
|
4218
|
+
"name": "readJsonSchemaFile",
|
|
4219
|
+
"signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
|
|
4220
|
+
"summary": "Reads a JSON Schema file. Does not need TypeScript."
|
|
4221
|
+
}
|
|
4222
|
+
]
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
},
|
|
4226
|
+
{
|
|
4227
|
+
"since": "0.10.0-alpha.1",
|
|
4228
|
+
"content": {
|
|
4229
|
+
"value": {
|
|
4230
|
+
"requires": {
|
|
4231
|
+
"peerDependency": "typescript",
|
|
4232
|
+
"range": ">=7.1.0-beta",
|
|
4233
|
+
"optional": true,
|
|
4234
|
+
"install": "pnpm add -D typescript@7.1.0-beta"
|
|
4235
|
+
},
|
|
4236
|
+
"exports": [
|
|
4237
|
+
{
|
|
4238
|
+
"name": "readStringTuples",
|
|
4239
|
+
"signature": "readStringTuples(source: string) => Promise<Record<string, string[]>>",
|
|
4240
|
+
"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."
|
|
4241
|
+
},
|
|
4242
|
+
{
|
|
4243
|
+
"name": "readStringTuplesFromFile",
|
|
4244
|
+
"signature": "readStringTuplesFromFile(path: string) => Promise<Record<string, string[]>>",
|
|
4245
|
+
"summary": "Reads the file and returns `readStringTuples` of it."
|
|
4246
|
+
},
|
|
4247
|
+
{
|
|
4248
|
+
"name": "interfaceToJsonSchema",
|
|
4249
|
+
"signature": "interfaceToJsonSchema({ path, type, tsconfig?, additionalProperties?, descriptions? }) => Promise<JsonSchema>",
|
|
4250
|
+
"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."
|
|
4251
|
+
},
|
|
4252
|
+
{
|
|
4253
|
+
"name": "readJsonSchemaFile",
|
|
4254
|
+
"signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
|
|
4255
|
+
"summary": "Reads a JSON Schema file. Does not need TypeScript."
|
|
4256
|
+
}
|
|
4257
|
+
],
|
|
4258
|
+
"optionalPeers": [
|
|
4259
|
+
{
|
|
4260
|
+
"peerDependency": "prettier",
|
|
4261
|
+
"range": ">=3.0.0",
|
|
4262
|
+
"install": "pnpm add -D prettier@3",
|
|
4263
|
+
"usedBy": [
|
|
4264
|
+
"writeFormatted"
|
|
4265
|
+
]
|
|
4266
|
+
}
|
|
4267
|
+
]
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
],
|
|
4272
|
+
"tool": "fact-kit",
|
|
4273
|
+
"source": {
|
|
4274
|
+
"kind": "published"
|
|
3904
4275
|
},
|
|
3905
4276
|
"content": {
|
|
3906
4277
|
"value": {
|
|
@@ -3931,12 +4302,18 @@
|
|
|
3931
4302
|
"signature": "readJsonSchemaFile(path: string) => Promise<JsonSchema>",
|
|
3932
4303
|
"summary": "Reads a JSON Schema file. Does not need TypeScript."
|
|
3933
4304
|
}
|
|
4305
|
+
],
|
|
4306
|
+
"optionalPeers": [
|
|
4307
|
+
{
|
|
4308
|
+
"peerDependency": "prettier",
|
|
4309
|
+
"range": ">=3.0.0",
|
|
4310
|
+
"install": "pnpm add -D prettier@3",
|
|
4311
|
+
"usedBy": [
|
|
4312
|
+
"writeFormatted"
|
|
4313
|
+
]
|
|
4314
|
+
}
|
|
3934
4315
|
]
|
|
3935
4316
|
}
|
|
3936
|
-
},
|
|
3937
|
-
"tool": "fact-kit",
|
|
3938
|
-
"source": {
|
|
3939
|
-
"kind": "published"
|
|
3940
4317
|
}
|
|
3941
4318
|
},
|
|
3942
4319
|
{
|