linked-rolls 0.27.0 → 0.29.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/README.md CHANGED
@@ -88,9 +88,12 @@ no features to carry the symbols of a version. It states instead
88
88
  which versions it is held to carry, in `carries`, each under a belief
89
89
  that says how certainly and why. `witnessesOf` gathers the copies of a
90
90
  version, whether their features carry its symbols or they state that
91
- they carry it, and `carriageProblems` reports a statement made beside
92
- features that carry symbols already, or one naming a version the
93
- edition lacks.
91
+ they carry it, a statement with the belief it rests on;
92
+ `versionsWitnessedBy` gathers the same from the side of a copy.
93
+ `carriageProblems` reports a statement made beside features that carry
94
+ symbols already, or one naming a version the edition lacks. A copy may
95
+ carry a `siglum`, as a version does; one without is named by its
96
+ keeper.
94
97
 
95
98
  ```ts
96
99
  import { reservationsAbout, stateSource } from 'linked-rolls'
package/lib/RollCopy.d.ts CHANGED
@@ -273,6 +273,12 @@ export interface RollCopy extends WithType<'RollCopy'>, WithId {
273
273
  * @see crm:P44 has condition
274
274
  */
275
275
  conditions: RollConditionAssignment[];
276
+ /**
277
+ * A short siglum to identify the copy, e.g. "W1" or "S2". A copy
278
+ * without one is named by its keeper.
279
+ * @see reo:siglum
280
+ */
281
+ siglum?: string;
276
282
  /**
277
283
  * The institution or person holding this copy. Left out where it is
278
284
  * not known, as for a copy known only from a recording.
package/lib/Version.d.ts CHANGED
@@ -1,25 +1,9 @@
1
1
  import { Edit } from "./Edit";
2
2
  import { Concept } from "./Agent";
3
- import { ActorAssignment, Certainty, DateAssignment, ReferenceAssumption } from "./Assumption";
3
+ import { ActorAssignment, Belief, Certainty, DateAssignment, ReferenceAssumption } from "./Assumption";
4
4
  import { CollationTolerance } from "./Collation";
5
5
  import { AnySymbol } from "./Symbol";
6
6
  import { WithId, WithNote, WithType } from "./utils";
7
- export declare const versionTypes: readonly [
8
- /**
9
- * The roll is in a state where it is (possibly) used as
10
- * the master roll for several new reproductions.
11
- */
12
- 'edition',
13
- /**
14
- * A version that exists only on one specific copy of a roll.
15
- */
16
- 'unicum'];
17
- /**
18
- * The type of a version. An 'edition' version may serve as the
19
- * master for several roll copies; a 'unicum' version exists only
20
- * on one specific copy.
21
- */
22
- export type VersionType = typeof versionTypes[number];
23
7
  /**
24
8
  * A motivation provides a reason or rationale for an editorial change.
25
9
  * Motivations are defined at the version level and referenced by edits.
@@ -96,13 +80,6 @@ export interface Version extends WithId, WithType<'Version'> {
96
80
  * @see crm:P2 has type
97
81
  */
98
82
  system: Concept;
99
- /**
100
- * Whether the version served as a master for reproductions
101
- * or exists on one copy only. Left out where that is not known,
102
- * as for a version only a secondary witness hints at.
103
- * @see crm:P2 has type
104
- */
105
- versionType?: VersionType;
106
83
  /**
107
84
  * The versions this one is held to derive from, each under the
108
85
  * belief it rests on. The text is read against the principal one
@@ -136,10 +113,14 @@ export declare const editsOf: (version: Readonly<Version>) => Edit[];
136
113
  export declare const insertedBy: (version: Readonly<Version>) => AnySymbol[];
137
114
  /** The ids of the symbols the version's edits delete. */
138
115
  export declare const deletedBy: (version: Readonly<Version>) => string[];
139
- /** The parents the version names, each with the certainty its derivation is held with. */
116
+ /**
117
+ * The parents the version names, in the order of `basedOn`, each with the
118
+ * certainty its derivation is held with and the belief it rests on.
119
+ */
140
120
  export declare const derivationsOf: (version: Readonly<Version>) => {
141
121
  parent: string;
142
122
  certainty: Certainty;
123
+ belief?: Belief;
143
124
  }[];
144
125
  /**
145
126
  * The derivation the version's text is read against: the first of those
package/lib/Version.js CHANGED
@@ -1,16 +1,5 @@
1
1
  import { certainties, certaintyOf, idOf } from "./Assumption";
2
2
  import { defaultCollationTolerance } from "./Collation";
3
- export const versionTypes = [
4
- /**
5
- * The roll is in a state where it is (possibly) used as
6
- * the master roll for several new reproductions.
7
- */
8
- 'edition',
9
- /**
10
- * A version that exists only on one specific copy of a roll.
11
- */
12
- 'unicum'
13
- ];
14
3
  /** The tolerance the derivation was collated at, or the default where it states none. */
15
4
  export const collationToleranceOf = (derivation) => derivation.collationTolerance ?? defaultCollationTolerance;
16
5
  /** The edits the version states, none where it leaves its text unstated. */
@@ -19,8 +8,14 @@ export const editsOf = (version) => version.edits ?? [];
19
8
  export const insertedBy = (version) => editsOf(version).flatMap(edit => edit.insert ?? []);
20
9
  /** The ids of the symbols the version's edits delete. */
21
10
  export const deletedBy = (version) => editsOf(version).flatMap(edit => edit.delete ?? []);
22
- /** The parents the version names, each with the certainty its derivation is held with. */
23
- export const derivationsOf = (version) => (version.basedOn ?? []).map(derivation => ({ parent: idOf(derivation), certainty: certaintyOf(derivation) }));
11
+ /**
12
+ * The parents the version names, in the order of `basedOn`, each with the
13
+ * certainty its derivation is held with and the belief it rests on.
14
+ */
15
+ export const derivationsOf = (version) => (version.basedOn ?? []).map(derivation => {
16
+ const belief = derivation['@annotation']?.belief;
17
+ return { parent: idOf(derivation), certainty: certaintyOf(derivation), ...(belief && { belief }) };
18
+ });
24
19
  const rankOf = (derivation) => certainties.indexOf(certaintyOf(derivation));
25
20
  /**
26
21
  * The derivation the version's text is read against: the first of those
@@ -44,6 +44,8 @@ export declare const unalignCopy: (copyId: string) => EditionOp;
44
44
  export declare const stateSource: (copyId: string, source: FeatureSource) => EditionOp;
45
45
  /** Takes back the statement, leaving the copy silent about its source again. */
46
46
  export declare const clearSource: (copyId: string) => EditionOp;
47
+ /** Gives the copy the siglum it is referred to by, or takes it away where the siglum given is blank. */
48
+ export declare const nameCopy: (copyId: string, siglum: string) => EditionOp;
47
49
  /**
48
50
  * States that the copy carries the version, under the belief given. It
49
51
  * is meant for a copy whose features are not read into symbols, such as
package/lib/editionOps.js CHANGED
@@ -83,7 +83,6 @@ export const createVersion = (siglum, copy) => draft => {
83
83
  id: v4(),
84
84
  siglum,
85
85
  system: systemOf(bar),
86
- versionType: 'edition',
87
86
  edits: asSymbols(copy.features, bar).map(insertion),
88
87
  motivations: []
89
88
  });
@@ -135,6 +134,14 @@ export const stateSource = (copyId, source) => onCopy(copyId, copy => {
135
134
  export const clearSource = (copyId) => onCopy(copyId, copy => {
136
135
  copy.readFrom = undefined;
137
136
  });
137
+ /** Gives the copy the siglum it is referred to by, or takes it away where the siglum given is blank. */
138
+ export const nameCopy = (copyId, siglum) => onCopy(copyId, copy => {
139
+ const trimmed = siglum.trim();
140
+ if (trimmed)
141
+ copy.siglum = trimmed;
142
+ else
143
+ delete copy.siglum;
144
+ });
138
145
  /** A reference under the belief given, where one is given. */
139
146
  const referenceHeld = (id, belief) => ({ ...assignReference(id), ...(belief && { '@annotation': { id: v4(), belief } }) });
140
147
  /** The references less those that match, or nothing where none is left. */
@@ -641,7 +648,6 @@ export const deriveVersion = (versionId, editIds) => onVersion(versionId, (versi
641
648
  id: v4(),
642
649
  siglum: `${version.siglum}_derived`,
643
650
  system: stateOf(version).system,
644
- versionType: 'unicum',
645
651
  basedOn: [assignReference(versionId)],
646
652
  edits: moved,
647
653
  motivations: []
package/lib/migrate.js CHANGED
@@ -3,8 +3,7 @@ import { rollConditions } from "./RollCopy";
3
3
  import { systemIdIn, systemOf, translationBetween } from "./TrackerBar";
4
4
  import { trackerBars } from "./systems";
5
5
  import { welteT100 } from "./systems/welteT100/bar";
6
- import { versionTypes } from "./Version";
7
- const versionTypeValues = new Set(versionTypes);
6
+ const retiredVersionTypes = new Set(['edition', 'unicum']);
8
7
  const conditionTypeValues = new Set([...rollConditions, ...Object.values(conditions).flat()]);
9
8
  const renamedKeys = {
10
9
  productionEvent: 'production',
@@ -17,14 +16,21 @@ const withRenamedKeys = (node) => Object.keys(node).some(key => Object.hasOwn(re
17
16
  ? Object.fromEntries(Object.entries(node).map(([key, value]) => [renamedKeys[key] ?? key, value]))
18
17
  : node;
19
18
  const withTypology = (node) => {
20
- if (versionTypeValues.has(node['@type'])) {
21
- return { ...node, '@type': 'Version', versionType: node['@type'] };
19
+ if (retiredVersionTypes.has(node['@type'])) {
20
+ return { ...node, '@type': 'Version' };
22
21
  }
23
22
  if (conditionTypeValues.has(node['@type'])) {
24
23
  return { ...node, '@type': 'ConditionState', conditionType: node['@type'] };
25
24
  }
26
25
  return node;
27
26
  };
27
+ /** A version once stated whether it served as a master or stood on one copy. */
28
+ const withoutVersionType = (node) => {
29
+ if (!Object.hasOwn(node, 'versionType'))
30
+ return node;
31
+ const { versionType: _retired, ...rest } = node;
32
+ return rest;
33
+ };
28
34
  const withReferences = (node) => referenceKeys.reduce((result, key) => {
29
35
  const reference = result[key];
30
36
  if (reference && typeof reference === 'object' && '@value' in reference) {
@@ -88,7 +94,7 @@ const withoutEmptyKeeper = (node) => {
88
94
  const { keeper: _unnamed, ...rest } = node;
89
95
  return rest;
90
96
  };
91
- const migrateNode = (node) => [withRenamedKeys, withTypology, withReferences, withKeeper, withoutEmptyKeeper, withProductionNodes, withScale,
97
+ const migrateNode = (node) => [withRenamedKeys, withTypology, withoutVersionType, withReferences, withKeeper, withoutEmptyKeeper, withProductionNodes, withScale,
92
98
  withDerivationList, withReadingKind]
93
99
  .reduce((result, step) => step(result), node);
94
100
  /** The items each walked, or the very same list where the walk changed none. */
@@ -24,7 +24,7 @@ export interface Reservation<T extends string = ReservationType> {
24
24
  * the measurement leaves open, then who holds it.
25
25
  */
26
26
  export declare const reservationsAbout: (copy: RollCopy) => Reservation[];
27
- export declare const versionReservationTypes: readonly ['text-not-stated', 'type-not-stated', 'witnessed-by-statement-only'];
27
+ export declare const versionReservationTypes: readonly ['text-not-stated', 'witnessed-by-statement-only'];
28
28
  export type VersionReservationType = typeof versionReservationTypes[number];
29
29
  /** What the edition cannot vouch for in a version, in the order the checks are listed. */
30
30
  export declare const reservationsAboutVersion: (view: EditionView, version: Readonly<Version>) => Reservation<VersionReservationType>[];
@@ -102,17 +102,12 @@ const checks = [
102
102
  export const reservationsAbout = (copy) => checks.flatMap(check => check(copy) ?? []);
103
103
  export const versionReservationTypes = [
104
104
  'text-not-stated',
105
- 'type-not-stated',
106
105
  'witnessed-by-statement-only'
107
106
  ];
108
107
  const textStated = (_view, version) => version.edits ? undefined : {
109
108
  type: 'text-not-stated',
110
109
  note: 'The version does not state its edits, so it reads as the version it derives from.'
111
110
  };
112
- const typeStated = (_view, version) => version.versionType ? undefined : {
113
- type: 'type-not-stated',
114
- note: 'The version does not say whether it served as a master for several copies or exists on one only.'
115
- };
116
111
  const witnessedByFeatures = (view, version) => {
117
112
  const witnesses = witnessesOf(view, version.id);
118
113
  return witnesses.length > 0 && witnesses.every(({ by }) => by === 'statement') ? {
@@ -120,6 +115,6 @@ const witnessedByFeatures = (view, version) => {
120
115
  note: 'No copy\'s features carry what the version inserts; only copies that state they carry it bear witness to it.'
121
116
  } : undefined;
122
117
  };
123
- const versionChecks = [textStated, typeStated, witnessedByFeatures];
118
+ const versionChecks = [textStated, witnessedByFeatures];
124
119
  /** What the edition cannot vouch for in a version, in the order the checks are listed. */
125
120
  export const reservationsAboutVersion = (view, version) => versionChecks.flatMap(check => check(view, version) ?? []);
package/lib/schema.json CHANGED
@@ -2270,6 +2270,11 @@
2270
2270
  "type": "string",
2271
2271
  "ontology": "crm:P138i has representation"
2272
2272
  },
2273
+ "siglum": {
2274
+ "description": "A short siglum to identify the copy, e.g. \"W1\" or \"S2\". A copy without one is named by its keeper.",
2275
+ "type": "string",
2276
+ "ontology": "reo:siglum"
2277
+ },
2273
2278
  "@id": {
2274
2279
  "description": "A unique identifier for this object.",
2275
2280
  "type": "string"
@@ -2450,11 +2455,6 @@
2450
2455
  "description": "The reproducing system this version is coded for. One roll was often issued for several of them, and a version is a reading in one system's words: its expression types are that system's vocabulary and its notes sit on that bar's positions. A system the type vocabulary knows carries the IRI of its concept as `id`, from which the export takes the system's own context.",
2451
2456
  "ontology": "crm:P2 has type"
2452
2457
  },
2453
- "versionType": {
2454
- "$ref": "#/definitions/VersionType",
2455
- "description": "Whether the version served as a master for reproductions or exists on one copy only. Left out where that is not known, as for a version only a secondary witness hints at.",
2456
- "ontology": "crm:P2 has type"
2457
- },
2458
2458
  "@id": {
2459
2459
  "description": "A unique identifier for this object.",
2460
2460
  "type": "string"
@@ -2498,14 +2498,6 @@
2498
2498
  "type": "object",
2499
2499
  "ontology": "lrmoo:F28 Expression Creation"
2500
2500
  },
2501
- "VersionType": {
2502
- "description": "The type of a version. An 'edition' version may serve as the master for several roll copies; a 'unicum' version exists only on one specific copy.",
2503
- "enum": [
2504
- "edition",
2505
- "unicum"
2506
- ],
2507
- "type": "string"
2508
- },
2509
2501
  "VerticalSpan": {
2510
2502
  "description": "Describes the vertical extent of a feature on the roll, measured in track numbers. Track numbers correspond to positions on the tracker bar.",
2511
2503
  "properties": {
@@ -249,11 +249,6 @@
249
249
  "@context": { "@vocab": "https://w3id.org/reo/type/" }
250
250
  },
251
251
  "siglum": "reo:siglum",
252
- "versionType": {
253
- "@id": "crm:P2_has_type",
254
- "@type": "@vocab",
255
- "@context": { "@vocab": "https://w3id.org/reo/type/" }
256
- },
257
252
  "basedOn": "lrmoo:R76_is_derivative_of",
258
253
  "edits": "reo:involvedEdit",
259
254
  "motivations": "@included",
@@ -1,4 +1,4 @@
1
- import { Certainty } from "./Assumption";
1
+ import { Belief, Certainty } from "./Assumption";
2
2
  import { EditionView } from "./EditionView";
3
3
  export type WitnessBy = 'carriers' | 'statement';
4
4
  /** A copy that bears witness to a version, and how. */
@@ -9,6 +9,8 @@ export interface Witness {
9
9
  by: WitnessBy;
10
10
  /** How certainly a statement is held. Carriage through features is no statement and holds none. */
11
11
  certainty?: Certainty;
12
+ /** The belief a statement rests on, where it states one. */
13
+ belief?: Belief;
12
14
  }
13
15
  /**
14
16
  * The copies that bear witness to the version: those whose features carry
@@ -20,6 +22,13 @@ export interface Witness {
20
22
  * are not stated is witnessed by statement alone.
21
23
  */
22
24
  export declare const witnessesOf: (view: EditionView, versionId: string) => Witness[];
25
+ /**
26
+ * The versions the copy bears witness to, each with how, in the order the
27
+ * edition lists its versions.
28
+ */
29
+ export declare const versionsWitnessedBy: (view: EditionView, copyId: string) => (Witness & {
30
+ version: string;
31
+ })[];
23
32
  export type CarriageProblem = {
24
33
  copy: string;
25
34
  version: string;
package/lib/witnesses.js CHANGED
@@ -28,9 +28,19 @@ export const witnessesOf = (view, versionId) => {
28
28
  .filter(copy => !carrying.has(copy.id))
29
29
  .flatMap(copy => (copy.carries ?? [])
30
30
  .filter(statement => idOf(statement) === versionId)
31
- .map((statement) => ({ copy: copy.id, by: 'statement', certainty: certaintyOf(statement) })));
31
+ .map((statement) => {
32
+ const belief = statement['@annotation']?.belief;
33
+ return { copy: copy.id, by: 'statement', certainty: certaintyOf(statement), ...(belief && { belief }) };
34
+ }));
32
35
  return [...byCarriers, ...byStatement];
33
36
  };
37
+ /**
38
+ * The versions the copy bears witness to, each with how, in the order the
39
+ * edition lists its versions.
40
+ */
41
+ export const versionsWitnessedBy = (view, copyId) => view.edition.versions.flatMap(version => witnessesOf(view, version.id)
42
+ .filter(witness => witness.copy === copyId)
43
+ .map(witness => ({ ...witness, version: version.id })));
34
44
  /**
35
45
  * Where a copy's statement that it carries a version cannot stand: one
36
46
  * made although the copy's features carry symbols, which say by
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Digital editions of piano rolls: import, collation, editorial assumptions, JSON-LD export, and emulation through a reproducing system",
5
5
  "license": "MIT",
6
6
  "repository": {