@intellectual-frontiers/libraries 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/affected.d.ts +1 -1
  2. package/dist/changes.js +2 -1
  3. package/dist/check.js +21 -2
  4. package/dist/dev.js +1 -1
  5. package/dist/generate-ontology.d.ts +2 -0
  6. package/dist/generate-ontology.js +41 -1
  7. package/dist/imports/nist-sp-800-53.auto.prov.ttl +22 -0
  8. package/dist/imports/schema-org.auto.prov.ttl +22 -0
  9. package/dist/install-bun.js +1 -1
  10. package/dist/libraries.d.ts +34 -2
  11. package/dist/libraries.js +70 -9
  12. package/dist/license/PolyForm-Noncommercial-1.0.0.md +73 -0
  13. package/dist/link.d.ts +1 -1
  14. package/dist/link.js +4 -4
  15. package/dist/metapackages.d.ts +62 -0
  16. package/dist/metapackages.js +187 -0
  17. package/dist/mod.d.ts +1 -1
  18. package/dist/mod.js +1 -1
  19. package/dist/pack-library.d.ts +7 -0
  20. package/dist/pack-library.js +31 -56
  21. package/dist/pack-metapackage.d.ts +22 -0
  22. package/dist/pack-metapackage.js +147 -0
  23. package/dist/pins.d.ts +1 -1
  24. package/dist/pins.js +1 -1
  25. package/dist/readme.d.ts +13 -1
  26. package/dist/readme.js +45 -4
  27. package/dist/releasing.d.ts +8 -1
  28. package/dist/releasing.js +44 -14
  29. package/dist/workflows/definitions.d.ts +2 -2
  30. package/dist/workflows/definitions.js +31 -113
  31. package/dist/workflows/model.d.ts +2 -0
  32. package/dist/workflows/render.js +2 -0
  33. package/dist/workflows/schema/github-workflow.schema.json +2290 -0
  34. package/package.json +28 -13
  35. package/src/affected.ts +1 -1
  36. package/src/changes.ts +2 -1
  37. package/src/check.ts +21 -2
  38. package/src/dev.ts +1 -1
  39. package/src/generate-ontology.ts +42 -1
  40. package/src/imports/nist-sp-800-53.auto.prov.ttl +22 -0
  41. package/src/imports/schema-org.auto.prov.ttl +22 -0
  42. package/src/install-bun.ts +1 -1
  43. package/src/libraries.ts +88 -8
  44. package/src/license/PolyForm-Noncommercial-1.0.0.md +73 -0
  45. package/src/link.ts +4 -4
  46. package/src/metapackages.ts +203 -0
  47. package/src/mod.ts +1 -1
  48. package/src/pack-library.ts +37 -53
  49. package/src/pack-metapackage.ts +137 -0
  50. package/src/pins.ts +1 -1
  51. package/src/readme.ts +49 -4
  52. package/src/releasing.ts +47 -16
  53. package/src/workflows/definitions.ts +34 -131
  54. package/src/workflows/model.ts +2 -0
  55. package/src/workflows/render.ts +1 -0
  56. package/src/workflows/schema/github-workflow.schema.json +2290 -0
@@ -1,7 +1,7 @@
1
1
  import { type Library } from "./libraries.js";
2
2
  /** What a library reads: its folder, the folders and files it takes from others, what it depends on, and the files it imports one by one. */
3
3
  export type Inputs = {
4
- /** The paths of the library's inputs: `commons/<name>/` and each folder (`commons/ts/kernel/**`) or file the library takes from another. */
4
+ /** The paths of the library's inputs: `commons/<name>/` and each folder (`commons/core/src/**`) or file the library takes from another. */
5
5
  readonly paths: readonly string[];
6
6
  /** The folders of commons that the library depends on through its package. */
7
7
  readonly dependsOn: readonly string[];
package/dist/changes.js CHANGED
@@ -45,6 +45,7 @@ import { readSpecTexts } from "@intellectual-frontiers/mizan/spec-files";
45
45
  import { packagingTerms } from "@intellectual-frontiers/ontology/audit";
46
46
  import * as ifccmOntology from "@intellectual-frontiers/ontology/ifccm";
47
47
  import * as ifqsOntology from "@intellectual-frontiers/ontology/ifqs";
48
+ import * as otoOntology from "@intellectual-frontiers/ontology/oto";
48
49
  import { terms } from "@intellectual-frontiers/ontology/mizan";
49
50
  /** The rules that need no range of commits: the declaration's own, and its history. */
50
51
  const WITHOUT_RANGE = ["changes/declaration", "changes/gate-relaxed"];
@@ -115,7 +116,7 @@ function sourcesUnder(root) {
115
116
  }
116
117
  /** The citations of requirements by the terms of commons' own ontologies (`mz:definedBy`), for the chain's third stage (`--terms commons`, and the default of `--trace`). */
117
118
  function termCitations() {
118
- return [...terms, ...packagingTerms, ...ifccmOntology.terms, ...ifqsOntology.terms].map((t) => ({
119
+ return [...terms, ...packagingTerms, ...ifccmOntology.terms, ...ifqsOntology.terms, ...otoOntology.terms].map((t) => ({
119
120
  term: t.values.termIri,
120
121
  cites: t.values.definedBy ?? [],
121
122
  file: "commons/ontology",
package/dist/check.js CHANGED
@@ -26,6 +26,7 @@ import { audienceModels, bases, classes, conformanceLevels, conformanceRequireme
26
26
  import * as ifccmOntology from "@intellectual-frontiers/ontology/ifccm";
27
27
  import * as ifrOntology from "@intellectual-frontiers/ontology/ifr";
28
28
  import * as ifqsOntology from "@intellectual-frontiers/ontology/ifqs";
29
+ import * as otoOntology from "@intellectual-frontiers/ontology/oto";
29
30
  import { pm } from "@intellectual-frontiers/ontology/supply-chain/packaging";
30
31
  import { rulePlugins } from "@intellectual-frontiers/mizan/rules";
31
32
  import { holdHarness } from "@intellectual-frontiers/mizan/harness";
@@ -57,7 +58,7 @@ export function termRecordsOf(audit) {
57
58
  }
58
59
  /** Mizan's own terms and the packaging ontology's as the rules read them. */
59
60
  export function mizanTermRecords() {
60
- return termRecordsOf([...terms, ...packagingTerms, ...ifccmOntology.terms, ...ifqsOntology.terms, ...ifrOntology.terms]);
61
+ return termRecordsOf([...terms, ...packagingTerms, ...ifccmOntology.terms, ...ifqsOntology.terms, ...otoOntology.terms, ...ifrOntology.terms]);
61
62
  }
62
63
  /** The prefixes of commons' own ontologies and their namespaces. */
63
64
  const PREFIXES = {
@@ -65,6 +66,7 @@ const PREFIXES = {
65
66
  pm: "https://www.intellectualfrontiers.com/ontology/packaging#",
66
67
  ifccm: ifccmOntology.IFCCM.iri,
67
68
  ifqs: ifqsOntology.IFQS.iri,
69
+ oto: otoOntology.OTO.iri,
68
70
  ifr: ifrOntology.IFR.iri,
69
71
  };
70
72
  /** The CURIE of a term of commons' own ontologies: `mz:` or `pm:` and its local name, or the IRI where it is of neither. */
@@ -76,7 +78,7 @@ function curieOf(iri) {
76
78
  }
77
79
  /** The deprecated terms of commons' own ontologies, by CURIE, with what replaces each (0018-standards-first): a specification that names one is found. */
78
80
  export function deprecatedTerms() {
79
- return new Map([...terms, ...packagingTerms, ...ifccmOntology.terms, ...ifqsOntology.terms, ...ifrOntology.terms].flatMap((t) => t.values.deprecatedOn === undefined ? [] : [[curieOf(t.values.termIri), curieOf(t.values.replacedBy ?? "")]]));
81
+ return new Map([...terms, ...packagingTerms, ...ifccmOntology.terms, ...ifqsOntology.terms, ...otoOntology.terms, ...ifrOntology.terms].flatMap((t) => t.values.deprecatedOn === undefined ? [] : [[curieOf(t.values.termIri), curieOf(t.values.replacedBy ?? "")]]));
80
82
  }
81
83
  /** The command line. Returns the exit status: 0, or 1 where a finding is new or a baseline line is stale. */
82
84
  export function main(argv, plugins = rulePlugins, today = new Date().toISOString().slice(0, 10)) {
@@ -126,6 +128,11 @@ export function main(argv, plugins = rulePlugins, today = new Date().toISOString
126
128
  ontology: ifqsOntology.classes.map((c) => c.iri),
127
129
  recorded: ifqsOntology.terms.map((t) => t.values.termIri),
128
130
  },
131
+ {
132
+ file: "commons/ontology/src/oto/oto.ts",
133
+ ontology: otoOntology.classes.map((c) => c.iri),
134
+ recorded: otoOntology.terms.map((t) => t.values.termIri),
135
+ },
129
136
  {
130
137
  file: "commons/ontology/src/ifr/ifr.ts",
131
138
  ontology: ifrOntology.classes.map((c) => c.iri),
@@ -146,6 +153,18 @@ export function main(argv, plugins = rulePlugins, today = new Date().toISOString
146
153
  ...Object.keys(audienceModels),
147
154
  ]),
148
155
  pm: new Set(Object.keys(pm)),
156
+ oto: new Set([
157
+ ...Object.keys(otoOntology.oto),
158
+ ...[
159
+ otoOntology.domains,
160
+ otoOntology.invariants,
161
+ otoOntology.pillars,
162
+ otoOntology.principles,
163
+ otoOntology.maturityLevels,
164
+ otoOntology.dimensions,
165
+ otoOntology.alignmentStates,
166
+ ].flatMap((l) => Object.keys(l)),
167
+ ]),
149
168
  ifr: ifrOntology.termNames,
150
169
  ifccm: new Set([
151
170
  ...Object.keys(ifccmOntology.ifccm),
package/dist/dev.js CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @remarks
13
13
  * Nothing is installed per library. The repository's root installs the packages every library shares (`bun install`, once), the libraries are linked under `commons/node_modules` (a link for each folder whose package
14
- * name is `@intellectual-frontiers/<folder>`, and `@intellectual-frontiers/commons` for `commons/ts`), so that a library that imports another by its package name reads the checkout's source, never a copy from a
14
+ * name is `@intellectual-frontiers/<folder>`), so that a library that imports another by its package name reads the checkout's source, never a copy from a
15
15
  * registry: the `exports` of each package are the sources. A library with a package of its own outside the shared set (a database driver) is installed in its folder, once. The affected libraries are those of
16
16
  * `affected.ts` (the same code the workflow of CI runs); TypeScript 7 checks each library's own `tsconfig.json`, several at a time, and the tests of each run in a `bun test` process of its own, from its folder as `verify` runs them, several at a time.
17
17
  *
@@ -11,6 +11,8 @@ export declare const MIZAN: OntologyPublication;
11
11
  export declare const IFCCM: OntologyPublication;
12
12
  /** The ontology of the Intellectual Frontiers Quality System (commons 0021-ifqs, 0022-trust), as it is published. */
13
13
  export declare const IFQS: OntologyPublication;
14
+ /** The Operational Truth Ontology (commons ontology 0002-oto), as it is published. */
15
+ export declare const OTO: OntologyPublication;
14
16
  /** The ontology of Intellectual Frontiers Releases (commons 0026-works-versioning), as it is published. */
15
17
  export declare const IFR: OntologyPublication;
16
18
  /** The ontology of Kanon (commons 0033-kanon), as it is published. */
@@ -19,6 +19,7 @@ import { Authority, bases, classes, Decision, files, integrationDirections, rung
19
19
  import * as ifccmOntology from "@intellectual-frontiers/ontology/ifccm";
20
20
  import * as ifrOntology from "@intellectual-frontiers/ontology/ifr";
21
21
  import * as ifqsOntology from "@intellectual-frontiers/ontology/ifqs";
22
+ import * as otoOntology from "@intellectual-frontiers/ontology/oto";
22
23
  import * as kanonOntology from "@intellectual-frontiers/ontology/kanon";
23
24
  import { formatRdfFinding, validate } from "@intellectual-frontiers/rdf";
24
25
  import { stdio } from "@intellectual-frontiers/system";
@@ -172,6 +173,45 @@ export const IFQS = {
172
173
  viewTitle: "Intellectual Frontiers Quality System: the ontology",
173
174
  license: CC0,
174
175
  };
176
+ /** The Operational Truth Ontology (commons ontology 0002-oto), as it is published. */
177
+ export const OTO = {
178
+ name: "oto",
179
+ ns: { prefix: "oto", iri: otoOntology.OTO.iri },
180
+ idNs: { prefix: "mzid", iri: MZID.iri },
181
+ curies: [
182
+ ["oto", otoOntology.OTO.iri],
183
+ ["ifqs", ifqsOntology.IFQS.iri],
184
+ ["mz", MZ.iri],
185
+ ["xsd", "http://www.w3.org/2001/XMLSchema#"],
186
+ ["rdfs", "http://www.w3.org/2000/01/rdf-schema#"],
187
+ ["skos", "http://www.w3.org/2004/02/skos/core#"],
188
+ ["dcterms", "http://purl.org/dc/terms/"],
189
+ ["prov", "http://www.w3.org/ns/prov#"],
190
+ ],
191
+ files: otoOntology.files,
192
+ ontology: otoOntology.otoOntology,
193
+ classes: otoOntology.classes,
194
+ properties: otoOntology.properties,
195
+ terms: otoOntology.terms,
196
+ schemas: [otoOntology.DomainSchema, otoOntology.MaturityLevelSchema, otoOntology.Alignment],
197
+ lists: listsOf("oto", [
198
+ ["Domain", otoOntology.domains],
199
+ ["Invariant", otoOntology.invariants],
200
+ ["Pillar", otoOntology.pillars],
201
+ ["Principle", otoOntology.principles],
202
+ ["MaturityLevel", otoOntology.maturityLevels],
203
+ ["Dimension", otoOntology.dimensions],
204
+ ["AlignmentState", otoOntology.alignmentStates],
205
+ ]),
206
+ source: "commons/ontology/src/oto/*.ts",
207
+ run: RUN,
208
+ shapes: { prefix: "otosh", iri: "https://www.intellectualfrontiers.com/ontology/oto-shapes#" },
209
+ schemasIri: "https://www.intellectualfrontiers.com/ontology/oto-schemas",
210
+ sssomSetId: "https://www.intellectualfrontiers.com/ontology/oto-mappings",
211
+ sssomCuries: { dcterms: "http://purl.org/dc/terms/", prov: "http://www.w3.org/ns/prov#", ifqs: ifqsOntology.IFQS.iri },
212
+ viewTitle: "Operational Truth Ontology",
213
+ license: CC0,
214
+ };
175
215
  /** The ontology of Intellectual Frontiers Releases (commons 0026-works-versioning), as it is published. */
176
216
  export const IFR = {
177
217
  name: "ifr",
@@ -241,7 +281,7 @@ export const KANON = {
241
281
  license: CC0,
242
282
  };
243
283
  /** The ontologies of commons that are published, each from its own typed modules: Mizan's, then the ones its specifications define. */
244
- export const publications = [MIZAN, IFCCM, IFQS, IFR, KANON];
284
+ export const publications = [MIZAN, IFCCM, IFQS, OTO, IFR, KANON];
245
285
  /** Where the generated files are downloaded from: this repository's `commons/` folder on its default branch. */
246
286
  const DOWNLOAD_BASE = "https://raw.githubusercontent.com/intellectual-frontiers/.github/main/commons/";
247
287
  /** The exports of the ontology (0019-mizan-integrations FR-010): everything but its Turtle, by its path from commons' folder. */
@@ -0,0 +1,22 @@
1
+ # AUTO-GENERATED with ../../../ontology/src/standards/nist-sp-800-53/controls.auto.ts by commons/mizan/src/integrations/pure/import-oscal-catalog.ts (commons 0019-mizan-integrations FR-009). Do not edit.
2
+
3
+ @prefix dcterms: <http://purl.org/dc/terms/> .
4
+ @prefix prov: <http://www.w3.org/ns/prov#> .
5
+
6
+ <urn:ifc:mizan:module:nist-sp-800-53> a prov:Entity ;
7
+ dcterms:source "../../../ontology/src/standards/nist-sp-800-53/controls.auto.ts" ;
8
+ prov:wasGeneratedBy <urn:ifc:mizan:import:nist-sp-800-53:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> ;
9
+ prov:wasDerivedFrom <urn:sha256:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> .
10
+
11
+ <urn:ifc:mizan:import:nist-sp-800-53:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> a prov:Activity ;
12
+ prov:used <urn:sha256:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> ;
13
+ prov:wasAssociatedWith <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-oscal-catalog.ts> .
14
+
15
+ <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-oscal-catalog.ts> a prov:SoftwareAgent .
16
+
17
+ <urn:sha256:64ca6b4161de51ab6af098a7d101d326f14c95e1abf721396cd8a049e8115eeb> a prov:Entity ;
18
+ dcterms:title "NIST SP 800-53 Rev. 5.2.0 (OSCAL catalog)" ;
19
+ dcterms:publisher "National Institute of Standards and Technology" ;
20
+ dcterms:hasVersion "5.2.0" ;
21
+ dcterms:source <https://raw.githubusercontent.com/usnistgov/oscal-content/f0de6d8d8c059d374f15e0ae07508d82e370fc1d/nist.gov/SP800-53/rev5/json/NIST_SP-800-53_rev5_catalog.json> ;
22
+ dcterms:license <https://spdx.org/licenses/Public domain (a work of the United States Government, 17 U.S.C. 105).html> .
@@ -0,0 +1,22 @@
1
+ # AUTO-GENERATED with ../../../ontology/src/supply-chain/packaging/schema.auto.ts by commons/mizan/src/integrations/pure/import-vocabulary.ts (commons 0019-mizan-integrations FR-009). Do not edit.
2
+
3
+ @prefix dcterms: <http://purl.org/dc/terms/> .
4
+ @prefix prov: <http://www.w3.org/ns/prov#> .
5
+
6
+ <urn:ifc:mizan:module:schema-org> a prov:Entity ;
7
+ dcterms:source "../../../ontology/src/supply-chain/packaging/schema.auto.ts" ;
8
+ prov:wasGeneratedBy <urn:ifc:mizan:import:schema-org:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> ;
9
+ prov:wasDerivedFrom <urn:sha256:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> .
10
+
11
+ <urn:ifc:mizan:import:schema-org:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> a prov:Activity ;
12
+ prov:used <urn:sha256:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> ;
13
+ prov:wasAssociatedWith <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-vocabulary.ts> .
14
+
15
+ <urn:ifc:mizan:generator:commons:mizan:src:integrations:pure:import-vocabulary.ts> a prov:SoftwareAgent .
16
+
17
+ <urn:sha256:7f15ca89398c4f235f478a4b3b8d1f975d63c5a860b77c8a8fce01f791b7ae2f> a prov:Entity ;
18
+ dcterms:title "schema.org" ;
19
+ dcterms:publisher "Schema.org Community Group" ;
20
+ dcterms:hasVersion "30.1" ;
21
+ dcterms:source <https://schema.org/version/30.1/schemaorg-current-https.ttl> ;
22
+ dcterms:license <https://spdx.org/licenses/CC-BY-SA-3.0.html> .
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Bun at the version commons pins (its version, address, SHA-256, format and folder per platform in `commons/generated/pins.auto.env`, commons
3
- * 0005-typescript-runtime FR-026, 0002-packaging FR-019), fetched from that address with retries, kept only where its SHA-256 is the pinned one, unpacked by the
3
+ * 0005-typescript-practice FR-026, 0002-packaging FR-019), fetched from that address with retries, kept only where its SHA-256 is the pinned one, unpacked by the
4
4
  * kernel's own zip reader and put in a folder; nothing but IFC TypeScript itself, so it runs on Node 26 (or Bun) on Linux, macOS
5
5
  * and Windows with no shell, no Python and no unzip. CI's `.github/actions/bun` runs it.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { type Result } from "@intellectual-frontiers/core";
1
+ import { type Brand, type Result } from "@intellectual-frontiers/core";
2
2
  import { type SpdxId } from "./license/standard.js";
3
3
  import { type Table } from "@intellectual-frontiers/kanon";
4
4
  import { type LevelKey } from "@intellectual-frontiers/mizan/levels";
@@ -37,6 +37,35 @@ export type Library = {
37
37
  readonly family?: LibraryFamily;
38
38
  /** The license its `LICENSE` and its packed `package.json` carry, where it is not the default of the repository (`license/standard.ts`; commons 0035-licensing FR-003). */
39
39
  readonly license?: SpdxId;
40
+ /** The constants of its sources that say its own version (`ERGONEX_VERSION`), each a file from the library's folder and the name of the constant: the release rewrites them with the version, and a check finds one that disagrees. */
41
+ readonly versionConstants?: readonly VersionConstant[];
42
+ /** The package the library publishes where it is not `@intellectual-frontiers/<name>` (the `data` library publishes `@intellectual-frontiers/arcactl`; commons 0036-distribution FR-009). */
43
+ readonly publishes?: PackageName;
44
+ /** Why the library is kept out of the release: it is verified and packed like any other, and has no release record entry, no tag, no set and no registry (FR-0xx of 0001-libraries). */
45
+ readonly held?: HeldReason;
46
+ /** The set the library is, where it is a metapackage: a folder with no code of its own whose package depends on the libraries of the set at exact versions (commons 0036-distribution FR-005). */
47
+ readonly bundle?: BundleName;
48
+ };
49
+ /** The reason a library is held out of the release: a non-empty sentence, made only by {@link parseHeldReason}. */
50
+ export type HeldReason = Brand<string, "held reason">;
51
+ /** A held reason from text, or why the text is not one. */
52
+ export declare function parseHeldReason(text: string): Result<HeldReason, string>;
53
+ /** The scope of the packages of commons. */
54
+ export declare const PACKAGE_SCOPE = "@intellectual-frontiers/";
55
+ /** The sets that a metapackage is: the whole of commons, and the four roles of the libraries; a closed union, and the name of the folder and of the package of each. */
56
+ export declare const BUNDLES: readonly ["commons", "foundation", "patterns", "programs", "standards"];
57
+ /** The name of a set of libraries a metapackage is. */
58
+ export type BundleName = (typeof BUNDLES)[number];
59
+ /** The name of a package of commons: `@intellectual-frontiers/` and a name, made only by {@link parsePackageName}. */
60
+ export type PackageName = Brand<string, "package name">;
61
+ /** A package name of commons from text, or why the text is not one. */
62
+ export declare function parsePackageName(text: string): Result<PackageName, string>;
63
+ /** The package a library publishes: the one its manifest names in `publishes`, else `@intellectual-frontiers/<name>` (commons 0036-distribution FR-009). */
64
+ export declare function publishedPackage(l: Pick<Library, "name" | "publishes">): string;
65
+ /** A constant of a library's sources that holds the library's version: the file (from the library's folder) and the constant's name. */
66
+ export type VersionConstant = {
67
+ readonly file: string;
68
+ readonly name: string;
40
69
  };
41
70
  /** The lowest conformance level that requires a library to declare `kanon`; none yet (0033-kanon FR-014, OQ-1): a level asks for it by naming itself here. */
42
71
  export declare const KANON_REQUIRED_FROM: LevelKey | undefined;
@@ -69,7 +98,10 @@ export declare function requirementOf(id: string, l: Library): string;
69
98
  export declare function rowOf(id: string, l: Library): string;
70
99
  /** The ids the section already gives each library, by name, read from its text between the markers. */
71
100
  export declare function idsIn(spec: string): ReadonlyMap<string, string>;
72
- /** The id each library has: the one it had, or the next number after the greatest. */
101
+ /**
102
+ * The id each library has: the one it had, or the next number after the greatest. A number belongs to the first library that holds it in the specification: where a second one holds it (two branches each gave the next number to a
103
+ * library, and a merge kept both), the second is given the next number after the greatest, so that the generator makes the section again with one number for each library.
104
+ */
73
105
  export declare function idsFor(libraries: readonly Library[], had: ReadonlyMap<string, string>): ReadonlyMap<string, string>;
74
106
  /** The text of the specification and of the register, made again from the libraries: nothing where the specification has no markers. */
75
107
  export declare function generated(spec: string, enforcement: string, libraries: readonly Library[]): Result<{
package/dist/libraries.js CHANGED
@@ -80,7 +80,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
80
80
  * @module
81
81
  */
82
82
  import process from "node:process";
83
- import { array, describe, formatDecodeError, literal, object, unknownValue, string, err, ok, } from "@intellectual-frontiers/core";
83
+ import { array, describe, formatDecodeError, literal, object, unknownValue, string, err, ok, refine, } from "@intellectual-frontiers/core";
84
84
  import { parseSpdxId } from "./license/standard.js";
85
85
  import { exportedLiteral } from "@intellectual-frontiers/formats/ts-literal";
86
86
  import { decodeTable } from "@intellectual-frontiers/kanon";
@@ -105,6 +105,26 @@ function bounds(spec) {
105
105
  const to = spec.indexOf(`\n${END}\n`, from);
106
106
  return from < 0 || to < 0 ? undefined : { from: from + 1, to: to + 1 };
107
107
  }
108
+ const heldDecoder = refine(string, "held reason", (t) => t.trim() !== "" && t.trim() === t && !t.includes("\n"));
109
+ /** A held reason from text, or why the text is not one. */
110
+ export function parseHeldReason(text) {
111
+ const r = heldDecoder(text, "held");
112
+ return r.kind === "ok" ? ok(r.value) : err("library.held is one non-empty line that says why the library is kept out of the release");
113
+ }
114
+ /** The scope of the packages of commons. */
115
+ export const PACKAGE_SCOPE = "@intellectual-frontiers/";
116
+ /** The sets that a metapackage is: the whole of commons, and the four roles of the libraries; a closed union, and the name of the folder and of the package of each. */
117
+ export const BUNDLES = ["commons", "foundation", "patterns", "programs", "standards"];
118
+ const packageNameDecoder = refine(string, "package name", (t) => /^@intellectual-frontiers\/[a-z][a-z0-9-]*$/.test(t));
119
+ /** A package name of commons from text, or why the text is not one. */
120
+ export function parsePackageName(text) {
121
+ const r = packageNameDecoder(text, "package");
122
+ return r.kind === "ok" ? ok(r.value) : err(`${JSON.stringify(text)} is not a package of commons (@intellectual-frontiers/ and a name of lower-case letters, digits and hyphens)`);
123
+ }
124
+ /** The package a library publishes: the one its manifest names in `publishes`, else `@intellectual-frontiers/<name>` (commons 0036-distribution FR-009). */
125
+ export function publishedPackage(l) {
126
+ return l.publishes ?? `${PACKAGE_SCOPE}${l.name}`;
127
+ }
108
128
  /** The lowest conformance level that requires a library to declare `kanon`; none yet (0033-kanon FR-014, OQ-1): a level asks for it by naming itself here. */
109
129
  export const KANON_REQUIRED_FROM = undefined;
110
130
  /** The registries a library may be published to: the kinds only, never a host or a credential (0027-commons-libraries FR-018). */
@@ -125,8 +145,16 @@ const nameDecoder = (input, path = "$") => {
125
145
  ? r
126
146
  : err({ kind: "decode", path, expected: "a name of lower-case letters, digits and hyphens", found: describe(input) });
127
147
  };
128
- const body = object({ name: nameDecoder, verify: nonEmpty, version: nonEmpty, exports: array(nonEmpty) }, { level: literal(...LEVELS), specKit: nonEmpty, summary: nonEmpty, distribution: array(literal(...REGISTRIES)), kanon: unknownValue, family: object({ host: nonEmpty, role: literal(...ROLES) }), license: nonEmpty });
129
- const FIELDS = ["name", "level", "specKit", "verify", "version", "exports", "summary", "distribution", "kanon", "family", "license"];
148
+ const constantName = (input, path = "$") => {
149
+ const r = string(input, path);
150
+ if (r.kind === "err")
151
+ return r;
152
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(r.value)
153
+ ? r
154
+ : err({ kind: "decode", path, expected: "the name of a constant: letters, digits and underscores", found: describe(input) });
155
+ };
156
+ const body = object({ name: nameDecoder, verify: nonEmpty, version: nonEmpty, exports: array(nonEmpty) }, { level: literal(...LEVELS), specKit: nonEmpty, summary: nonEmpty, distribution: array(literal(...REGISTRIES)), kanon: unknownValue, family: object({ host: nonEmpty, role: literal(...ROLES) }), license: nonEmpty, versionConstants: array(object({ file: nonEmpty, name: constantName })), publishes: nonEmpty, bundle: literal(...BUNDLES), held: string });
157
+ const FIELDS = ["name", "level", "specKit", "verify", "version", "exports", "summary", "distribution", "kanon", "family", "license", "versionConstants", "publishes", "bundle", "held"];
130
158
  /** The manifest read from the text of its file: `export const library = { ... }` and no other export, read as data and never run (0027-commons-libraries FR-012). */
131
159
  export function decodeLibrarySource(source) {
132
160
  const exports = source.split("\n").filter((l) => /^export\s/.test(l));
@@ -147,9 +175,18 @@ export function decodeLibrarySource(source) {
147
175
  return err(formatDecodeError(r.error));
148
176
  const v = r.value;
149
177
  const distribution = v.distribution ?? DEFAULT_DISTRIBUTION;
150
- if (distribution.length === 0 || new Set(distribution).size !== distribution.length)
178
+ let held;
179
+ if (v.held !== undefined) {
180
+ const h = parseHeldReason(v.held);
181
+ if (h.kind === "err")
182
+ return err(h.error);
183
+ held = h.value;
184
+ if (v.publishes !== undefined || v.bundle !== undefined)
185
+ return err("library.held is not given with library.publishes or library.bundle: a held library is published nowhere");
186
+ }
187
+ if (held === undefined && (distribution.length === 0 || new Set(distribution).size !== distribution.length))
151
188
  return err("library.distribution lists each registry once and at least one (FR-015)");
152
- if (!distribution.includes("github"))
189
+ if (held === undefined && !distribution.includes("github"))
153
190
  return err("library.distribution includes github: a library is published to the GitHub package registry whatever else it is published to (FR-015, FR-016)");
154
191
  let kanon;
155
192
  if (v.kanon !== undefined) {
@@ -172,6 +209,17 @@ export function decodeLibrarySource(source) {
172
209
  return err(`library.license: ${l.error}`);
173
210
  license = l.value;
174
211
  }
212
+ let publishes;
213
+ if (v.publishes !== undefined) {
214
+ const p = parsePackageName(v.publishes);
215
+ if (p.kind === "err")
216
+ return err(`library.publishes: ${p.error}`);
217
+ publishes = p.value;
218
+ }
219
+ if (v.bundle !== undefined && v.bundle !== v.name)
220
+ return err(`library.bundle ${v.bundle} is the set of the metapackage of that name: the folder is named ${v.bundle}, and this one is ${v.name} (0036-distribution FR-005)`);
221
+ if (v.bundle !== undefined && publishes !== undefined)
222
+ return err("library.bundle and library.publishes are not both given: a metapackage publishes the package of its folder (0036-distribution FR-005)");
175
223
  return ok({
176
224
  name: v.name,
177
225
  level: v.level ?? DEFAULT_LIBRARY_LEVEL,
@@ -184,6 +232,10 @@ export function decodeLibrarySource(source) {
184
232
  ...(kanon === undefined ? {} : { kanon }),
185
233
  ...(family === undefined ? {} : { family }),
186
234
  ...(license === undefined ? {} : { license }),
235
+ ...(v.versionConstants === undefined ? {} : { versionConstants: v.versionConstants }),
236
+ ...(publishes === undefined ? {} : { publishes }),
237
+ ...(v.bundle === undefined ? {} : { bundle: v.bundle }),
238
+ ...(held === undefined ? {} : { held }),
187
239
  });
188
240
  }
189
241
  /** The manifests of `commons/*`, in the order of the folders' names: every folder that holds a `library.ts`. */
@@ -292,8 +344,10 @@ const list = (items) => {
292
344
  export function requirementOf(id, l) {
293
345
  const kit = l.specKit === undefined ? "" : `, its spec kit at \`commons/${l.name}/${l.specKit}\``;
294
346
  const summary = l.summary === undefined ? "" : ` ${l.summary}`;
295
- const where = l.distribution.map((r) => REGISTRY_NAME[r]).join(" and ");
296
- return `- **${id}**: \`commons/${l.name}\` MUST be a library at conformance level ${l.level} (\`${LEVEL_TERM[l.level]}\`): the package \`@intellectual-frontiers/${l.name}\` at version \`${l.version}\`${kit}, exporting ${list(l.exports)}, published to ${where}, proved by \`cd commons/${l.name} && ${l.verify}\`.${summary}`;
347
+ const where = l.held === undefined ? l.distribution.map((r) => REGISTRY_NAME[r]).join(" and ") : `no registry (held out of the release: ${l.held})`;
348
+ const own = l.publishes === undefined ? `@intellectual-frontiers/${l.name}` : l.publishes;
349
+ const sets = l.bundle === undefined ? "" : `, a metapackage with no code of its own (the set ${l.bundle}, 0036-distribution FR-005)`;
350
+ return `- **${id}**: \`commons/${l.name}\` MUST be a library at conformance level ${l.level} (\`${LEVEL_TERM[l.level]}\`): the package \`${own}\`${sets} at version \`${l.version}\`${kit}, exporting ${list(l.exports)}, published to ${where}, proved by \`cd commons/${l.name} && ${l.verify}\`.${summary}`;
297
351
  }
298
352
  /** The row of `enforcement.tsv` of a library's requirement. */
299
353
  export function rowOf(id, l) {
@@ -313,13 +367,20 @@ export function idsIn(spec) {
313
367
  }
314
368
  return out;
315
369
  }
316
- /** The id each library has: the one it had, or the next number after the greatest. */
370
+ /**
371
+ * The id each library has: the one it had, or the next number after the greatest. A number belongs to the first library that holds it in the specification: where a second one holds it (two branches each gave the next number to a
372
+ * library, and a merge kept both), the second is given the next number after the greatest, so that the generator makes the section again with one number for each library.
373
+ */
317
374
  export function idsFor(libraries, had) {
318
375
  const out = new Map();
376
+ const first = new Map();
377
+ for (const [name, id] of had)
378
+ if (!first.has(id))
379
+ first.set(id, name);
319
380
  let next = Math.max(FIRST_GENERATED - 1, ...[...had.values()].map((id) => Number(id.slice(3)))) + 1;
320
381
  for (const l of libraries) {
321
382
  const id = had.get(l.name);
322
- if (id !== undefined)
383
+ if (id !== undefined && first.get(id) === l.name)
323
384
  out.set(l.name, id);
324
385
  else
325
386
  out.set(l.name, `FR-${String(next++).padStart(3, "0")}`);
@@ -0,0 +1,73 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
12
+
13
+ ## Distribution License
14
+
15
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
16
+
17
+ ## Notices
18
+
19
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
20
+
21
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
22
+
23
+ ## Changes and New Works License
24
+
25
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
26
+
27
+ ## Patent License
28
+
29
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
30
+
31
+ ## Noncommercial Purposes
32
+
33
+ Any noncommercial purpose is a permitted purpose.
34
+
35
+ ## Personal Uses
36
+
37
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
38
+
39
+ ## Noncommercial Organizations
40
+
41
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
42
+
43
+ ## Fair Use
44
+
45
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
46
+
47
+ ## No Other Rights
48
+
49
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
50
+
51
+ ## Patent Defense
52
+
53
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
54
+
55
+ ## Violations
56
+
57
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
58
+
59
+ ## No Liability
60
+
61
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
62
+
63
+ ## Definitions
64
+
65
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
66
+
67
+ **You** refers to the individual or entity agreeing to these terms.
68
+
69
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
70
+
71
+ **Your licenses** are all the licenses granted to you for the software under these terms.
72
+
73
+ **Use** means anything you do with the software requiring one of your licenses.
package/dist/link.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /** The packages of commons by name and the folder of each; `commons/ts` comes first, so that it is the one that bears `@intellectual-frontiers/commons`. */
1
+ /** The packages of commons by name and the folder of each. */
2
2
  export declare function linksOf(repo: string): ReadonlyMap<string, string>;
3
3
  /** Links each package that is not linked yet, and gives how many it linked, or why it could not. */
4
4
  export declare function linkAll(repo: string): {
package/dist/link.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * bun commons/libraries/src/link.ts link what is not linked, from the repository above this folder (or --repo DIR)
7
7
  *
8
8
  * @remarks
9
- * A folder of `commons/` whose `package.json` is named `@intellectual-frontiers/<name>` is linked as that name, and `commons/ts` as `@intellectual-frontiers/commons` (`commons/docs` bears the same name and is not linked). A link
9
+ * A folder of `commons/` whose `package.json` is named `@intellectual-frontiers/<name>` is linked as that name (the metapackage `commons/commons` bears `@intellectual-frontiers/commons`). A link
10
10
  * that is there is left as it is. Only the built-ins of Node are used, so it runs on Bun and on Node 26 before anything is installed.
11
11
  *
12
12
  * @limits
@@ -15,7 +15,7 @@
15
15
  * @example
16
16
  * ```ts
17
17
  * import { linksOf } from "./link.ts";
18
- * linksOf(".").get("@intellectual-frontiers/commons"); // the path of commons/ts
18
+ * linksOf(".").get("@intellectual-frontiers/commons"); // the path of commons/commons
19
19
  * ```
20
20
  *
21
21
  * Spec: 0001-libraries FR-011
@@ -36,13 +36,13 @@ const nameOf = (file) => {
36
36
  return undefined;
37
37
  }
38
38
  };
39
- /** The packages of commons by name and the folder of each; `commons/ts` comes first, so that it is the one that bears `@intellectual-frontiers/commons`. */
39
+ /** The packages of commons by name and the folder of each. */
40
40
  export function linksOf(repo) {
41
41
  const links = new Map();
42
42
  const dirs = readdirSync(join(repo, "commons"), { withFileTypes: true })
43
43
  .filter((e) => e.isDirectory() && e.name !== "node_modules")
44
44
  .map((e) => e.name)
45
- .sort((a, b) => (a === "ts" ? -1 : b === "ts" ? 1 : a < b ? -1 : 1));
45
+ .sort((a, b) => (a < b ? -1 : 1));
46
46
  for (const d of dirs) {
47
47
  const name = nameOf(join(repo, "commons", d, "package.json"));
48
48
  if (name !== undefined && name.startsWith(SCOPE) && !links.has(name))
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The metapackages of commons (commons 0036-distribution FR-005 to FR-008): five packages with no code of their own, each a set of libraries at the exact versions of one release. `@intellectual-frontiers/commons` is every
3
+ * consumer-facing library; `foundation`, `patterns`, `programs` and `standards` are the four roles of the libraries. A repository other than `.github` installs commons by installing one of them, or a library, from a registry.
4
+ *
5
+ * @remarks
6
+ * Pure: the libraries as data give the members of a set, the exact dependencies of its package, the file that records them, the `package.json` and the README that are published. The role of a library is read from `ROLE_OF` of
7
+ * `readme.ts`, the one place that says it, and the set of a role is the role's: `foundation`, `pattern` (`patterns`), `program` (`programs`) and `standard` (`standards`). A library is consumer-facing where its distribution
8
+ * names npm and it is not a metapackage and not held back ({@link HELD_BACK}); the package of a member is the package it publishes ({@link publishedPackage}). A member whose role is not known is a problem and never a member
9
+ * of no set. The effects (writing the files, packing) are `pack-metapackage.ts`.
10
+ *
11
+ * @limits
12
+ * It reads no file and knows no registry. It does not know what is published: a release that has not published a member makes the set refer to a version npm does not hold yet, which the release's order prevents.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { dependenciesOf } from "./metapackages.js";
17
+ * dependenciesOf([{ library: "core", package: "@intellectual-frontiers/core", version: "0.1.5" }]); // { "@intellectual-frontiers/core": "0.1.5" }
18
+ * ```
19
+ *
20
+ * Spec: 0001-libraries FR-023
21
+ *
22
+ * @module
23
+ */
24
+ import { type Result } from "@intellectual-frontiers/core";
25
+ import { type BundleName, type Library } from "./libraries.js";
26
+ import { type Role } from "./readme.js";
27
+ /** The libraries that are not in any set yet, each with why: they declare npm and are not ready to be installed (commons 0036-distribution FR-006). A library leaves this list when its owner releases it. */
28
+ export declare const HELD_BACK: ReadonlyMap<string, string>;
29
+ /** The roles' sets: a role is in exactly one. */
30
+ export declare const BUNDLE_OF_ROLE: Readonly<Record<Role, Exclude<BundleName, "commons">>>;
31
+ /** A member of a set: the library, the package it publishes and the version of this release. */
32
+ export type Member = {
33
+ readonly library: string;
34
+ readonly package: string;
35
+ readonly version: string;
36
+ };
37
+ /** The exact dependencies of a package: the name of each member and its version, nothing else. */
38
+ export type Dependencies = Readonly<Record<string, string>>;
39
+ /** Whether a library is installed by a set: it names npm, it is no metapackage and it is not held back. */
40
+ export declare function isConsumerFacing(l: Pick<Library, "name" | "bundle" | "distribution" | "held">): boolean;
41
+ /** The members of a set, in the order of their packages' names; the problem where a consumer-facing library has no role in `ROLE_OF`. */
42
+ export declare function membersOf(bundle: BundleName, libraries: readonly Library[]): Result<readonly Member[], string>;
43
+ /** The exact dependencies of the package of a set: each member's package at its version, no range. */
44
+ export declare function dependenciesOf(members: readonly Member[]): Dependencies;
45
+ /** What the generated file of a set holds: the set and its exact dependencies. */
46
+ export declare function setFileText(bundle: BundleName, members: readonly Member[]): string;
47
+ /** The generated file of a set, from its folder. */
48
+ export declare const SET_FILE = "dependencies.auto.json";
49
+ /** The dependencies a generated file holds, or why its text is not one. */
50
+ export declare function readSetFile(text: string): Result<Dependencies, string>;
51
+ /** The text of a set's own `description`, which the package carries. */
52
+ export declare function descriptionOf(bundle: BundleName): string;
53
+ /** The README of a set's package: what it holds, how to install it from npm and from the GitHub package registry, and how to keep one copy of each library. */
54
+ export declare function readmeOf(bundle: BundleName, members: readonly Member[]): string;
55
+ /** The `package.json` that is published for a set: no code, one empty entry, the exact dependencies. */
56
+ export declare function publishedManifest(bundle: BundleName, version: string, dependencies: Dependencies, license: string): Readonly<Record<string, unknown>>;
57
+ /** The one file of code of a set's package, and its declaration: an empty module, so that the entry imports. */
58
+ export declare const ENTRY_JS = "export {};\n";
59
+ /** The declaration of {@link ENTRY_JS}. */
60
+ export declare const ENTRY_DTS = "export {};\n";
61
+ /** Every set, in the order the README lists them. */
62
+ export declare const ALL_BUNDLES: readonly BundleName[];