@pubid/pubid 0.1.41 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flavors/calconnect_pfs/index.d.ts +51 -0
- package/dist/flavors/calconnect_pfs/index.js +118 -0
- package/dist/flavors/etsi_pfs/index.d.ts +100 -0
- package/dist/flavors/etsi_pfs/index.js +265 -0
- package/dist/flavors/index.js +6 -0
- package/dist/pubid-urn/schemas/calconnect_pfs.d.ts +8 -0
- package/dist/pubid-urn/schemas/calconnect_pfs.js +16 -0
- package/dist/pubid-urn/schemas/etsi_pfs.d.ts +8 -0
- package/dist/pubid-urn/schemas/etsi_pfs.js +20 -0
- package/dist/pubid-urn/schemas/index.d.ts +1 -1
- package/dist/pubid-urn/schemas/index.js +5 -1
- package/package.json +1 -1
- package/vendor/parg/cen_pfs.json +1 -1
- package/vendor/parg/etsi_pfs.json +1 -1
- package/vendor/parg/iso.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { FlavorImplementation } from "../../conformance/implementation.js";
|
|
2
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
3
|
+
import { PubidDate } from "../../model/component.js";
|
|
4
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
5
|
+
/**
|
|
6
|
+
* The PFS-compiled calconnect flavor (pubid/pubid#706 §8) — one
|
|
7
|
+
* definition file, both engines: the grammar runtime is the SAME baked
|
|
8
|
+
* artifact the Ruby flavor runs (pubid-grammar
|
|
9
|
+
* artifacts/calconnect_pfs.json, compiled from definitions/calconnect.pfs),
|
|
10
|
+
* loaded through the artifact runtime, so grammar changes land once and
|
|
11
|
+
* this side cannot drift. Nothing is hand-rolled: the model is declared
|
|
12
|
+
* attributes on the unified model (serialization derives from
|
|
13
|
+
* BaseIdentifier), the publication date folds into the shared
|
|
14
|
+
* PubidDate exactly as the definition's `date: fields:` declares, and
|
|
15
|
+
* the render body is the definition's canonical template. The parity
|
|
16
|
+
* gate (test/calconnect-pfs-parity.test.ts) pins byte-identity with the
|
|
17
|
+
* coded {@linkcode import("../calconnect").CalconnectIdentifier} over
|
|
18
|
+
* the shared conformance set.
|
|
19
|
+
*/
|
|
20
|
+
/** The official URN: the definition's urn.official segments
|
|
21
|
+
* (urn:calconnect[:<series>]:<number>[:<date>]) — an absent field
|
|
22
|
+
* leaves no segment, the date group renders year[-month[-day]]. */
|
|
23
|
+
declare class CalconnectPfsUrnGenerator extends BaseUrnGenerator<CalconnectPfsIdentifier> {
|
|
24
|
+
generate(): string;
|
|
25
|
+
}
|
|
26
|
+
export declare class CalconnectPfsIdentifier extends BaseIdentifier {
|
|
27
|
+
/**
|
|
28
|
+
* The SCHEME-canonical wire tag (declared in the definition): to_hash
|
|
29
|
+
* is byte-identical with the coded flavor. Deliberately NOT registered
|
|
30
|
+
* in the global type map — one scheme, one `_type`, one global
|
|
31
|
+
* resolution (the coded class); {@linkcode fromHash} routes the tag
|
|
32
|
+
* back here flavor-locally, mirroring Ruby's CC_TYPE_MAP.
|
|
33
|
+
*/
|
|
34
|
+
static polymorphicName: string;
|
|
35
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
36
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
37
|
+
static urnGenerator: typeof CalconnectPfsUrnGenerator;
|
|
38
|
+
readonly series: string | undefined;
|
|
39
|
+
readonly number: string;
|
|
40
|
+
readonly date: PubidDate | undefined;
|
|
41
|
+
/** The definition's canonical face: CC["/" series]" " number
|
|
42
|
+
* [":" year["-" month"-" day]] — every optional renders only what
|
|
43
|
+
* the input carried. */
|
|
44
|
+
render(): string;
|
|
45
|
+
/** The alias's own from_hash: the scheme tag routes HERE, while the
|
|
46
|
+
* global resolution keeps answering the coded class (coexistence, not
|
|
47
|
+
* cutover). */
|
|
48
|
+
static fromHash(hash: Record<string, unknown>): BaseIdentifier;
|
|
49
|
+
}
|
|
50
|
+
export declare function calconnectPfsGrammarImplementation(): FlavorImplementation;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ParseFailed } from "../../grammar/engine.js";
|
|
2
|
+
import { PubidRuntime } from "../../parg/runtime.js";
|
|
3
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
4
|
+
import { extendAttributes, keyValue } from "../../model/attribute.js";
|
|
5
|
+
import { PubidDate } from "../../model/component.js";
|
|
6
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
7
|
+
/**
|
|
8
|
+
* The PFS-compiled calconnect flavor (pubid/pubid#706 §8) — one
|
|
9
|
+
* definition file, both engines: the grammar runtime is the SAME baked
|
|
10
|
+
* artifact the Ruby flavor runs (pubid-grammar
|
|
11
|
+
* artifacts/calconnect_pfs.json, compiled from definitions/calconnect.pfs),
|
|
12
|
+
* loaded through the artifact runtime, so grammar changes land once and
|
|
13
|
+
* this side cannot drift. Nothing is hand-rolled: the model is declared
|
|
14
|
+
* attributes on the unified model (serialization derives from
|
|
15
|
+
* BaseIdentifier), the publication date folds into the shared
|
|
16
|
+
* PubidDate exactly as the definition's `date: fields:` declares, and
|
|
17
|
+
* the render body is the definition's canonical template. The parity
|
|
18
|
+
* gate (test/calconnect-pfs-parity.test.ts) pins byte-identity with the
|
|
19
|
+
* coded {@linkcode import("../calconnect").CalconnectIdentifier} over
|
|
20
|
+
* the shared conformance set.
|
|
21
|
+
*/
|
|
22
|
+
/** The official URN: the definition's urn.official segments
|
|
23
|
+
* (urn:calconnect[:<series>]:<number>[:<date>]) — an absent field
|
|
24
|
+
* leaves no segment, the date group renders year[-month[-day]]. */
|
|
25
|
+
class CalconnectPfsUrnGenerator extends BaseUrnGenerator {
|
|
26
|
+
generate() {
|
|
27
|
+
const id = this.identifier;
|
|
28
|
+
const parts = ["urn", "calconnect"];
|
|
29
|
+
if (id.series !== undefined)
|
|
30
|
+
parts.push(id.series);
|
|
31
|
+
parts.push(id.number);
|
|
32
|
+
const date = id.date?.render();
|
|
33
|
+
if (date !== undefined && date !== "")
|
|
34
|
+
parts.push(date);
|
|
35
|
+
return parts.join(":");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class CalconnectPfsIdentifier extends BaseIdentifier {
|
|
39
|
+
/**
|
|
40
|
+
* The SCHEME-canonical wire tag (declared in the definition): to_hash
|
|
41
|
+
* is byte-identical with the coded flavor. Deliberately NOT registered
|
|
42
|
+
* in the global type map — one scheme, one `_type`, one global
|
|
43
|
+
* resolution (the coded class); {@linkcode fromHash} routes the tag
|
|
44
|
+
* back here flavor-locally, mirroring Ruby's CC_TYPE_MAP.
|
|
45
|
+
*/
|
|
46
|
+
static polymorphicName = "pubid:calconnect:standard";
|
|
47
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
48
|
+
series: { type: "string" },
|
|
49
|
+
number: { type: "string" },
|
|
50
|
+
});
|
|
51
|
+
static mappings = keyValue({ wire: "series", to: "series" }, { wire: "number", to: "number" }, {
|
|
52
|
+
wire: "year",
|
|
53
|
+
to: "date",
|
|
54
|
+
toWire: (m) => m["date"]?.year,
|
|
55
|
+
fromWire: (h) => h["year"] === undefined || h["year"] === null
|
|
56
|
+
? undefined
|
|
57
|
+
: new PubidDate({
|
|
58
|
+
year: String(h["year"]),
|
|
59
|
+
month: h["month"],
|
|
60
|
+
day: h["day"],
|
|
61
|
+
}),
|
|
62
|
+
}, { wire: "month", to: "date", toWire: (m) => m["date"]?.month, fromWire: () => undefined }, { wire: "day", to: "date", toWire: (m) => m["date"]?.day, fromWire: () => undefined });
|
|
63
|
+
static urnGenerator = CalconnectPfsUrnGenerator;
|
|
64
|
+
/** The definition's canonical face: CC["/" series]" " number
|
|
65
|
+
* [":" year["-" month"-" day]] — every optional renders only what
|
|
66
|
+
* the input carried. */
|
|
67
|
+
render() {
|
|
68
|
+
const prefix = this.series === undefined ? "CC " : `CC/${this.series} `;
|
|
69
|
+
const date = this.date?.render();
|
|
70
|
+
return `${prefix}${this.number}${date === undefined || date === "" ? "" : `:${date}`}`;
|
|
71
|
+
}
|
|
72
|
+
/** The alias's own from_hash: the scheme tag routes HERE, while the
|
|
73
|
+
* global resolution keeps answering the coded class (coexistence, not
|
|
74
|
+
* cutover). */
|
|
75
|
+
static fromHash(hash) {
|
|
76
|
+
return new CalconnectPfsIdentifier(this.applyMappings(this.inflateScalarComponents(hash)));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The artifact's declared bindings (series/number/year/month/day, flat
|
|
81
|
+
* string captures) carry the parsed faces; the year/month/day trio
|
|
82
|
+
* folds into the shared PubidDate — the definition's calendar binding,
|
|
83
|
+
* the same fold the coded flavor's builder performs — so the bound map
|
|
84
|
+
* lands on the model fields directly.
|
|
85
|
+
*/
|
|
86
|
+
let cachedRuntime;
|
|
87
|
+
export function calconnectPfsGrammarImplementation() {
|
|
88
|
+
return {
|
|
89
|
+
parse(input) {
|
|
90
|
+
cachedRuntime ??= PubidRuntime.load("calconnect_pfs");
|
|
91
|
+
const bound = cachedRuntime.parseAndBind(input);
|
|
92
|
+
if (bound === null || typeof bound !== "object") {
|
|
93
|
+
throw new ParseFailed("calconnect_pfs: the artifact rejected the input", 0);
|
|
94
|
+
}
|
|
95
|
+
const flat = bound;
|
|
96
|
+
const attrs = {};
|
|
97
|
+
if (flat["series"] !== undefined && flat["series"] !== null) {
|
|
98
|
+
attrs["series"] = String(flat["series"]);
|
|
99
|
+
}
|
|
100
|
+
if (flat["number"] === undefined || flat["number"] === null) {
|
|
101
|
+
throw new ParseFailed("CalConnect: no number", 0);
|
|
102
|
+
}
|
|
103
|
+
attrs["number"] = String(flat["number"]);
|
|
104
|
+
if (flat["year"] !== undefined && flat["year"] !== null) {
|
|
105
|
+
attrs["date"] = new PubidDate({
|
|
106
|
+
year: String(flat["year"]),
|
|
107
|
+
month: flat["month"] === undefined || flat["month"] === null
|
|
108
|
+
? undefined
|
|
109
|
+
: String(flat["month"]),
|
|
110
|
+
day: flat["day"] === undefined || flat["day"] === null
|
|
111
|
+
? undefined
|
|
112
|
+
: String(flat["day"]),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return new CalconnectPfsIdentifier(attrs);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { FlavorImplementation } from "../../conformance/implementation.js";
|
|
2
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
3
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
4
|
+
/**
|
|
5
|
+
* The PFS-compiled etsi flavor (pubid/pubid#706 phase 3) — one
|
|
6
|
+
* definition file, both engines: the grammar runtime is the SAME baked
|
|
7
|
+
* artifact the Ruby flavor runs (pubid-grammar artifacts/etsi_pfs.json,
|
|
8
|
+
* compiled from definitions/etsi.pfs by the compiler v2), loaded through
|
|
9
|
+
* the artifact runtime, so grammar changes land once and this side
|
|
10
|
+
* cannot drift. Nothing is hand-rolled: the model is declared attributes
|
|
11
|
+
* on the unified model (serialization derives from BaseIdentifier), the
|
|
12
|
+
* ed.N face folds onto version + is_edition exactly as the definition's
|
|
13
|
+
* fold declares, and the render body is the definition's canonical
|
|
14
|
+
* template with presence-guarded optionals and the /A//C run. The
|
|
15
|
+
* supplement wrappers are the compiled classes the definition's
|
|
16
|
+
* supplements declaration synthesizes ({number, base}, outermost last).
|
|
17
|
+
* The parity gate (test/etsi-pfs-parity.test.ts) pins byte-identity with
|
|
18
|
+
* the coded {@linkcode import("../etsi").EtsiIdentifier} over the shared
|
|
19
|
+
* conformance set (the full 24,718-row inventory).
|
|
20
|
+
*/
|
|
21
|
+
/** The official URN: the definition's urn.official segments —
|
|
22
|
+
* urn:etsi[:<type>][:<composed code>][:<version face>][:<date>]; a
|
|
23
|
+
* supplement wrapper reads through to the wrapped standard, an absent
|
|
24
|
+
* field leaves no segment, the fold's target switches to the edition
|
|
25
|
+
* affix while the flag holds, and the date group joins year-month. */
|
|
26
|
+
declare class EtsiPfsUrnGenerator extends BaseUrnGenerator<EtsiPfsIdentifier> {
|
|
27
|
+
generate(): string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The compiled flavor's identifier base: the shared render machinery and
|
|
31
|
+
* the FLAVOR-LOCAL type dispatch. The concrete classes carry the scheme's
|
|
32
|
+
* canonical wire tags (pubid:etsi:…), which deliberately stay OUT of the
|
|
33
|
+
* global type map — one scheme, one `_type`, one global resolution (the
|
|
34
|
+
* coded class); {@linkcode fromHash} routes the tags back here
|
|
35
|
+
* flavor-locally, mirroring Ruby's Pubid::EtsiPfs::Identifier.from_hash
|
|
36
|
+
* (a bare polymorphic cast would rebuild the plain Base and lose the
|
|
37
|
+
* concrete subclass — the tags must NOT dispatch through the registry).
|
|
38
|
+
*/
|
|
39
|
+
export declare abstract class EtsiPfsIdentifier extends BaseIdentifier {
|
|
40
|
+
/** The wire tags the compiled classes answer, resolved flavor-locally. */
|
|
41
|
+
static localTypeMap: Map<string, new (attrs?: Record<string, unknown>) => EtsiPfsIdentifier>;
|
|
42
|
+
readonly type: string | undefined;
|
|
43
|
+
readonly number: string | undefined;
|
|
44
|
+
readonly minor: string | undefined;
|
|
45
|
+
readonly parts: string[] | undefined;
|
|
46
|
+
readonly version: string | undefined;
|
|
47
|
+
readonly year: string | undefined;
|
|
48
|
+
readonly month: string | undefined;
|
|
49
|
+
readonly is_edition: boolean | undefined;
|
|
50
|
+
readonly base: EtsiPfsIdentifier | undefined;
|
|
51
|
+
/** A wrapper reads through to the wrapped standard (the compiled
|
|
52
|
+
* generator's subject). */
|
|
53
|
+
standardSubject(): EtsiPfsIdentifier;
|
|
54
|
+
/** The printed supplement run ("/A1/C1", the base outward), empty on a
|
|
55
|
+
* standard row. */
|
|
56
|
+
supplementRun(): string;
|
|
57
|
+
/** The kind face ("A"/"C") — wrappers only; never called on a standard. */
|
|
58
|
+
protected supplementFace(): string;
|
|
59
|
+
/** The definition's canonical face: ETSI <type> <number>[ <minor>][-<parts>]
|
|
60
|
+
* [<supplement run>] [<V<version>|ed.<version>] [(<year>-<month>)] — every
|
|
61
|
+
* optional renders only what the input carried. */
|
|
62
|
+
render(): string;
|
|
63
|
+
/** The alias's own from_hash: the scheme tags route HERE, while the
|
|
64
|
+
* global resolution keeps answering the coded class (coexistence, not
|
|
65
|
+
* cutover). */
|
|
66
|
+
static fromHash(hash: Record<string, unknown>): BaseIdentifier;
|
|
67
|
+
}
|
|
68
|
+
export declare class EtsiPfsStandardIdentifier extends EtsiPfsIdentifier {
|
|
69
|
+
/**
|
|
70
|
+
* The SCHEME-canonical wire tag (declared in the definition): to_hash
|
|
71
|
+
* is byte-identical with the coded flavor. Deliberately NOT registered
|
|
72
|
+
* in the global type map.
|
|
73
|
+
*/
|
|
74
|
+
static polymorphicName: string;
|
|
75
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
76
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
77
|
+
static urnGenerator: typeof EtsiPfsUrnGenerator;
|
|
78
|
+
}
|
|
79
|
+
/** The supplement wrapper base: the wrapper owns its ordinal and the base
|
|
80
|
+
* identifier; the hash carries only _type, number, base (the base collapses
|
|
81
|
+
* to the leaf standard shape) and every rendered face reads through. */
|
|
82
|
+
declare abstract class EtsiPfsSupplementIdentifier extends EtsiPfsIdentifier {
|
|
83
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
84
|
+
static mappings: import("../../model/attribute.js").FieldMapping[];
|
|
85
|
+
static urnGenerator: typeof EtsiPfsUrnGenerator;
|
|
86
|
+
}
|
|
87
|
+
export declare class EtsiPfsAmendmentIdentifier extends EtsiPfsSupplementIdentifier {
|
|
88
|
+
/** The kind face "A" is the run's dispatch token and the notation face. */
|
|
89
|
+
static polymorphicName: string;
|
|
90
|
+
static FACE: string;
|
|
91
|
+
protected supplementFace(): string;
|
|
92
|
+
}
|
|
93
|
+
export declare class EtsiPfsCorrigendumIdentifier extends EtsiPfsSupplementIdentifier {
|
|
94
|
+
/** The kind face "C" is the run's dispatch token and the notation face. */
|
|
95
|
+
static polymorphicName: string;
|
|
96
|
+
static FACE: string;
|
|
97
|
+
protected supplementFace(): string;
|
|
98
|
+
}
|
|
99
|
+
export declare function etsiPfsGrammarImplementation(): FlavorImplementation;
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { ParseFailed } from "../../grammar/engine.js";
|
|
2
|
+
import { PubidRuntime } from "../../parg/runtime.js";
|
|
3
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
4
|
+
import { extendAttributes, keyValue } from "../../model/attribute.js";
|
|
5
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
6
|
+
/**
|
|
7
|
+
* The PFS-compiled etsi flavor (pubid/pubid#706 phase 3) — one
|
|
8
|
+
* definition file, both engines: the grammar runtime is the SAME baked
|
|
9
|
+
* artifact the Ruby flavor runs (pubid-grammar artifacts/etsi_pfs.json,
|
|
10
|
+
* compiled from definitions/etsi.pfs by the compiler v2), loaded through
|
|
11
|
+
* the artifact runtime, so grammar changes land once and this side
|
|
12
|
+
* cannot drift. Nothing is hand-rolled: the model is declared attributes
|
|
13
|
+
* on the unified model (serialization derives from BaseIdentifier), the
|
|
14
|
+
* ed.N face folds onto version + is_edition exactly as the definition's
|
|
15
|
+
* fold declares, and the render body is the definition's canonical
|
|
16
|
+
* template with presence-guarded optionals and the /A//C run. The
|
|
17
|
+
* supplement wrappers are the compiled classes the definition's
|
|
18
|
+
* supplements declaration synthesizes ({number, base}, outermost last).
|
|
19
|
+
* The parity gate (test/etsi-pfs-parity.test.ts) pins byte-identity with
|
|
20
|
+
* the coded {@linkcode import("../etsi").EtsiIdentifier} over the shared
|
|
21
|
+
* conformance set (the full 24,718-row inventory).
|
|
22
|
+
*/
|
|
23
|
+
/** The official URN: the definition's urn.official segments —
|
|
24
|
+
* urn:etsi[:<type>][:<composed code>][:<version face>][:<date>]; a
|
|
25
|
+
* supplement wrapper reads through to the wrapped standard, an absent
|
|
26
|
+
* field leaves no segment, the fold's target switches to the edition
|
|
27
|
+
* affix while the flag holds, and the date group joins year-month. */
|
|
28
|
+
class EtsiPfsUrnGenerator extends BaseUrnGenerator {
|
|
29
|
+
generate() {
|
|
30
|
+
const subject = this.identifier.standardSubject();
|
|
31
|
+
const parts = ["urn", "etsi"];
|
|
32
|
+
if (subject.type !== undefined)
|
|
33
|
+
parts.push(subject.type.toLowerCase());
|
|
34
|
+
const code = [];
|
|
35
|
+
if (subject.number !== undefined)
|
|
36
|
+
code.push(subject.number);
|
|
37
|
+
if (subject.minor !== undefined)
|
|
38
|
+
code.push(` ${subject.minor}`);
|
|
39
|
+
if (subject.parts !== undefined && subject.parts.length > 0) {
|
|
40
|
+
code.push(...subject.parts.map((item) => `-${item}`));
|
|
41
|
+
}
|
|
42
|
+
const composed = code.join("");
|
|
43
|
+
if (composed !== "")
|
|
44
|
+
parts.push(composed);
|
|
45
|
+
if (subject.is_edition) {
|
|
46
|
+
parts.push(`ed.${(subject.version ?? "").toLowerCase()}`);
|
|
47
|
+
}
|
|
48
|
+
else if (subject.version !== undefined) {
|
|
49
|
+
parts.push(`v${subject.version.toLowerCase()}`);
|
|
50
|
+
}
|
|
51
|
+
const date = [subject.year, subject.month].filter((v) => v !== undefined);
|
|
52
|
+
if (date.length > 0)
|
|
53
|
+
parts.push(date.join("-"));
|
|
54
|
+
return parts.join(":");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The compiled flavor's identifier base: the shared render machinery and
|
|
59
|
+
* the FLAVOR-LOCAL type dispatch. The concrete classes carry the scheme's
|
|
60
|
+
* canonical wire tags (pubid:etsi:…), which deliberately stay OUT of the
|
|
61
|
+
* global type map — one scheme, one `_type`, one global resolution (the
|
|
62
|
+
* coded class); {@linkcode fromHash} routes the tags back here
|
|
63
|
+
* flavor-locally, mirroring Ruby's Pubid::EtsiPfs::Identifier.from_hash
|
|
64
|
+
* (a bare polymorphic cast would rebuild the plain Base and lose the
|
|
65
|
+
* concrete subclass — the tags must NOT dispatch through the registry).
|
|
66
|
+
*/
|
|
67
|
+
export class EtsiPfsIdentifier extends BaseIdentifier {
|
|
68
|
+
/** The wire tags the compiled classes answer, resolved flavor-locally. */
|
|
69
|
+
static localTypeMap = new Map();
|
|
70
|
+
/** A wrapper reads through to the wrapped standard (the compiled
|
|
71
|
+
* generator's subject). */
|
|
72
|
+
standardSubject() {
|
|
73
|
+
let current = this;
|
|
74
|
+
while (current.base !== undefined)
|
|
75
|
+
current = current.base;
|
|
76
|
+
return current;
|
|
77
|
+
}
|
|
78
|
+
/** The printed supplement run ("/A1/C1", the base outward), empty on a
|
|
79
|
+
* standard row. */
|
|
80
|
+
supplementRun() {
|
|
81
|
+
let run = "";
|
|
82
|
+
let current = this;
|
|
83
|
+
while (current.base !== undefined) {
|
|
84
|
+
run = `/${current.supplementFace()}${current.number}${run}`;
|
|
85
|
+
current = current.base;
|
|
86
|
+
}
|
|
87
|
+
return run;
|
|
88
|
+
}
|
|
89
|
+
/** The kind face ("A"/"C") — wrappers only; never called on a standard. */
|
|
90
|
+
supplementFace() {
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
93
|
+
/** The definition's canonical face: ETSI <type> <number>[ <minor>][-<parts>]
|
|
94
|
+
* [<supplement run>] [<V<version>|ed.<version>] [(<year>-<month>)] — every
|
|
95
|
+
* optional renders only what the input carried. */
|
|
96
|
+
render() {
|
|
97
|
+
const root = this.standardSubject();
|
|
98
|
+
let result = `ETSI ${root.type} ${root.number}`;
|
|
99
|
+
if (root.minor !== undefined)
|
|
100
|
+
result += ` ${root.minor}`;
|
|
101
|
+
if (root.parts !== undefined && root.parts.length > 0) {
|
|
102
|
+
result += root.parts.map((item) => `-${item}`).join("");
|
|
103
|
+
}
|
|
104
|
+
result += this.supplementRun();
|
|
105
|
+
if (root.is_edition) {
|
|
106
|
+
result += ` ed.${root.version}`;
|
|
107
|
+
}
|
|
108
|
+
else if (root.version !== undefined) {
|
|
109
|
+
result += ` V${root.version}`;
|
|
110
|
+
}
|
|
111
|
+
if (root.year !== undefined && root.month !== undefined) {
|
|
112
|
+
result += ` (${root.year}-${root.month})`;
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
/** The alias's own from_hash: the scheme tags route HERE, while the
|
|
117
|
+
* global resolution keeps answering the coded class (coexistence, not
|
|
118
|
+
* cutover). */
|
|
119
|
+
static fromHash(hash) {
|
|
120
|
+
const tag = typeof hash["_type"] === "string" ? hash["_type"] : undefined;
|
|
121
|
+
const klass = tag !== undefined ? this.localTypeMap.get(tag) : undefined;
|
|
122
|
+
const target = (klass ?? this);
|
|
123
|
+
return new target(target.applyMappings(target.inflateScalarComponents(hash)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export class EtsiPfsStandardIdentifier extends EtsiPfsIdentifier {
|
|
127
|
+
/**
|
|
128
|
+
* The SCHEME-canonical wire tag (declared in the definition): to_hash
|
|
129
|
+
* is byte-identical with the coded flavor. Deliberately NOT registered
|
|
130
|
+
* in the global type map.
|
|
131
|
+
*/
|
|
132
|
+
static polymorphicName = "pubid:etsi:etsi-standard";
|
|
133
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
134
|
+
type: { type: "string" },
|
|
135
|
+
number: { type: "string" },
|
|
136
|
+
minor: { type: "string" },
|
|
137
|
+
parts: { type: "string", collection: true, initializeEmpty: true },
|
|
138
|
+
version: { type: "string" },
|
|
139
|
+
year: { type: "string" },
|
|
140
|
+
month: { type: "string" },
|
|
141
|
+
is_edition: { type: "boolean", default: false },
|
|
142
|
+
});
|
|
143
|
+
static mappings = keyValue({ wire: "type", to: "type" }, { wire: "number", to: "number" }, { wire: "minor", to: "minor" }, { wire: "parts", to: "parts" }, { wire: "version", to: "version" }, { wire: "year", to: "year" }, { wire: "month", to: "month" }, { wire: "is_edition", to: "is_edition" });
|
|
144
|
+
static urnGenerator = EtsiPfsUrnGenerator;
|
|
145
|
+
}
|
|
146
|
+
/** The supplement wrapper base: the wrapper owns its ordinal and the base
|
|
147
|
+
* identifier; the hash carries only _type, number, base (the base collapses
|
|
148
|
+
* to the leaf standard shape) and every rendered face reads through. */
|
|
149
|
+
class EtsiPfsSupplementIdentifier extends EtsiPfsIdentifier {
|
|
150
|
+
static attributes = extendAttributes(BaseIdentifier, {
|
|
151
|
+
base: { type: EtsiPfsIdentifier },
|
|
152
|
+
number: { type: "integer" },
|
|
153
|
+
});
|
|
154
|
+
static mappings = keyValue({ wire: "number", to: "number" }, { wire: "base", to: "base" });
|
|
155
|
+
static urnGenerator = EtsiPfsUrnGenerator;
|
|
156
|
+
}
|
|
157
|
+
export class EtsiPfsAmendmentIdentifier extends EtsiPfsSupplementIdentifier {
|
|
158
|
+
/** The kind face "A" is the run's dispatch token and the notation face. */
|
|
159
|
+
static polymorphicName = "pubid:etsi:amendment";
|
|
160
|
+
static FACE = "A";
|
|
161
|
+
supplementFace() {
|
|
162
|
+
return EtsiPfsAmendmentIdentifier.FACE;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
EtsiPfsIdentifier.localTypeMap.set(EtsiPfsAmendmentIdentifier.polymorphicName, EtsiPfsAmendmentIdentifier);
|
|
166
|
+
export class EtsiPfsCorrigendumIdentifier extends EtsiPfsSupplementIdentifier {
|
|
167
|
+
/** The kind face "C" is the run's dispatch token and the notation face. */
|
|
168
|
+
static polymorphicName = "pubid:etsi:corrigendum";
|
|
169
|
+
static FACE = "C";
|
|
170
|
+
supplementFace() {
|
|
171
|
+
return EtsiPfsCorrigendumIdentifier.FACE;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
EtsiPfsIdentifier.localTypeMap.set(EtsiPfsCorrigendumIdentifier.polymorphicName, EtsiPfsCorrigendumIdentifier);
|
|
175
|
+
EtsiPfsIdentifier.localTypeMap.set(EtsiPfsStandardIdentifier.polymorphicName, EtsiPfsStandardIdentifier);
|
|
176
|
+
/**
|
|
177
|
+
* The artifact's declared bindings carry the parsed faces: the flat
|
|
178
|
+
* columns land on the model fields, the ed.N capture folds onto version +
|
|
179
|
+
* is_edition (the definition's fold), the parts list binds its item per
|
|
180
|
+
* repetition, and the supplement run folds into the synthesized wrapper
|
|
181
|
+
* chain ({number, base}, outermost last) — the same fold the Ruby builder
|
|
182
|
+
* performs.
|
|
183
|
+
*/
|
|
184
|
+
let cachedRuntime;
|
|
185
|
+
/** A raw capture leaf ({value, line, …}) yields its value; a bound scalar
|
|
186
|
+
* passes through (the run's internal captures bind only through the item
|
|
187
|
+
* row, so unbound ones arrive as raw leaves). */
|
|
188
|
+
function unwrap(capture) {
|
|
189
|
+
if (typeof capture === "object" && capture !== null && "value" in capture) {
|
|
190
|
+
return capture["value"];
|
|
191
|
+
}
|
|
192
|
+
return capture;
|
|
193
|
+
}
|
|
194
|
+
export function etsiPfsGrammarImplementation() {
|
|
195
|
+
return {
|
|
196
|
+
parse(input) {
|
|
197
|
+
cachedRuntime ??= PubidRuntime.load("etsi_pfs");
|
|
198
|
+
const bound = cachedRuntime.parseAndBind(input);
|
|
199
|
+
if (bound === null || typeof bound !== "object") {
|
|
200
|
+
throw new ParseFailed("etsi_pfs: the artifact rejected the input", 0);
|
|
201
|
+
}
|
|
202
|
+
const flat = bound;
|
|
203
|
+
const attrs = {};
|
|
204
|
+
if (flat["type"] === undefined || flat["type"] === null) {
|
|
205
|
+
throw new ParseFailed("ETSI: no type", 0);
|
|
206
|
+
}
|
|
207
|
+
attrs["type"] = String(flat["type"]);
|
|
208
|
+
if (flat["number"] === undefined || flat["number"] === null) {
|
|
209
|
+
throw new ParseFailed("ETSI: no number", 0);
|
|
210
|
+
}
|
|
211
|
+
attrs["number"] = String(flat["number"]);
|
|
212
|
+
if (flat["minor"] !== undefined && flat["minor"] !== null) {
|
|
213
|
+
attrs["minor"] = String(flat["minor"]);
|
|
214
|
+
}
|
|
215
|
+
if (flat["parts"] !== undefined && flat["parts"] !== null) {
|
|
216
|
+
const rows = Array.isArray(flat["parts"]) ? flat["parts"] : [flat["parts"]];
|
|
217
|
+
const items = rows
|
|
218
|
+
.map((row) => unwrap(row?.["part"]))
|
|
219
|
+
.filter((item) => item !== undefined && item !== null);
|
|
220
|
+
if (items.length > 0)
|
|
221
|
+
attrs["parts"] = items.map((item) => String(item));
|
|
222
|
+
}
|
|
223
|
+
// The fold: version || edition, with the flag holding for ed.N —
|
|
224
|
+
// the V/ed faces are mutually exclusive by grammar.
|
|
225
|
+
if (flat["version"] !== undefined && flat["version"] !== null) {
|
|
226
|
+
attrs["version"] = String(flat["version"]);
|
|
227
|
+
}
|
|
228
|
+
else if (flat["edition"] !== undefined && flat["edition"] !== null) {
|
|
229
|
+
attrs["version"] = String(flat["edition"]);
|
|
230
|
+
attrs["is_edition"] = true;
|
|
231
|
+
}
|
|
232
|
+
if (flat["year"] !== undefined && flat["year"] !== null) {
|
|
233
|
+
attrs["year"] = String(flat["year"]);
|
|
234
|
+
}
|
|
235
|
+
if (flat["month"] !== undefined && flat["month"] !== null) {
|
|
236
|
+
attrs["month"] = String(flat["month"]);
|
|
237
|
+
}
|
|
238
|
+
let identifier = new EtsiPfsStandardIdentifier(attrs);
|
|
239
|
+
if (flat["supplements"] !== undefined && flat["supplements"] !== null) {
|
|
240
|
+
const rows = Array.isArray(flat["supplements"])
|
|
241
|
+
? flat["supplements"]
|
|
242
|
+
: [flat["supplements"]];
|
|
243
|
+
for (const row of rows) {
|
|
244
|
+
const item = row?.["supplement"];
|
|
245
|
+
if (item === undefined || item === null)
|
|
246
|
+
continue;
|
|
247
|
+
const kind = String(unwrap(item["supplement_kind"]) ?? "");
|
|
248
|
+
const Wrapper = kind === EtsiPfsAmendmentIdentifier.FACE
|
|
249
|
+
? EtsiPfsAmendmentIdentifier
|
|
250
|
+
: kind === EtsiPfsCorrigendumIdentifier.FACE
|
|
251
|
+
? EtsiPfsCorrigendumIdentifier
|
|
252
|
+
: undefined;
|
|
253
|
+
if (Wrapper === undefined) {
|
|
254
|
+
throw new ParseFailed(`ETSI: unknown supplement kind ${kind}`, 0);
|
|
255
|
+
}
|
|
256
|
+
identifier = new Wrapper({
|
|
257
|
+
base: identifier,
|
|
258
|
+
number: Number(unwrap(item["supplement_number"])),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return identifier;
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
package/dist/flavors/index.js
CHANGED
|
@@ -17,9 +17,11 @@ import { ansiGrammarImplementation } from "./ansi/index.js";
|
|
|
17
17
|
import { oasisGrammarImplementation } from "./oasis/index.js";
|
|
18
18
|
import { ihoGrammarImplementation } from "./iho/index.js";
|
|
19
19
|
import { calconnectGrammarImplementation } from "./calconnect/index.js";
|
|
20
|
+
import { calconnectPfsGrammarImplementation } from "./calconnect_pfs/index.js";
|
|
20
21
|
import { gbGrammarImplementation } from "./gb/index.js";
|
|
21
22
|
import { jcgmGrammarImplementation } from "./jcgm/index.js";
|
|
22
23
|
import { etsiGrammarImplementation } from "./etsi/index.js";
|
|
24
|
+
import { etsiPfsGrammarImplementation } from "./etsi_pfs/index.js";
|
|
23
25
|
import { jisGrammarImplementation } from "./jis/index.js";
|
|
24
26
|
import { iecGrammarImplementation } from "./iec/index.js";
|
|
25
27
|
import { cieGrammarImplementation } from "./cie/index.js";
|
|
@@ -112,12 +114,16 @@ function grammarImplementationSwitch(flavor) {
|
|
|
112
114
|
return ihoGrammarImplementation();
|
|
113
115
|
case "calconnect":
|
|
114
116
|
return calconnectGrammarImplementation();
|
|
117
|
+
case "calconnect_pfs":
|
|
118
|
+
return calconnectPfsGrammarImplementation();
|
|
115
119
|
case "gb":
|
|
116
120
|
return gbGrammarImplementation();
|
|
117
121
|
case "jcgm":
|
|
118
122
|
return jcgmGrammarImplementation();
|
|
119
123
|
case "etsi":
|
|
120
124
|
return etsiGrammarImplementation();
|
|
125
|
+
case "etsi_pfs":
|
|
126
|
+
return etsiPfsGrammarImplementation();
|
|
121
127
|
case "jis":
|
|
122
128
|
return jisGrammarImplementation();
|
|
123
129
|
case "iec":
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pubid-scheme URN schema of CALCONNECT_PFS — the transcription
|
|
3
|
+
* of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
|
|
4
|
+
* #670; design in docs/URN-SCHEMES.adoc). GENERATED by
|
|
5
|
+
* scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
|
|
6
|
+
* schema and regenerate, never this table by hand.
|
|
7
|
+
*/
|
|
8
|
+
export declare const calconnectPfsSchema: import("../schema.js").FlavorSchema;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pubid-scheme URN schema of CALCONNECT_PFS — the transcription
|
|
3
|
+
* of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
|
|
4
|
+
* #670; design in docs/URN-SCHEMES.adoc). GENERATED by
|
|
5
|
+
* scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
|
|
6
|
+
* schema and regenerate, never this table by hand.
|
|
7
|
+
*/
|
|
8
|
+
import { define } from "../index.js";
|
|
9
|
+
export const calconnectPfsSchema = define("calconnect_pfs", (s) => {
|
|
10
|
+
s.atom("series", "series");
|
|
11
|
+
s.atom("year", "year");
|
|
12
|
+
s.atom("month", "month");
|
|
13
|
+
s.atom("day", "day");
|
|
14
|
+
s.type("pubid:calconnect:identifier", "id", { core: [] });
|
|
15
|
+
s.type("pubid:calconnect:standard", "std");
|
|
16
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pubid-scheme URN schema of ETSI_PFS — the transcription
|
|
3
|
+
* of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
|
|
4
|
+
* #670; design in docs/URN-SCHEMES.adoc). GENERATED by
|
|
5
|
+
* scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
|
|
6
|
+
* schema and regenerate, never this table by hand.
|
|
7
|
+
*/
|
|
8
|
+
export declare const etsiPfsSchema: import("../schema.js").FlavorSchema;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pubid-scheme URN schema of ETSI_PFS — the transcription
|
|
3
|
+
* of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
|
|
4
|
+
* #670; design in docs/URN-SCHEMES.adoc). GENERATED by
|
|
5
|
+
* scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
|
|
6
|
+
* schema and regenerate, never this table by hand.
|
|
7
|
+
*/
|
|
8
|
+
import { define } from "../index.js";
|
|
9
|
+
export const etsiPfsSchema = define("etsi_pfs", (s) => {
|
|
10
|
+
s.atom("type", "type");
|
|
11
|
+
s.atom("parts", "part");
|
|
12
|
+
s.atom("minor", "minor");
|
|
13
|
+
s.atom("year", "year");
|
|
14
|
+
s.atom("month", "month");
|
|
15
|
+
s.atom("version", "v");
|
|
16
|
+
s.type("pubid:etsi:etsi-standard", "es", { core: [] });
|
|
17
|
+
s.type("pubid:etsi:amendment", "amd", { core: [["number", "int"]] });
|
|
18
|
+
s.type("pubid:etsi:corrigendum", "cor", { core: [["number", "int"]] });
|
|
19
|
+
s.type("pubid:etsi:identifier", "id", { core: [] });
|
|
20
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The registry of all
|
|
2
|
+
* The registry of all 47 flavor pubid-urn schema tables — the TS mirror
|
|
3
3
|
* of lib/pubid.rb's autoloaded Pubid::<Flavor>::PubidUrnSchema chain.
|
|
4
4
|
* Declared tables only: importing this module has no side effects; the
|
|
5
5
|
* pubid-urn module builds its flavor lookup lazily from this array.
|