@pubid/pubid 0.1.43 → 0.1.45
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/artifact/corpus.json.gz +0 -0
- package/dist/corpus/loader.d.ts +2 -0
- package/dist/corpus/loader.js +45 -2
- package/dist/flavors/ccsds/index.d.ts +3 -0
- package/dist/flavors/ccsds/index.js +61 -0
- package/dist/flavors/ccsds/model.d.ts +66 -0
- package/dist/flavors/ccsds/model.js +136 -0
- package/dist/flavors/cen_cenelec/model.d.ts +5 -0
- package/dist/flavors/cen_cenelec/model.js +5 -2
- package/dist/flavors/cen_pfs/index.d.ts +151 -0
- package/dist/flavors/cen_pfs/index.js +666 -0
- package/dist/flavors/iec/model.js +20 -3
- package/dist/flavors/index.js +6 -0
- package/dist/flavors/nist/model.js +8 -10
- package/dist/flavors/register-types.d.ts +1 -0
- package/dist/flavors/register-types.js +5 -0
- package/dist/pubid-urn/schemas/cen_pfs.d.ts +8 -0
- package/dist/pubid-urn/schemas/cen_pfs.js +33 -0
- package/dist/pubid-urn/schemas/index.js +2 -0
- package/package.json +1 -1
- package/vendor/parg/cen_pfs.json +1 -1
- package/vendor/parg/iso.json +1 -1
package/artifact/corpus.json.gz
CHANGED
|
Binary file
|
package/dist/corpus/loader.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CorpusCase, FlavorStatus } from "./types.js";
|
|
2
|
+
/** Parse corpus YAML under the psych wire contract (see above). */
|
|
3
|
+
export declare function parseCorpusYaml(text: string): unknown;
|
|
2
4
|
export interface FlavorPayloads {
|
|
3
5
|
/** Non-underscore payload files: canonical cases + aliases. */
|
|
4
6
|
cases: CorpusCase[];
|
package/dist/corpus/loader.js
CHANGED
|
@@ -1,13 +1,56 @@
|
|
|
1
1
|
import { readdirSync, readFileSync, existsSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { parse as parseYaml } from "yaml";
|
|
4
|
+
/**
|
|
5
|
+
* The corpus files are written by the ruby exporter's psych dump, so
|
|
6
|
+
* their wire form carries YAML 1.1 scalar resolution: psych keeps
|
|
7
|
+
* exponent spellings without a dot (`102E-42`, `45E-36`) as Strings,
|
|
8
|
+
* while the npm yaml package's 1.2 core schema floats them — the
|
|
9
|
+
* divergence behind pubid-ts#177. Loading the corpus is the boundary
|
|
10
|
+
* where the parse type is decided, so the loader reads it back under
|
|
11
|
+
* psych's float contract instead of patching serialization per site:
|
|
12
|
+
* a float needs the dot, and where psych keeps a String the loader
|
|
13
|
+
* keeps the String too. Other 1.1-vs-1.2 classes (legacy octal
|
|
14
|
+
* `0777`, `yes`-bool) never occur in the corpus and are left on the
|
|
15
|
+
* package default.
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- the yaml
|
|
18
|
+
// package's Tags union makes a discriminating map awkward; the shapes
|
|
19
|
+
// below are the package's own ScalarTag objects with test/resolve swapped.
|
|
20
|
+
const psychFloatTags = (tags) => tags.map((tag) => {
|
|
21
|
+
if (tag?.tag !== "tag:yaml.org,2002:float")
|
|
22
|
+
return tag;
|
|
23
|
+
const source = String(tag.test?.source);
|
|
24
|
+
if (source.includes("inf"))
|
|
25
|
+
return tag; // floatNaN: .inf/.nan as psych has them
|
|
26
|
+
if (tag.format === "EXP") {
|
|
27
|
+
// The exponent form: psych requires the dot AND the exponent sign
|
|
28
|
+
// (`1.0E-5` floats; `102E-42`, `1.5e3` stay Strings).
|
|
29
|
+
return {
|
|
30
|
+
...tag,
|
|
31
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*[eE][-+][0-9]+$/,
|
|
32
|
+
resolve: (str) => parseFloat(str.replace(/_/g, "")),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// The decimal form: dot required (psych accepts a bare `.5`, an
|
|
36
|
+
// optional fraction `1.`, and `1_000.5`-style underscores).
|
|
37
|
+
return {
|
|
38
|
+
...tag,
|
|
39
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
40
|
+
resolve: (str) => parseFloat(str.replace(/_/g, "")),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
/** Parse corpus YAML under the psych wire contract (see above). */
|
|
44
|
+
export function parseCorpusYaml(text) {
|
|
45
|
+
return parseYaml(text, { customTags: psychFloatTags });
|
|
46
|
+
}
|
|
4
47
|
/**
|
|
5
48
|
* The wire schema uses snake_case for exactly one field
|
|
6
49
|
* (non_normalized_aliases); the loader is the boundary that normalises
|
|
7
50
|
* it, so a missed mapping can never silently disable a check.
|
|
8
51
|
*/
|
|
9
52
|
function loadPayload(path) {
|
|
10
|
-
const doc =
|
|
53
|
+
const doc = parseCorpusYaml(readFileSync(path, "utf8"));
|
|
11
54
|
if (!Array.isArray(doc))
|
|
12
55
|
return [];
|
|
13
56
|
return doc.map((row) => {
|
|
@@ -26,7 +69,7 @@ function loadStatus(dir) {
|
|
|
26
69
|
if (!existsSync(path)) {
|
|
27
70
|
throw new Error(`missing _status.yaml in ${dir} - every flavor has one`);
|
|
28
71
|
}
|
|
29
|
-
const doc =
|
|
72
|
+
const doc = parseCorpusYaml(readFileSync(path, "utf8"));
|
|
30
73
|
if (typeof doc.clean !== "boolean") {
|
|
31
74
|
throw new Error(`malformed _status.yaml in ${dir}: clean must be boolean`);
|
|
32
75
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ParseFailed } from "../../grammar/engine.js";
|
|
2
|
+
import { PubidRuntime } from "../../parg/runtime.js";
|
|
3
|
+
import { CcsdsBaseIdentifier, CcsdsCorrigendumIdentifier } from "./model.js";
|
|
4
|
+
export * from "./model.js";
|
|
5
|
+
/**
|
|
6
|
+
* The ccsds parse entry (pubid-ts#178): the grammar runtime is the SAME
|
|
7
|
+
* baked artifact the Ruby flavor runs (pubid-grammar
|
|
8
|
+
* grammars/ccsds.parg -> artifacts/ccsds.json, the bindings carry flat
|
|
9
|
+
* strings), loaded through the artifact runtime, so grammar changes
|
|
10
|
+
* land once and this side cannot drift. The builder mirrors
|
|
11
|
+
* Pubid::Ccsds::Builder: corrigenda fold last-wraps-first onto the
|
|
12
|
+
* base; the update-code line normalizes first (Core::UpdateCodes).
|
|
13
|
+
*/
|
|
14
|
+
// data/ccsds/update_codes.yaml — pre-parse normalizations (full-line).
|
|
15
|
+
const UPDATE_CODE_LINES = {
|
|
16
|
+
"CCSDS 320.0-B-1-S Corrigendum 1": "CCSDS 320.0-B-1-S Cor. 1",
|
|
17
|
+
};
|
|
18
|
+
function applyUpdateCodes(input) {
|
|
19
|
+
return UPDATE_CODE_LINES[input] ?? input;
|
|
20
|
+
}
|
|
21
|
+
// --- Builder -----------------------------------------------------------------
|
|
22
|
+
const s = (v) => {
|
|
23
|
+
if (v === undefined || v === null)
|
|
24
|
+
return undefined;
|
|
25
|
+
const str = String(v);
|
|
26
|
+
return str.length > 0 ? str : undefined;
|
|
27
|
+
};
|
|
28
|
+
function buildBase(data) {
|
|
29
|
+
return new CcsdsBaseIdentifier({
|
|
30
|
+
number: s(data["number"]) ?? "",
|
|
31
|
+
part: s(data["part"]),
|
|
32
|
+
type: s(data["type"]),
|
|
33
|
+
edition: s(data["edition"]),
|
|
34
|
+
suffix: s(data["suffix"]),
|
|
35
|
+
language: s(data["language"]),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** ruby Builder.build: corrigenda fold last-wraps-first onto the base. */
|
|
39
|
+
function build(data) {
|
|
40
|
+
const corrigenda = data["corrigenda"];
|
|
41
|
+
if (Array.isArray(corrigenda) && corrigenda.length > 0) {
|
|
42
|
+
const base = buildBase({ ...data, corrigenda: undefined });
|
|
43
|
+
return corrigenda.reduce((current, c) => new CcsdsCorrigendumIdentifier({ base: current, number: s(c["cor_number"]) ?? "" }), base);
|
|
44
|
+
}
|
|
45
|
+
return buildBase(data);
|
|
46
|
+
}
|
|
47
|
+
// --- Implementation ----------------------------------------------------------
|
|
48
|
+
let cachedRuntime;
|
|
49
|
+
export function ccsdsGrammarImplementation() {
|
|
50
|
+
return {
|
|
51
|
+
parse(input) {
|
|
52
|
+
cachedRuntime ??= PubidRuntime.load("ccsds");
|
|
53
|
+
const normalized = applyUpdateCodes(input);
|
|
54
|
+
const bound = cachedRuntime.parseAndBind(normalized);
|
|
55
|
+
if (bound === null || typeof bound !== "object") {
|
|
56
|
+
throw new ParseFailed("ccsds: the artifact rejected the input", 0);
|
|
57
|
+
}
|
|
58
|
+
return build(bound);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
2
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
3
|
+
/**
|
|
4
|
+
* The ccsds model declarations (pubid-ts#178) — the parg-free
|
|
5
|
+
* registration module (the worker manifest imports THIS file; the
|
|
6
|
+
* artifact-backed parse entry lives on the flavor index). 1:1 port of
|
|
7
|
+
* lib/pubid/ccsds/identifier.rb + identifiers/ + urn_generator.rb.
|
|
8
|
+
*
|
|
9
|
+
* Faces pinned by the reference: Base#to_s composes by hand ("CCSDS "
|
|
10
|
+
* publisher lead); UrnGenerator#generate_base_urn assembles
|
|
11
|
+
* `urn:ccsds:<number>[.part][-type][-edition][-suffix]`, with the
|
|
12
|
+
* supplement chain emitting `:cor.<n>` segments. A language face makes
|
|
13
|
+
* the reference's own to_urn RAISE (`language&.code` on a plain String —
|
|
14
|
+
* NoMethodError; the corpus exporter omits the `urn` representation for
|
|
15
|
+
* those rows exactly because of this) — mirrored, not papered over.
|
|
16
|
+
*/
|
|
17
|
+
/** ruby UrnGenerator — the base body is ONE segment; supplements chain
|
|
18
|
+
* `:cor.<n>` segments onto it. */
|
|
19
|
+
export declare class CcsdsUrnGenerator extends BaseUrnGenerator<CcsdsIdentifier> {
|
|
20
|
+
generate(): string;
|
|
21
|
+
private generateBaseUrn;
|
|
22
|
+
private generateSupplementUrn;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Abstract root for every CCSDS identifier AND the polymorphic type the
|
|
26
|
+
* supplements' `base` attribute points at — never itself a serialized
|
|
27
|
+
* type (absent from the registry, like ruby's CCSDS_TYPE_MAP omits it;
|
|
28
|
+
* that is what breaks the supplement recursion). Every code component is
|
|
29
|
+
* a plain string, overriding the inherited component types.
|
|
30
|
+
*/
|
|
31
|
+
export declare abstract class CcsdsIdentifier extends BaseIdentifier {
|
|
32
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
33
|
+
static subsetStrict: string[];
|
|
34
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
35
|
+
readonly number: string;
|
|
36
|
+
readonly part: string | undefined;
|
|
37
|
+
readonly type: string | undefined;
|
|
38
|
+
readonly edition: string | undefined;
|
|
39
|
+
readonly suffix: string | undefined;
|
|
40
|
+
readonly language: string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** The published standard (ruby Identifiers::Base). */
|
|
43
|
+
export declare class CcsdsBaseIdentifier extends CcsdsIdentifier {
|
|
44
|
+
static polymorphicName: string;
|
|
45
|
+
static urnGenerator: typeof CcsdsUrnGenerator;
|
|
46
|
+
/** ruby Base#to_s: hand composition, publisher lead hard-coded. */
|
|
47
|
+
render(): string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Base class for CCSDS supplements; `base` points at the abstract root
|
|
51
|
+
* (never a concrete subclass of itself — the recursion break).
|
|
52
|
+
*/
|
|
53
|
+
export declare abstract class CcsdsSupplementIdentifier extends CcsdsIdentifier {
|
|
54
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
55
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
56
|
+
readonly base: CcsdsIdentifier | undefined;
|
|
57
|
+
}
|
|
58
|
+
/** The corrigendum (ruby Identifiers::Corrigendum); its `number` is the
|
|
59
|
+
* corrigendum sequence, mirroring ISO. */
|
|
60
|
+
export declare class CcsdsCorrigendumIdentifier extends CcsdsSupplementIdentifier {
|
|
61
|
+
static polymorphicName: string;
|
|
62
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
63
|
+
static urnGenerator: typeof CcsdsUrnGenerator;
|
|
64
|
+
/** ruby Corrigendum#to_s: the base spelling, then " Cor. n". */
|
|
65
|
+
render(): string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { BaseIdentifier, registerType } from "../../model/identifier.js";
|
|
2
|
+
import { extendAttributes, keyValue } from "../../model/attribute.js";
|
|
3
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
4
|
+
/**
|
|
5
|
+
* The ccsds model declarations (pubid-ts#178) — the parg-free
|
|
6
|
+
* registration module (the worker manifest imports THIS file; the
|
|
7
|
+
* artifact-backed parse entry lives on the flavor index). 1:1 port of
|
|
8
|
+
* lib/pubid/ccsds/identifier.rb + identifiers/ + urn_generator.rb.
|
|
9
|
+
*
|
|
10
|
+
* Faces pinned by the reference: Base#to_s composes by hand ("CCSDS "
|
|
11
|
+
* publisher lead); UrnGenerator#generate_base_urn assembles
|
|
12
|
+
* `urn:ccsds:<number>[.part][-type][-edition][-suffix]`, with the
|
|
13
|
+
* supplement chain emitting `:cor.<n>` segments. A language face makes
|
|
14
|
+
* the reference's own to_urn RAISE (`language&.code` on a plain String —
|
|
15
|
+
* NoMethodError; the corpus exporter omits the `urn` representation for
|
|
16
|
+
* those rows exactly because of this) — mirrored, not papered over.
|
|
17
|
+
*/
|
|
18
|
+
/** ruby UrnGenerator — the base body is ONE segment; supplements chain
|
|
19
|
+
* `:cor.<n>` segments onto it. */
|
|
20
|
+
export class CcsdsUrnGenerator extends BaseUrnGenerator {
|
|
21
|
+
generate() {
|
|
22
|
+
if (this.identifier instanceof CcsdsSupplementIdentifier) {
|
|
23
|
+
return this.generateSupplementUrn(this.identifier);
|
|
24
|
+
}
|
|
25
|
+
return this.generateBaseUrn(this.identifier);
|
|
26
|
+
}
|
|
27
|
+
generateBaseUrn(id) {
|
|
28
|
+
const parts = ["urn", "ccsds"];
|
|
29
|
+
const identifierParts = [];
|
|
30
|
+
if (id.number)
|
|
31
|
+
identifierParts.push(id.number);
|
|
32
|
+
if (id.part)
|
|
33
|
+
identifierParts.push(`.${id.part}`);
|
|
34
|
+
// book_color never populates on the modern hierarchy; type carries
|
|
35
|
+
// the letter (ruby: `elsif identifier.type`).
|
|
36
|
+
if (id.type)
|
|
37
|
+
identifierParts.push(`-${id.type}`);
|
|
38
|
+
if (id.edition)
|
|
39
|
+
identifierParts.push(`-${id.edition}`);
|
|
40
|
+
// ruby: retired ? "-S" : suffix — retired never populates here.
|
|
41
|
+
if (id.suffix)
|
|
42
|
+
identifierParts.push(`-${id.suffix}`);
|
|
43
|
+
if (identifierParts.length > 0)
|
|
44
|
+
parts.push(identifierParts.join(""));
|
|
45
|
+
if (id.language !== undefined) {
|
|
46
|
+
// Mirrored reference failure: `language&.code` on a plain String
|
|
47
|
+
// raises NoMethodError in ruby (the exporter omits these URNs).
|
|
48
|
+
throw new TypeError("ccsds: the reference raises on a language face (undefined method 'code' for String); no URN exists for it");
|
|
49
|
+
}
|
|
50
|
+
return parts.join(":");
|
|
51
|
+
}
|
|
52
|
+
generateSupplementUrn(supp) {
|
|
53
|
+
const parts = ["urn", "ccsds"];
|
|
54
|
+
const chain = [];
|
|
55
|
+
let current = supp;
|
|
56
|
+
while (current instanceof CcsdsSupplementIdentifier) {
|
|
57
|
+
chain.unshift(current);
|
|
58
|
+
current = current.base;
|
|
59
|
+
}
|
|
60
|
+
if (current === undefined) {
|
|
61
|
+
throw new TypeError("ccsds: a supplement without a base has no URN body");
|
|
62
|
+
}
|
|
63
|
+
const baseUrn = this.generateBaseUrn(current);
|
|
64
|
+
parts.push(baseUrn.replace(/^urn:ccsds:/, ""));
|
|
65
|
+
for (const link of chain) {
|
|
66
|
+
if (link.number !== undefined && link.number !== "") {
|
|
67
|
+
parts.push(`cor.${link.number}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return parts.join(":");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Abstract root for every CCSDS identifier AND the polymorphic type the
|
|
75
|
+
* supplements' `base` attribute points at — never itself a serialized
|
|
76
|
+
* type (absent from the registry, like ruby's CCSDS_TYPE_MAP omits it;
|
|
77
|
+
* that is what breaks the supplement recursion). Every code component is
|
|
78
|
+
* a plain string, overriding the inherited component types.
|
|
79
|
+
*/
|
|
80
|
+
export class CcsdsIdentifier extends BaseIdentifier {
|
|
81
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
82
|
+
edition: { type: "string" },
|
|
83
|
+
type: { type: "string" },
|
|
84
|
+
suffix: { type: "string" },
|
|
85
|
+
language: { type: "string" },
|
|
86
|
+
});
|
|
87
|
+
// ruby subset_strict :language / :suffix — a nil language means the
|
|
88
|
+
// original English document, a nil suffix the current document.
|
|
89
|
+
static subsetStrict = ["language", "suffix"];
|
|
90
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "part", to: "part" }, { wire: "edition", to: "edition" }, { wire: "type", to: "type" }, { wire: "suffix", to: "suffix" }, { wire: "language", to: "language" });
|
|
91
|
+
}
|
|
92
|
+
/** The published standard (ruby Identifiers::Base). */
|
|
93
|
+
export class CcsdsBaseIdentifier extends CcsdsIdentifier {
|
|
94
|
+
static polymorphicName = "pubid:ccsds:base";
|
|
95
|
+
static urnGenerator = CcsdsUrnGenerator;
|
|
96
|
+
/** ruby Base#to_s: hand composition, publisher lead hard-coded. */
|
|
97
|
+
render() {
|
|
98
|
+
let result = `CCSDS ${this.number ?? ""}`;
|
|
99
|
+
if (this.part !== undefined)
|
|
100
|
+
result += `.${this.part}`;
|
|
101
|
+
if (this.type !== undefined)
|
|
102
|
+
result += `-${this.type}`;
|
|
103
|
+
if (this.edition !== undefined)
|
|
104
|
+
result += `-${this.edition}`;
|
|
105
|
+
if (this.suffix !== undefined)
|
|
106
|
+
result += `-${this.suffix}`;
|
|
107
|
+
if (this.language !== undefined)
|
|
108
|
+
result += ` - ${this.language} Translated`;
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
registerType(CcsdsBaseIdentifier);
|
|
113
|
+
/**
|
|
114
|
+
* Base class for CCSDS supplements; `base` points at the abstract root
|
|
115
|
+
* (never a concrete subclass of itself — the recursion break).
|
|
116
|
+
*/
|
|
117
|
+
export class CcsdsSupplementIdentifier extends CcsdsIdentifier {
|
|
118
|
+
static attributes = extendAttributes(CcsdsIdentifier, {
|
|
119
|
+
base: { type: CcsdsIdentifier },
|
|
120
|
+
});
|
|
121
|
+
static mappings = keyValue({ wire: "base", to: "base" });
|
|
122
|
+
}
|
|
123
|
+
/** The corrigendum (ruby Identifiers::Corrigendum); its `number` is the
|
|
124
|
+
* corrigendum sequence, mirroring ISO. */
|
|
125
|
+
export class CcsdsCorrigendumIdentifier extends CcsdsSupplementIdentifier {
|
|
126
|
+
static polymorphicName = "pubid:ccsds:corrigendum";
|
|
127
|
+
// The merged mapping list (lutaml semantics): the root's code fields
|
|
128
|
+
// first (a supplement's own stay nil), then base.
|
|
129
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "part", to: "part" }, { wire: "edition", to: "edition" }, { wire: "type", to: "type" }, { wire: "suffix", to: "suffix" }, { wire: "language", to: "language" }, { wire: "base", to: "base" });
|
|
130
|
+
static urnGenerator = CcsdsUrnGenerator;
|
|
131
|
+
/** ruby Corrigendum#to_s: the base spelling, then " Cor. n". */
|
|
132
|
+
render() {
|
|
133
|
+
return `${this.base?.render() ?? ""} Cor. ${this.number ?? ""}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
registerType(CcsdsCorrigendumIdentifier);
|
|
@@ -35,6 +35,11 @@ export declare abstract class CenIdentifier extends BaseIdentifier {
|
|
|
35
35
|
root(): CenIdentifier;
|
|
36
36
|
toUrn(): string;
|
|
37
37
|
}
|
|
38
|
+
/** MR string of a nested iso/iec document read from its wire hash.
|
|
39
|
+
* Exported for the cen_pfs port: the compiled flavor's fused-URN segment
|
|
40
|
+
* is the adopted document's MR string, the same computation the coded
|
|
41
|
+
* flavor performs. */
|
|
42
|
+
export declare function mrFromHash(hash: Record<string, unknown>): string;
|
|
38
43
|
export declare const CEN_DOCUMENT_CLASSES: Map<string, IdentifierStatic>;
|
|
39
44
|
export declare const CenelecHarmonizationDocumentClass: IdentifierStatic;
|
|
40
45
|
export declare const AmendmentClass: IdentifierStatic;
|
|
@@ -197,8 +197,11 @@ const ISO_TYPE_SEGMENT = {
|
|
|
197
197
|
"technical-report": "tr",
|
|
198
198
|
guide: "guide",
|
|
199
199
|
};
|
|
200
|
-
/** MR string of a nested iso/iec document read from its wire hash.
|
|
201
|
-
|
|
200
|
+
/** MR string of a nested iso/iec document read from its wire hash.
|
|
201
|
+
* Exported for the cen_pfs port: the compiled flavor's fused-URN segment
|
|
202
|
+
* is the adopted document's MR string, the same computation the coded
|
|
203
|
+
* flavor performs. */
|
|
204
|
+
export function mrFromHash(hash) {
|
|
202
205
|
const type = String(hash["_type"] ?? "");
|
|
203
206
|
const segments = [];
|
|
204
207
|
if (type.startsWith("pubid:iso")) {
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { FlavorImplementation } from "../../conformance/implementation.js";
|
|
2
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
3
|
+
import type { IdentifierStatic } from "../../model/identifier.js";
|
|
4
|
+
import { type FieldMapping } from "../../model/attribute.js";
|
|
5
|
+
import { PubidDate } from "../../model/component.js";
|
|
6
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
7
|
+
/**
|
|
8
|
+
* The PFS-compiled cen flavor (pubid/pubid#706; the cen_pfs full
|
|
9
|
+
* absorption is pubid-grammar#121 + pubid#721's regeneration) — one
|
|
10
|
+
* definition file, both engines: the grammar runtime is the SAME baked
|
|
11
|
+
* artifact the Ruby flavor runs (pubid-grammar artifacts/cen_pfs.json,
|
|
12
|
+
* compiled from definitions/cen.pfs by the compiler with the six
|
|
13
|
+
* declared-emission features), loaded through the artifact runtime, so
|
|
14
|
+
* grammar changes land once and this side cannot drift. Nothing is
|
|
15
|
+
* hand-rolled serialization: the model is declared attributes on the
|
|
16
|
+
* unified model (serialization derives from BaseIdentifier), the nine
|
|
17
|
+
* deliverable families are declared document classes (the token in type
|
|
18
|
+
* or publisher position selects the class, the designation token
|
|
19
|
+
* defaulting the publisher column), the prEN/FprEN draft stages fold
|
|
20
|
+
* onto the typed stage whose compact wire code is the definition's
|
|
21
|
+
* stage map, and the render body is the definition's canonical template
|
|
22
|
+
* with presence-guarded optionals. The wrapper classes are the compiled
|
|
23
|
+
* classes the definition's supplements declaration synthesizes (the
|
|
24
|
+
* slash run folds into the standalone wrapper chain, the plus run into
|
|
25
|
+
* the consolidated bundle, the FRAG face wraps the amendment), and the
|
|
26
|
+
* adopted-base dispatch is the §4 coded escape hatch: the hook parses
|
|
27
|
+
* the adopted string with the owning flavor's implementation, switches
|
|
28
|
+
* the ENV adoption to the prestandard, and owns the implicit IEC-range
|
|
29
|
+
* adoption — the same two explicit call points the generated Ruby
|
|
30
|
+
* builder performs. The parity gate (test/cen-pfs-parity.test.ts) pins
|
|
31
|
+
* byte-identity with the coded
|
|
32
|
+
* {@linkcode import("../cen_cenelec/model.js").CenIdentifier} over the
|
|
33
|
+
* shared conformance set (the full 189-row corpus inventory).
|
|
34
|
+
*/
|
|
35
|
+
/** The declared draft stages (the definition's `stages:` map): the
|
|
36
|
+
* serialized code is the key, the official-URN stage code the declared
|
|
37
|
+
* `urn:` value — the same trio the coded flavor's stage registry rows
|
|
38
|
+
* carry, restricted to the declared subset. */
|
|
39
|
+
export interface CenPfsStage {
|
|
40
|
+
code: string;
|
|
41
|
+
stage_code: string;
|
|
42
|
+
type_code: string;
|
|
43
|
+
abbr: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const STAGES: Record<string, CenPfsStage>;
|
|
46
|
+
export declare function locateStageByCode(code: string): CenPfsStage | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The compiled flavor's identifier base: the shared render machinery
|
|
49
|
+
* (the definition's canonical template) and the FLAVOR-LOCAL type
|
|
50
|
+
* dispatch. The concrete classes carry the scheme's canonical wire tags
|
|
51
|
+
* (pubid:cencenelec:…), which deliberately stay OUT of the global type
|
|
52
|
+
* map — one scheme, one `_type`, one global resolution (the coded
|
|
53
|
+
* class); {@linkcode fromHash} routes the tags back here flavor-locally
|
|
54
|
+
* first (mirroring Ruby's flavor-base polymorphic_type_map), then falls
|
|
55
|
+
* through to the global registry for the cross-flavor nested identifiers
|
|
56
|
+
* (the adopted ISO/IEC document), exactly the TypeResolver order.
|
|
57
|
+
*/
|
|
58
|
+
export declare abstract class CenPfsIdentifier extends BaseIdentifier {
|
|
59
|
+
/** The wire tags the compiled classes answer, resolved flavor-locally. */
|
|
60
|
+
static localTypeMap: Map<string, new (attrs?: Record<string, unknown>) => CenPfsIdentifier>;
|
|
61
|
+
readonly number: string | undefined;
|
|
62
|
+
readonly part: string | undefined;
|
|
63
|
+
readonly version: string | undefined;
|
|
64
|
+
readonly date: PubidDate | undefined;
|
|
65
|
+
readonly publisher: string | undefined;
|
|
66
|
+
readonly copublishers: string[] | undefined;
|
|
67
|
+
readonly type: string | undefined;
|
|
68
|
+
readonly typedStage: CenPfsStage | undefined;
|
|
69
|
+
/** The alias's own from_hash: the scheme tags route HERE, the
|
|
70
|
+
* cross-flavor tags (a nested adopted ISO/IEC document) fall through
|
|
71
|
+
* to the global registry, while the cen tags never reach the coded
|
|
72
|
+
* classes (coexistence, not cutover). */
|
|
73
|
+
static fromHash(hash: Record<string, unknown>): BaseIdentifier;
|
|
74
|
+
/** The definition's canonical face — the head alternation picks the
|
|
75
|
+
* first alternative whose direct fields captured: the draft face, the
|
|
76
|
+
* Guide word face, the adopted face, else the publisher face with the
|
|
77
|
+
* optional slash type; the run and the FRAG face follow. */
|
|
78
|
+
render(): string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The official URN: the definition's urn.official fused segments —
|
|
82
|
+
* urn:cen[:<publisher group>][:<adopted fused MR>][:<composed
|
|
83
|
+
* code>][:<year>][:<stage code>]; a wrapper reads through to its
|
|
84
|
+
* subject and appends its declared chain (:amd:/:cor:), the
|
|
85
|
+
* consolidated bundle marks each member with the plus marker, and the
|
|
86
|
+
* fragment's :frag: segments come last.
|
|
87
|
+
*/
|
|
88
|
+
declare class CenPfsUrnGenerator extends BaseUrnGenerator<CenPfsIdentifier> {
|
|
89
|
+
generate(): string;
|
|
90
|
+
}
|
|
91
|
+
/** The nine deliverable families plus the adoption wrapper (the
|
|
92
|
+
* definition's `types:` map): the token-free EuropeanNorm is the
|
|
93
|
+
* default class. */
|
|
94
|
+
export declare const CenPfsEuropeanNorm: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
95
|
+
export declare const CenPfsAdoptedEuropeanNorm: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
96
|
+
export declare const CenPfsTechnicalReport: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
97
|
+
export declare const CenPfsTechnicalSpecification: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
98
|
+
export declare const CenPfsGuide: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
99
|
+
export declare const CenPfsCenReport: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
100
|
+
export declare const CenPfsCenWorkshopAgreement: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
101
|
+
export declare const CenPfsEuropeanSpecification: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
102
|
+
export declare const CenPfsEuropeanPrestandard: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
103
|
+
export declare const CenPfsHarmonizationDocument: (new (attrs?: Record<string, unknown>) => CenPfsIdentifier) & IdentifierStatic;
|
|
104
|
+
/** The supplement wrapper base: the wrapper owns its ordinal and the
|
|
105
|
+
* base identifier; every rendered face reads through. */
|
|
106
|
+
declare abstract class CenPfsSupplement extends CenPfsIdentifier {
|
|
107
|
+
static get attributes(): import("../../model/attribute.js").AttributeTable;
|
|
108
|
+
static get mappings(): FieldMapping[];
|
|
109
|
+
static urnGenerator: typeof CenPfsUrnGenerator;
|
|
110
|
+
readonly base: CenPfsIdentifier | undefined;
|
|
111
|
+
readonly year: string | undefined;
|
|
112
|
+
readonly month: string | undefined;
|
|
113
|
+
/** The wrapper's date: "2016-11", "2003", or undefined. */
|
|
114
|
+
supplementDate(): string | undefined;
|
|
115
|
+
/** The printed notation: the kind face, the ordinal (absent for an
|
|
116
|
+
* unnumbered corrigendum) and the declared date tail. */
|
|
117
|
+
supplementNotation(): string;
|
|
118
|
+
}
|
|
119
|
+
export declare class CenPfsAmendment extends CenPfsSupplement {
|
|
120
|
+
/** The kind face "A" is the run's dispatch token and the notation
|
|
121
|
+
* face. */
|
|
122
|
+
static get polymorphicName(): string;
|
|
123
|
+
static FACE: string;
|
|
124
|
+
}
|
|
125
|
+
export declare class CenPfsCorrigendum extends CenPfsSupplement {
|
|
126
|
+
/** The kind face "AC" is the run's dispatch token and the notation
|
|
127
|
+
* face. */
|
|
128
|
+
static get polymorphicName(): string;
|
|
129
|
+
static FACE: string;
|
|
130
|
+
}
|
|
131
|
+
/** The consolidated (plus-run) bundle: the base document is the first
|
|
132
|
+
* member; the supplements carry no base. */
|
|
133
|
+
export declare class CenPfsConsolidatedIdentifier extends CenPfsIdentifier {
|
|
134
|
+
static get polymorphicName(): string;
|
|
135
|
+
static get attributes(): import("../../model/attribute.js").AttributeTable;
|
|
136
|
+
static get mappings(): FieldMapping[];
|
|
137
|
+
static urnGenerator: typeof CenPfsUrnGenerator;
|
|
138
|
+
readonly identifiers: CenPfsIdentifier[];
|
|
139
|
+
}
|
|
140
|
+
/** The fragment wrapper: a fragment of the amendment it wraps; the
|
|
141
|
+
* fragment ordinal is its own `number`. */
|
|
142
|
+
export declare class CenPfsFragment extends CenPfsIdentifier {
|
|
143
|
+
static get polymorphicName(): string;
|
|
144
|
+
static get attributes(): import("../../model/attribute.js").AttributeTable;
|
|
145
|
+
static get mappings(): FieldMapping[];
|
|
146
|
+
static urnGenerator: typeof CenPfsUrnGenerator;
|
|
147
|
+
readonly base: CenPfsIdentifier | undefined;
|
|
148
|
+
}
|
|
149
|
+
export declare function buildCenPfsIdentifier(flat: Record<string, unknown>): CenPfsIdentifier;
|
|
150
|
+
export declare function cenPfsGrammarImplementation(): FlavorImplementation;
|
|
151
|
+
export {};
|