@treeviz/gedcom-parser 1.0.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.
- package/LICENSE +21 -0
- package/README.md +954 -0
- package/dist/classes/common.d.ts +87 -0
- package/dist/classes/common.d.ts.map +1 -0
- package/dist/classes/common.js +481 -0
- package/dist/classes/date.d.ts +26 -0
- package/dist/classes/date.d.ts.map +1 -0
- package/dist/classes/date.js +176 -0
- package/dist/classes/fam.d.ts +19 -0
- package/dist/classes/fam.d.ts.map +1 -0
- package/dist/classes/fam.js +38 -0
- package/dist/classes/fams.d.ts +16 -0
- package/dist/classes/fams.d.ts.map +1 -0
- package/dist/classes/fams.js +41 -0
- package/dist/classes/gedcom.d.ts +89 -0
- package/dist/classes/gedcom.d.ts.map +1 -0
- package/dist/classes/gedcom.js +421 -0
- package/dist/classes/index.d.ts +19 -0
- package/dist/classes/index.d.ts.map +1 -0
- package/dist/classes/index.js +19 -0
- package/dist/classes/indi.d.ts +298 -0
- package/dist/classes/indi.d.ts.map +1 -0
- package/dist/classes/indi.js +2049 -0
- package/dist/classes/indis.d.ts +54 -0
- package/dist/classes/indis.d.ts.map +1 -0
- package/dist/classes/indis.js +439 -0
- package/dist/classes/list.d.ts +55 -0
- package/dist/classes/list.d.ts.map +1 -0
- package/dist/classes/list.js +440 -0
- package/dist/classes/name.d.ts +20 -0
- package/dist/classes/name.d.ts.map +1 -0
- package/dist/classes/name.js +48 -0
- package/dist/classes/note.d.ts +12 -0
- package/dist/classes/note.d.ts.map +1 -0
- package/dist/classes/note.js +46 -0
- package/dist/classes/obje.d.ts +12 -0
- package/dist/classes/obje.d.ts.map +1 -0
- package/dist/classes/obje.js +81 -0
- package/dist/classes/objes.d.ts +8 -0
- package/dist/classes/objes.d.ts.map +1 -0
- package/dist/classes/objes.js +13 -0
- package/dist/classes/repo.d.ts +11 -0
- package/dist/classes/repo.d.ts.map +1 -0
- package/dist/classes/repo.js +6 -0
- package/dist/classes/repos.d.ts +8 -0
- package/dist/classes/repos.d.ts.map +1 -0
- package/dist/classes/repos.js +13 -0
- package/dist/classes/sour.d.ts +11 -0
- package/dist/classes/sour.d.ts.map +1 -0
- package/dist/classes/sour.js +6 -0
- package/dist/classes/sours.d.ts +8 -0
- package/dist/classes/sours.d.ts.map +1 -0
- package/dist/classes/sours.js +13 -0
- package/dist/classes/subm.d.ts +10 -0
- package/dist/classes/subm.d.ts.map +1 -0
- package/dist/classes/subm.js +6 -0
- package/dist/classes/subms.d.ts +8 -0
- package/dist/classes/subms.d.ts.map +1 -0
- package/dist/classes/subms.js +13 -0
- package/dist/constants/constants.d.ts +14 -0
- package/dist/constants/constants.d.ts.map +1 -0
- package/dist/constants/constants.js +13 -0
- package/dist/constants/filters.d.ts +17 -0
- package/dist/constants/filters.d.ts.map +1 -0
- package/dist/constants/filters.js +44 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +4 -0
- package/dist/constants/orders.d.ts +17 -0
- package/dist/constants/orders.d.ts.map +1 -0
- package/dist/constants/orders.js +240 -0
- package/dist/factories/cache-factory.d.ts +30 -0
- package/dist/factories/cache-factory.d.ts.map +1 -0
- package/dist/factories/cache-factory.js +43 -0
- package/dist/factories/date-locale-factory.d.ts +30 -0
- package/dist/factories/date-locale-factory.d.ts.map +1 -0
- package/dist/factories/date-locale-factory.js +34 -0
- package/dist/factories/i18n-factory.d.ts +40 -0
- package/dist/factories/i18n-factory.d.ts.map +1 -0
- package/dist/factories/i18n-factory.js +44 -0
- package/dist/factories/index.d.ts +5 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +5 -0
- package/dist/factories/kinship-factory.d.ts +38 -0
- package/dist/factories/kinship-factory.d.ts.map +1 -0
- package/dist/factories/kinship-factory.js +35 -0
- package/dist/factories/place-parser-provider.d.ts +32 -0
- package/dist/factories/place-parser-provider.d.ts.map +1 -0
- package/dist/factories/place-parser-provider.js +35 -0
- package/dist/factories/place-translator-provider.d.ts +32 -0
- package/dist/factories/place-translator-provider.d.ts.map +1 -0
- package/dist/factories/place-translator-provider.js +35 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/interfaces/common.d.ts +43 -0
- package/dist/interfaces/common.d.ts.map +1 -0
- package/dist/interfaces/common.js +1 -0
- package/dist/interfaces/fam.d.ts +11 -0
- package/dist/interfaces/fam.d.ts.map +1 -0
- package/dist/interfaces/fam.js +1 -0
- package/dist/interfaces/fams.d.ts +9 -0
- package/dist/interfaces/fams.d.ts.map +1 -0
- package/dist/interfaces/fams.js +1 -0
- package/dist/interfaces/gedcom.d.ts +30 -0
- package/dist/interfaces/gedcom.d.ts.map +1 -0
- package/dist/interfaces/gedcom.js +1 -0
- package/dist/interfaces/index.d.ts +12 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/indi.d.ts +109 -0
- package/dist/interfaces/indi.d.ts.map +1 -0
- package/dist/interfaces/indi.js +1 -0
- package/dist/interfaces/indis.d.ts +31 -0
- package/dist/interfaces/indis.d.ts.map +1 -0
- package/dist/interfaces/indis.js +1 -0
- package/dist/interfaces/list.d.ts +52 -0
- package/dist/interfaces/list.d.ts.map +1 -0
- package/dist/interfaces/list.js +1 -0
- package/dist/interfaces/obje.d.ts +7 -0
- package/dist/interfaces/obje.d.ts.map +1 -0
- package/dist/interfaces/obje.js +1 -0
- package/dist/interfaces/repo.d.ts +7 -0
- package/dist/interfaces/repo.d.ts.map +1 -0
- package/dist/interfaces/repo.js +1 -0
- package/dist/interfaces/sour.d.ts +7 -0
- package/dist/interfaces/sour.d.ts.map +1 -0
- package/dist/interfaces/sour.js +1 -0
- package/dist/interfaces/subm.d.ts +6 -0
- package/dist/interfaces/subm.d.ts.map +1 -0
- package/dist/interfaces/subm.js +1 -0
- package/dist/kinship-translator/index.d.ts +11 -0
- package/dist/kinship-translator/index.d.ts.map +1 -0
- package/dist/kinship-translator/index.js +10 -0
- package/dist/kinship-translator/kinship-translator.basic.d.ts +30 -0
- package/dist/kinship-translator/kinship-translator.basic.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.basic.js +74 -0
- package/dist/kinship-translator/kinship-translator.d.ts +26 -0
- package/dist/kinship-translator/kinship-translator.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.de.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.de.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.de.js +180 -0
- package/dist/kinship-translator/kinship-translator.en.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.en.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.en.js +182 -0
- package/dist/kinship-translator/kinship-translator.es.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.es.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.es.js +181 -0
- package/dist/kinship-translator/kinship-translator.fr.d.ts +18 -0
- package/dist/kinship-translator/kinship-translator.fr.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.fr.js +181 -0
- package/dist/kinship-translator/kinship-translator.hu.d.ts +19 -0
- package/dist/kinship-translator/kinship-translator.hu.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.hu.js +226 -0
- package/dist/kinship-translator/kinship-translator.interface.d.ts +19 -0
- package/dist/kinship-translator/kinship-translator.interface.d.ts.map +1 -0
- package/dist/kinship-translator/kinship-translator.interface.js +1 -0
- package/dist/kinship-translator/kinship-translator.js +103 -0
- package/dist/kinship-translator/patterns.de.d.ts +2 -0
- package/dist/kinship-translator/patterns.de.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.de.js +14 -0
- package/dist/kinship-translator/patterns.en.d.ts +2 -0
- package/dist/kinship-translator/patterns.en.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.en.js +14 -0
- package/dist/kinship-translator/patterns.es.d.ts +2 -0
- package/dist/kinship-translator/patterns.es.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.es.js +14 -0
- package/dist/kinship-translator/patterns.fr.d.ts +2 -0
- package/dist/kinship-translator/patterns.fr.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.fr.js +14 -0
- package/dist/kinship-translator/patterns.hu.d.ts +6 -0
- package/dist/kinship-translator/patterns.hu.d.ts.map +1 -0
- package/dist/kinship-translator/patterns.hu.js +97 -0
- package/dist/kinship-translator/translators.d.ts +6 -0
- package/dist/kinship-translator/translators.d.ts.map +1 -0
- package/dist/kinship-translator/translators.js +5 -0
- package/dist/kinship-translator/types.d.ts +9 -0
- package/dist/kinship-translator/types.d.ts.map +1 -0
- package/dist/kinship-translator/types.js +1 -0
- package/dist/structures/address.d.ts +14 -0
- package/dist/structures/address.d.ts.map +1 -0
- package/dist/structures/address.js +1 -0
- package/dist/structures/association.d.ts +13 -0
- package/dist/structures/association.d.ts.map +1 -0
- package/dist/structures/association.js +1 -0
- package/dist/structures/change-date.d.ts +8 -0
- package/dist/structures/change-date.d.ts.map +1 -0
- package/dist/structures/change-date.js +1 -0
- package/dist/structures/creation-date.d.ts +7 -0
- package/dist/structures/creation-date.d.ts.map +1 -0
- package/dist/structures/creation-date.js +1 -0
- package/dist/structures/date.d.ts +9 -0
- package/dist/structures/date.d.ts.map +1 -0
- package/dist/structures/date.js +1 -0
- package/dist/structures/event-detail-structure.d.ts +25 -0
- package/dist/structures/event-detail-structure.d.ts.map +1 -0
- package/dist/structures/event-detail-structure.js +1 -0
- package/dist/structures/family.d.ts +34 -0
- package/dist/structures/family.d.ts.map +1 -0
- package/dist/structures/family.js +1 -0
- package/dist/structures/gedcom.d.ts +60 -0
- package/dist/structures/gedcom.d.ts.map +1 -0
- package/dist/structures/gedcom.js +1 -0
- package/dist/structures/index.d.ts +25 -0
- package/dist/structures/index.d.ts.map +1 -0
- package/dist/structures/index.js +1 -0
- package/dist/structures/individual-event-detail-structure.d.ts +9 -0
- package/dist/structures/individual-event-detail-structure.d.ts.map +1 -0
- package/dist/structures/individual-event-detail-structure.js +1 -0
- package/dist/structures/individual-event-structure.d.ts +83 -0
- package/dist/structures/individual-event-structure.d.ts.map +1 -0
- package/dist/structures/individual-event-structure.js +1 -0
- package/dist/structures/individual.d.ts +40 -0
- package/dist/structures/individual.d.ts.map +1 -0
- package/dist/structures/individual.js +1 -0
- package/dist/structures/lds-ordinance-detail.d.ts +17 -0
- package/dist/structures/lds-ordinance-detail.d.ts.map +1 -0
- package/dist/structures/lds-ordinance-detail.js +1 -0
- package/dist/structures/lds-spouse-sealing.d.ts +7 -0
- package/dist/structures/lds-spouse-sealing.d.ts.map +1 -0
- package/dist/structures/lds-spouse-sealing.js +1 -0
- package/dist/structures/marriage-date.d.ts +11 -0
- package/dist/structures/marriage-date.d.ts.map +1 -0
- package/dist/structures/marriage-date.js +1 -0
- package/dist/structures/multimedia-link.d.ts +16 -0
- package/dist/structures/multimedia-link.d.ts.map +1 -0
- package/dist/structures/multimedia-link.js +1 -0
- package/dist/structures/non-event.d.ts +12 -0
- package/dist/structures/non-event.d.ts.map +1 -0
- package/dist/structures/non-event.js +1 -0
- package/dist/structures/note.d.ts +16 -0
- package/dist/structures/note.d.ts.map +1 -0
- package/dist/structures/note.js +1 -0
- package/dist/structures/personal-name-pieces.d.ts +11 -0
- package/dist/structures/personal-name-pieces.d.ts.map +1 -0
- package/dist/structures/personal-name-pieces.js +1 -0
- package/dist/structures/personal-name.d.ts +16 -0
- package/dist/structures/personal-name.d.ts.map +1 -0
- package/dist/structures/personal-name.js +1 -0
- package/dist/structures/place.d.ts +20 -0
- package/dist/structures/place.d.ts.map +1 -0
- package/dist/structures/place.js +1 -0
- package/dist/structures/repository.d.ts +6 -0
- package/dist/structures/repository.d.ts.map +1 -0
- package/dist/structures/repository.js +1 -0
- package/dist/structures/source-citation.d.ts +27 -0
- package/dist/structures/source-citation.d.ts.map +1 -0
- package/dist/structures/source-citation.js +1 -0
- package/dist/structures/source-repository-citation.d.ts +13 -0
- package/dist/structures/source-repository-citation.d.ts.map +1 -0
- package/dist/structures/source-repository-citation.js +1 -0
- package/dist/structures/source.d.ts +28 -0
- package/dist/structures/source.d.ts.map +1 -0
- package/dist/structures/source.js +1 -0
- package/dist/types/ancestry-media.d.ts +65 -0
- package/dist/types/ancestry-media.d.ts.map +1 -0
- package/dist/types/ancestry-media.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/settings.d.ts +12 -0
- package/dist/types/settings.d.ts.map +1 -0
- package/dist/types/settings.js +1 -0
- package/dist/types/types.d.ts +220 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +26 -0
- package/dist/utils/cache.d.ts +22 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +57 -0
- package/dist/utils/common-creator.d.ts +13 -0
- package/dist/utils/common-creator.d.ts.map +1 -0
- package/dist/utils/common-creator.js +72 -0
- package/dist/utils/date-formatter.d.ts +35 -0
- package/dist/utils/date-formatter.d.ts.map +1 -0
- package/dist/utils/date-formatter.js +207 -0
- package/dist/utils/get-all-prop.d.ts +4 -0
- package/dist/utils/get-all-prop.d.ts.map +1 -0
- package/dist/utils/get-all-prop.js +5 -0
- package/dist/utils/get-family-with.d.ts +5 -0
- package/dist/utils/get-family-with.d.ts.map +1 -0
- package/dist/utils/get-family-with.js +11 -0
- package/dist/utils/get-places.d.ts +21 -0
- package/dist/utils/get-places.d.ts.map +1 -0
- package/dist/utils/get-places.js +77 -0
- package/dist/utils/get-product-details.d.ts +4 -0
- package/dist/utils/get-product-details.d.ts.map +1 -0
- package/dist/utils/get-product-details.js +6 -0
- package/dist/utils/get-raw-size.d.ts +2 -0
- package/dist/utils/get-raw-size.d.ts.map +1 -0
- package/dist/utils/get-raw-size.js +3 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +11 -0
- package/dist/utils/name-formatter.d.ts +10 -0
- package/dist/utils/name-formatter.d.ts.map +1 -0
- package/dist/utils/name-formatter.js +45 -0
- package/dist/utils/nested-group.d.ts +4 -0
- package/dist/utils/nested-group.d.ts.map +1 -0
- package/dist/utils/nested-group.js +34 -0
- package/dist/utils/ordinalize.d.ts +3 -0
- package/dist/utils/ordinalize.d.ts.map +1 -0
- package/dist/utils/ordinalize.js +104 -0
- package/dist/utils/parser.d.ts +17 -0
- package/dist/utils/parser.d.ts.map +1 -0
- package/dist/utils/parser.js +322 -0
- package/dist/utils/place-parser.d.ts +16 -0
- package/dist/utils/place-parser.d.ts.map +1 -0
- package/dist/utils/place-parser.js +46 -0
- package/dist/utils/place-translator.d.ts +6 -0
- package/dist/utils/place-translator.d.ts.map +1 -0
- package/dist/utils/place-translator.js +8 -0
- package/dist/utils/place-types.d.ts +27 -0
- package/dist/utils/place-types.d.ts.map +1 -0
- package/dist/utils/place-types.js +14 -0
- package/dist/utils/range.d.ts +19 -0
- package/dist/utils/range.d.ts.map +1 -0
- package/dist/utils/range.js +265 -0
- package/package.json +153 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type IdType, type MultiTag } from "../types/types";
|
|
2
|
+
import type { ListTag } from "../types/types";
|
|
3
|
+
import { type ConvertOptions } from "../interfaces/common";
|
|
4
|
+
import type ICommon from "../interfaces/common";
|
|
5
|
+
import { type GedComType } from "./gedcom";
|
|
6
|
+
import { List } from "./list";
|
|
7
|
+
export declare class Common<T = string, I extends IdType = IdType> implements ICommon<T, I> {
|
|
8
|
+
protected _gedcom?: GedComType;
|
|
9
|
+
protected _value?: T;
|
|
10
|
+
protected _id?: I;
|
|
11
|
+
protected _main?: Common;
|
|
12
|
+
protected _parent?: Common;
|
|
13
|
+
protected _uniqueId?: string | undefined;
|
|
14
|
+
protected _type?: MultiTag;
|
|
15
|
+
protected _refs?: List;
|
|
16
|
+
isListable: boolean;
|
|
17
|
+
refType?: ListTag;
|
|
18
|
+
cloneOf?: string;
|
|
19
|
+
clonedBy?: string;
|
|
20
|
+
constructor(gedcom?: GedComType, id?: I, main?: Common, parent?: Common);
|
|
21
|
+
set type(type: MultiTag | undefined);
|
|
22
|
+
get type(): MultiTag | undefined;
|
|
23
|
+
initUniqueId(): void;
|
|
24
|
+
set uniqueId(id: string | undefined);
|
|
25
|
+
get uniqueId(): string | undefined;
|
|
26
|
+
set id(id: I | undefined);
|
|
27
|
+
get id(): I | undefined;
|
|
28
|
+
set value(value: T | undefined);
|
|
29
|
+
get value(): T | undefined;
|
|
30
|
+
get originalValue(): T;
|
|
31
|
+
get ref(): Common<T, I> | undefined;
|
|
32
|
+
get main(): Common<string, IdType>;
|
|
33
|
+
get parent(): Common<string, IdType>;
|
|
34
|
+
addRef(refNode: Common): void;
|
|
35
|
+
getRefs(): List<IdType, Common<string, IdType>>;
|
|
36
|
+
exportValue(): T;
|
|
37
|
+
removeValue(): void;
|
|
38
|
+
set<T extends Common | List = Common | List>(name: MultiTag, value: T | string): T | undefined;
|
|
39
|
+
assign<T extends Common | List = Common | List>(name: MultiTag, value: T, unique?: boolean): T | undefined;
|
|
40
|
+
get<T extends Common | List = Common | List>(name: MultiTag): T;
|
|
41
|
+
remove(name: MultiTag): void;
|
|
42
|
+
getGedcom(): GedComType;
|
|
43
|
+
getIf<T extends Common | List = Common | List>(name: MultiTag, condition: string, name2: MultiTag): T;
|
|
44
|
+
toString(): string;
|
|
45
|
+
toValue(): T;
|
|
46
|
+
toProp(tag: MultiTag): Common<T, I> | undefined;
|
|
47
|
+
toList(): List<IdType, Common<string, IdType>>;
|
|
48
|
+
toValueList(): List<IdType, Common<string, IdType>>;
|
|
49
|
+
private standardizeObject;
|
|
50
|
+
toJson(tag?: MultiTag, options?: ConvertOptions): string;
|
|
51
|
+
toObject(tag?: MultiTag, options?: ConvertOptions): Record<string, string | ({
|
|
52
|
+
value?: string;
|
|
53
|
+
} & Record<string, unknown>) | (string | ({
|
|
54
|
+
value?: string;
|
|
55
|
+
} & Record<string, unknown>))[]>;
|
|
56
|
+
merge(other: Common<T, I>, override?: boolean, avoidKeys?: MultiTag[]): this;
|
|
57
|
+
clone(newId?: boolean, avoidKeys?: MultiTag[]): Common<T, I>;
|
|
58
|
+
fromGedcom(_value: string): void;
|
|
59
|
+
toGedcom(tag?: MultiTag, level?: number, options?: ConvertOptions): string;
|
|
60
|
+
toGedcomLines(tag?: MultiTag, level?: number, options?: ConvertOptions): string[];
|
|
61
|
+
isGenoPro(): boolean;
|
|
62
|
+
isAhnenblatt(): boolean;
|
|
63
|
+
isGeni(): boolean;
|
|
64
|
+
isAncestry(): boolean;
|
|
65
|
+
isMyHeritage(): boolean;
|
|
66
|
+
isFamilySearch(): boolean;
|
|
67
|
+
getAncestryTreeId(): string | undefined;
|
|
68
|
+
getMyHeritageTreeId(): string | undefined;
|
|
69
|
+
getTreeId(): string;
|
|
70
|
+
getAncestryTreeName(): string | undefined;
|
|
71
|
+
getMyHeritageTreeName(): string;
|
|
72
|
+
getTreeName(): string;
|
|
73
|
+
}
|
|
74
|
+
export type ProxyOriginal<T extends Common> = T & {
|
|
75
|
+
unwrapped: T;
|
|
76
|
+
};
|
|
77
|
+
export declare const createProxy: <T extends Common>(target: T) => T;
|
|
78
|
+
export declare const createCommon: (gedcom?: GedComType, id?: IdType, main?: Common, parent?: Common) => ProxyOriginal<Common>;
|
|
79
|
+
export declare const isOnlyMainProp: (key: string | symbol) => key is MultiTag | "_value" | "value";
|
|
80
|
+
export declare const isValidKey: <T>(common: Common<T>, key: string | symbol) => key is MultiTag | "_value" | "value" | "id" | "_id";
|
|
81
|
+
export declare const getValidKeys: <T>(common: Common<T>) => Array<MultiTag | "_value" | "value" | "id" | "_id">;
|
|
82
|
+
export declare const getValidTag: (tag: string) => string;
|
|
83
|
+
export declare const getListTag: (tag: string) => ListTag;
|
|
84
|
+
export declare const getValidKey: (tag: string, id: string) => string;
|
|
85
|
+
export declare const isId: (string: string) => string is IdType;
|
|
86
|
+
export declare const idGetter: <T extends IdType>(id?: T) => T;
|
|
87
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/classes/common.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import get from "lodash/get";
|
|
2
|
+
import set from "lodash/set";
|
|
3
|
+
import uniqBy from "lodash/uniqBy";
|
|
4
|
+
import unset from "lodash/unset";
|
|
5
|
+
import { ID_GETTER_REG, ID_REG } from "../constants/constants";
|
|
6
|
+
import { List } from "./list";
|
|
7
|
+
// import GedcomTree from "../../../utils/parser";
|
|
8
|
+
export class Common {
|
|
9
|
+
constructor(gedcom, id, main, parent) {
|
|
10
|
+
this.isListable = true;
|
|
11
|
+
this._gedcom = gedcom;
|
|
12
|
+
this._main = main;
|
|
13
|
+
this._parent = parent;
|
|
14
|
+
this.initUniqueId();
|
|
15
|
+
if (id) {
|
|
16
|
+
this._id = id;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
delete this._id;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
set type(type) {
|
|
23
|
+
if (type) {
|
|
24
|
+
this.uniqueId = this.uniqueId?.replace(/^[^:]+/, `~${type}`);
|
|
25
|
+
}
|
|
26
|
+
this._type = type;
|
|
27
|
+
}
|
|
28
|
+
get type() {
|
|
29
|
+
return this._type;
|
|
30
|
+
}
|
|
31
|
+
initUniqueId() {
|
|
32
|
+
if (this._gedcom) {
|
|
33
|
+
this.uniqueId = `~Common:${this._gedcom.refcount++}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
set uniqueId(id) {
|
|
37
|
+
const currentId = this._uniqueId;
|
|
38
|
+
if (this._gedcom?.reflist && id) {
|
|
39
|
+
this._uniqueId = id;
|
|
40
|
+
if (currentId && this._gedcom.reflist[currentId]) {
|
|
41
|
+
delete this._gedcom.reflist[currentId];
|
|
42
|
+
}
|
|
43
|
+
this._gedcom.reflist[id] = this;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get uniqueId() {
|
|
47
|
+
return this._uniqueId;
|
|
48
|
+
}
|
|
49
|
+
set id(id) {
|
|
50
|
+
this._id = idGetter(id);
|
|
51
|
+
}
|
|
52
|
+
get id() {
|
|
53
|
+
return idGetter(this._id);
|
|
54
|
+
}
|
|
55
|
+
set value(value) {
|
|
56
|
+
this._value = value;
|
|
57
|
+
}
|
|
58
|
+
get value() {
|
|
59
|
+
return this._value;
|
|
60
|
+
}
|
|
61
|
+
// avoid to override
|
|
62
|
+
get originalValue() {
|
|
63
|
+
return this._value;
|
|
64
|
+
}
|
|
65
|
+
get ref() {
|
|
66
|
+
if (typeof this.value === "string" &&
|
|
67
|
+
isId(this.value) &&
|
|
68
|
+
this.refType) {
|
|
69
|
+
return this._gedcom?.[getListTag(this.refType)]?.item(
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
this.value);
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
get main() {
|
|
76
|
+
return this._main;
|
|
77
|
+
}
|
|
78
|
+
get parent() {
|
|
79
|
+
return this._parent;
|
|
80
|
+
}
|
|
81
|
+
addRef(refNode) {
|
|
82
|
+
if (typeof refNode.value === "string" &&
|
|
83
|
+
isId(refNode.value) &&
|
|
84
|
+
refNode.refType) {
|
|
85
|
+
if (!this._refs) {
|
|
86
|
+
this._refs = new List();
|
|
87
|
+
}
|
|
88
|
+
this._refs.item(refNode.value, refNode);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
getRefs() {
|
|
92
|
+
return this._refs;
|
|
93
|
+
}
|
|
94
|
+
exportValue() {
|
|
95
|
+
return this.value;
|
|
96
|
+
}
|
|
97
|
+
removeValue() {
|
|
98
|
+
delete this._value;
|
|
99
|
+
}
|
|
100
|
+
set(name, value) {
|
|
101
|
+
if (typeof value === "string") {
|
|
102
|
+
const usedValue = createCommon(this._gedcom, undefined, this.main);
|
|
103
|
+
usedValue.value = value;
|
|
104
|
+
set(this, name, usedValue);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
set(this, name, value);
|
|
108
|
+
}
|
|
109
|
+
return get(this, name);
|
|
110
|
+
}
|
|
111
|
+
assign(name, value, unique = false) {
|
|
112
|
+
let curValue = this.get(name);
|
|
113
|
+
if (curValue?.isListable) {
|
|
114
|
+
if (curValue instanceof Common) {
|
|
115
|
+
curValue = new List().concat({ ...[curValue] });
|
|
116
|
+
this.set(name, curValue);
|
|
117
|
+
}
|
|
118
|
+
const values = [
|
|
119
|
+
...curValue.values(),
|
|
120
|
+
...(value instanceof List ? value.values() : [value]),
|
|
121
|
+
];
|
|
122
|
+
curValue.concat({
|
|
123
|
+
...(!unique
|
|
124
|
+
? values
|
|
125
|
+
: uniqBy(values, (value) => value instanceof Common ? value?.value : undefined)),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.set(name, value);
|
|
130
|
+
}
|
|
131
|
+
return get(this, name);
|
|
132
|
+
}
|
|
133
|
+
get(name) {
|
|
134
|
+
if (!name.includes(".")) {
|
|
135
|
+
return get(this, name);
|
|
136
|
+
}
|
|
137
|
+
const nameParts = name.split(".");
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
139
|
+
let last = this;
|
|
140
|
+
for (const part of nameParts) {
|
|
141
|
+
const indexPart = Number(part);
|
|
142
|
+
const itemIndex = part.match(/items\[(?<itemIndex>\d+)\]/)?.groups
|
|
143
|
+
?.itemIndex;
|
|
144
|
+
const itemId = part.match(/items\[(?<itemId>@[A-Z]+\d+@)\]/)?.groups
|
|
145
|
+
?.itemId;
|
|
146
|
+
const usedPart = itemId || itemIndex;
|
|
147
|
+
if (last instanceof List) {
|
|
148
|
+
if (!isNaN(indexPart)) {
|
|
149
|
+
last = last.index(indexPart);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (usedPart) {
|
|
153
|
+
last = last.item(usedPart);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
last = last?.index(0)?.get(part);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const usedIndex = Number(itemIndex ?? indexPart);
|
|
162
|
+
if (!isNaN(usedIndex)) {
|
|
163
|
+
last = last?.toList().index(usedIndex);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
last = last?.get((itemId ?? part));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!last) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return last;
|
|
174
|
+
}
|
|
175
|
+
remove(name) {
|
|
176
|
+
unset(this, name);
|
|
177
|
+
}
|
|
178
|
+
getGedcom() {
|
|
179
|
+
return this._gedcom;
|
|
180
|
+
}
|
|
181
|
+
getIf(name, condition, name2) {
|
|
182
|
+
const nameParts = name.split(".");
|
|
183
|
+
const name2Parts = name2.split(".");
|
|
184
|
+
if (nameParts.length !== name2Parts.length) {
|
|
185
|
+
throw new Error("Tag pathes must be of the same depth");
|
|
186
|
+
}
|
|
187
|
+
if (nameParts.length > 1 && nameParts[0] !== name2Parts[0]) {
|
|
188
|
+
throw new Error("Final tags must be siblings");
|
|
189
|
+
}
|
|
190
|
+
const valueCommon = this.get(name);
|
|
191
|
+
if (valueCommon instanceof Common) {
|
|
192
|
+
return valueCommon?.toValue() !== condition
|
|
193
|
+
? undefined
|
|
194
|
+
: this.get(name2);
|
|
195
|
+
}
|
|
196
|
+
const valueCommon2 = this.get(name2)?.toList();
|
|
197
|
+
const ifList = new List();
|
|
198
|
+
valueCommon?.forEach((item, key) => {
|
|
199
|
+
const pair = valueCommon2?.item(key);
|
|
200
|
+
ifList.item(key, item?.toValue() !== condition ? undefined : pair);
|
|
201
|
+
});
|
|
202
|
+
return ifList;
|
|
203
|
+
}
|
|
204
|
+
toString() {
|
|
205
|
+
return this.value?.toString() || "";
|
|
206
|
+
}
|
|
207
|
+
toValue() {
|
|
208
|
+
return this.value;
|
|
209
|
+
}
|
|
210
|
+
toProp(tag) {
|
|
211
|
+
const prop = this.get(tag);
|
|
212
|
+
return prop;
|
|
213
|
+
}
|
|
214
|
+
toList() {
|
|
215
|
+
return new List().concat(
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
+
this.id ? { [this.id]: this } : { ...[this] });
|
|
218
|
+
}
|
|
219
|
+
toValueList() {
|
|
220
|
+
return new List().concat(this.value
|
|
221
|
+
? { [this.value]: this }
|
|
222
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
{ ...[this] });
|
|
224
|
+
}
|
|
225
|
+
standardizeObject(tag, options) {
|
|
226
|
+
if (tag === "OBJE" &&
|
|
227
|
+
!options?.original &&
|
|
228
|
+
options?.obje?.standardize &&
|
|
229
|
+
options?.obje?.namespace &&
|
|
230
|
+
"standardizeMedia" in this) {
|
|
231
|
+
const standardize = this.standardizeMedia;
|
|
232
|
+
return standardize.call(this, options.obje.namespace, options.obje.override);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
toJson(tag, options) {
|
|
236
|
+
const json = this.toObject(tag, options);
|
|
237
|
+
return JSON.stringify(json);
|
|
238
|
+
}
|
|
239
|
+
toObject(tag, options) {
|
|
240
|
+
this.standardizeObject(tag, options);
|
|
241
|
+
const validKeys = getValidKeys(this);
|
|
242
|
+
let json = {};
|
|
243
|
+
validKeys.forEach((key) => {
|
|
244
|
+
if (key === "id" && this.id !== undefined) {
|
|
245
|
+
json.id = this.id;
|
|
246
|
+
}
|
|
247
|
+
else if (key === "_id" && this._id !== undefined) {
|
|
248
|
+
json.id = this._id;
|
|
249
|
+
}
|
|
250
|
+
else if (key === "value" && this.value !== undefined) {
|
|
251
|
+
json.value = this.value;
|
|
252
|
+
}
|
|
253
|
+
else if (key === "_value" && this._value !== undefined) {
|
|
254
|
+
json.value = this._value;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const validKey = key;
|
|
258
|
+
const prop = this.get(validKey);
|
|
259
|
+
if (typeof prop?.toObject === "function") {
|
|
260
|
+
if (prop instanceof Common) {
|
|
261
|
+
json[validKey] = prop.toObject(validKey, options);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
json = {
|
|
265
|
+
...json,
|
|
266
|
+
...prop.toObject(validKey, options),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
return json;
|
|
273
|
+
}
|
|
274
|
+
merge(other, override = false, avoidKeys = []) {
|
|
275
|
+
if (!other) {
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
const validKeys = getValidKeys(other);
|
|
279
|
+
validKeys.forEach((validKey) => {
|
|
280
|
+
if (avoidKeys.includes(validKey)) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const current = this.get(validKey);
|
|
284
|
+
const mergeValue = other.get(validKey);
|
|
285
|
+
if (mergeValue) {
|
|
286
|
+
if (current instanceof Common || current instanceof List) {
|
|
287
|
+
this.assign(validKey, mergeValue, true);
|
|
288
|
+
}
|
|
289
|
+
else if (!current ||
|
|
290
|
+
(override && validKey !== "id" && validKey !== "_id")) {
|
|
291
|
+
this.set(validKey, mergeValue);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
clone(newId = false, avoidKeys = []) {
|
|
298
|
+
const ctor = this.constructor;
|
|
299
|
+
const instance = new ctor(this._gedcom, this._id, this._main, this._parent);
|
|
300
|
+
if (newId && this._id) {
|
|
301
|
+
instance.id = `IFT${this._id.replace(/[^0-9]/g, "")}`;
|
|
302
|
+
}
|
|
303
|
+
const cloned = createProxy(instance);
|
|
304
|
+
cloned.merge(this, true, avoidKeys);
|
|
305
|
+
return cloned;
|
|
306
|
+
}
|
|
307
|
+
// fromGedcom<T = typeof this>(value: string) {
|
|
308
|
+
fromGedcom(_value) {
|
|
309
|
+
// Object.assign(this, GedcomTree.parse(value) as T);
|
|
310
|
+
}
|
|
311
|
+
toGedcom(tag, level = 0, options) {
|
|
312
|
+
const gedcom = this.toGedcomLines(tag, level, options);
|
|
313
|
+
return gedcom.join("\n");
|
|
314
|
+
}
|
|
315
|
+
toGedcomLines(tag, level = 0, options) {
|
|
316
|
+
this.standardizeObject(tag, options);
|
|
317
|
+
const validKeys = getValidKeys(this);
|
|
318
|
+
const gedcom = [];
|
|
319
|
+
validKeys.forEach((key) => {
|
|
320
|
+
const validKey = key;
|
|
321
|
+
const prop = this.get(validKey);
|
|
322
|
+
if (typeof prop?.toGedcomLines === "function") {
|
|
323
|
+
if (prop instanceof Common) {
|
|
324
|
+
const value = prop.exportValue();
|
|
325
|
+
gedcom.push(`${level} ${validKey}${value ? ` ${value}` : ""}`);
|
|
326
|
+
gedcom.push(...prop.toGedcomLines(validKey, level + 1, options));
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
gedcom.push(...prop.toGedcomLines(validKey, level, options));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
return gedcom;
|
|
334
|
+
}
|
|
335
|
+
isGenoPro() {
|
|
336
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
337
|
+
const sour = get(head, "SOUR.value");
|
|
338
|
+
return !!sour?.toLowerCase()?.startsWith("genopro");
|
|
339
|
+
}
|
|
340
|
+
isAhnenblatt() {
|
|
341
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
342
|
+
const sour = get(head, "SOUR.value");
|
|
343
|
+
return !!sour?.toLowerCase()?.startsWith("ahnenblatt");
|
|
344
|
+
}
|
|
345
|
+
isGeni() {
|
|
346
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
347
|
+
const sour = get(head, "SOUR.value");
|
|
348
|
+
return !!sour?.toLowerCase()?.startsWith("geni");
|
|
349
|
+
}
|
|
350
|
+
isAncestry() {
|
|
351
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
352
|
+
const sour = get(head, "SOUR.value");
|
|
353
|
+
return !!sour?.toLowerCase()?.startsWith("ancestry");
|
|
354
|
+
}
|
|
355
|
+
isMyHeritage() {
|
|
356
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
357
|
+
const sour = get(head, "SOUR.value");
|
|
358
|
+
return !!sour?.toLowerCase()?.startsWith("myheritage");
|
|
359
|
+
}
|
|
360
|
+
isFamilySearch() {
|
|
361
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
362
|
+
const sourName = get(head, "SOUR.NAME.value");
|
|
363
|
+
return sourName === "FamilySearch API";
|
|
364
|
+
}
|
|
365
|
+
getAncestryTreeId() {
|
|
366
|
+
const path = "HEAD.SOUR._TREE.RIN.value";
|
|
367
|
+
return (get(this, path) || get(this.getGedcom(), path));
|
|
368
|
+
}
|
|
369
|
+
getMyHeritageTreeId() {
|
|
370
|
+
const path = "HEAD._EXPORTED_FROM_SITE_ID.value";
|
|
371
|
+
return (get(this, path) || get(this.getGedcom(), path));
|
|
372
|
+
}
|
|
373
|
+
getTreeId() {
|
|
374
|
+
if (this?.isAncestry()) {
|
|
375
|
+
return this.getAncestryTreeId();
|
|
376
|
+
}
|
|
377
|
+
if (this?.isMyHeritage()) {
|
|
378
|
+
return this.getMyHeritageTreeId();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
getAncestryTreeName() {
|
|
382
|
+
const path = "HEAD.SOUR._TREE.value";
|
|
383
|
+
return (get(this, path) || get(this.getGedcom(), path));
|
|
384
|
+
}
|
|
385
|
+
getMyHeritageTreeName() {
|
|
386
|
+
const path = "HEAD.FILE.value";
|
|
387
|
+
const treeDetails = (get(this, path) || get(this.getGedcom(), path));
|
|
388
|
+
return treeDetails?.match(/Exported by MyHeritage.com from (?<tree>.+) in.+$/)?.groups?.tree;
|
|
389
|
+
}
|
|
390
|
+
getTreeName() {
|
|
391
|
+
if (this?.isAncestry()) {
|
|
392
|
+
return this.getAncestryTreeName();
|
|
393
|
+
}
|
|
394
|
+
if (this?.isMyHeritage()) {
|
|
395
|
+
return this.getMyHeritageTreeName();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
export const createProxy = (target) => {
|
|
400
|
+
return new Proxy(target, {
|
|
401
|
+
get(t, prop, receiver) {
|
|
402
|
+
if (prop === "unwrapped") {
|
|
403
|
+
return target;
|
|
404
|
+
}
|
|
405
|
+
if (prop in t) {
|
|
406
|
+
return Reflect.get(t, prop, receiver);
|
|
407
|
+
}
|
|
408
|
+
if (!isOnlyMainProp(prop)) {
|
|
409
|
+
const ref = t.ref;
|
|
410
|
+
if (ref && prop in ref) {
|
|
411
|
+
return Reflect.get(ref, prop, receiver);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
export const createCommon = (gedcom, id, main, parent) => {
|
|
418
|
+
return createProxy(new Common(gedcom, id, main, parent));
|
|
419
|
+
};
|
|
420
|
+
export const isOnlyMainProp = (key) => {
|
|
421
|
+
return (key === "_gedcom" ||
|
|
422
|
+
key === "_main" ||
|
|
423
|
+
key === "_parent" ||
|
|
424
|
+
key === "_uniqueId" ||
|
|
425
|
+
key === "_type" ||
|
|
426
|
+
key === "_refs" ||
|
|
427
|
+
key === "id" ||
|
|
428
|
+
key === "_id");
|
|
429
|
+
};
|
|
430
|
+
export const isValidKey = (common, key) => {
|
|
431
|
+
const prop = get(common, key);
|
|
432
|
+
return (key !== "_gedcom" &&
|
|
433
|
+
key !== "_main" &&
|
|
434
|
+
key !== "_parent" &&
|
|
435
|
+
key !== "_uniqueId" &&
|
|
436
|
+
key !== "_refs" &&
|
|
437
|
+
key !== "_type" &&
|
|
438
|
+
(key === "id" ||
|
|
439
|
+
key === "_id" ||
|
|
440
|
+
key === "value" ||
|
|
441
|
+
key === "_value" ||
|
|
442
|
+
prop instanceof Common ||
|
|
443
|
+
prop instanceof List));
|
|
444
|
+
};
|
|
445
|
+
export const getValidKeys = (common) => {
|
|
446
|
+
return Object.keys(common).filter((key) => {
|
|
447
|
+
return isValidKey(common, key);
|
|
448
|
+
});
|
|
449
|
+
};
|
|
450
|
+
export const getValidTag = (tag) => {
|
|
451
|
+
return tag.replace(/^@@/, "");
|
|
452
|
+
};
|
|
453
|
+
export const getListTag = (tag) => {
|
|
454
|
+
return `@@${tag}`;
|
|
455
|
+
};
|
|
456
|
+
export const getValidKey = (tag, id) => {
|
|
457
|
+
return `${id} ${getValidTag(tag)}`;
|
|
458
|
+
};
|
|
459
|
+
export const isId = (string) => {
|
|
460
|
+
return ID_REG.test(string);
|
|
461
|
+
};
|
|
462
|
+
export const idGetter = (id) => {
|
|
463
|
+
if (id === undefined) {
|
|
464
|
+
return undefined;
|
|
465
|
+
}
|
|
466
|
+
let newId = `${id}`;
|
|
467
|
+
const parts = newId?.match(ID_GETTER_REG)?.groups;
|
|
468
|
+
if (!parts?.at && !parts?.letter) {
|
|
469
|
+
newId = `@U${newId}`;
|
|
470
|
+
}
|
|
471
|
+
else if (!parts.at) {
|
|
472
|
+
newId = `@${newId}`;
|
|
473
|
+
}
|
|
474
|
+
else if (!parts.letter) {
|
|
475
|
+
newId = newId.replace(/^@/, "@U");
|
|
476
|
+
}
|
|
477
|
+
if (!newId.endsWith("@")) {
|
|
478
|
+
newId = `${newId}@`;
|
|
479
|
+
}
|
|
480
|
+
return newId;
|
|
481
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IdType, MultiTag } from "../types/types";
|
|
2
|
+
import type { Range } from "../utils/range";
|
|
3
|
+
import { Common } from "./common";
|
|
4
|
+
import type { ProxyOriginal } from "./common";
|
|
5
|
+
import { type GedComType } from "./gedcom";
|
|
6
|
+
import type { List } from "./list";
|
|
7
|
+
export declare class CommonDate extends Common<string> {
|
|
8
|
+
private _date?;
|
|
9
|
+
DAY?: Common;
|
|
10
|
+
MONTH?: Common;
|
|
11
|
+
YEAR?: Common;
|
|
12
|
+
NOTE?: Common;
|
|
13
|
+
constructor(gedcom?: GedComType, id?: IdType, main?: Common, parent?: Common);
|
|
14
|
+
set value(value: string | undefined);
|
|
15
|
+
get value(): string | undefined;
|
|
16
|
+
get rawValue(): Date;
|
|
17
|
+
assign<T extends Common | List = Common | List>(name: MultiTag, value: T, unique?: boolean): T;
|
|
18
|
+
private isValidDateFormat;
|
|
19
|
+
toNote(short?: boolean): string | undefined;
|
|
20
|
+
toValue(dateFormat?: string): string | undefined;
|
|
21
|
+
exportValue(): string;
|
|
22
|
+
inRange(range: Range, trueIfNoYear?: boolean): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const createCommonDate: (gedcom?: GedComType, id?: IdType, main?: Common, parent?: Common) => ProxyOriginal<CommonDate>;
|
|
25
|
+
export declare const isCommonDate: (value?: unknown) => value is CommonDate;
|
|
26
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/classes/date.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAA6B,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAkDnC,qBAAa,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAC,CAAO;IAErB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;gBAGb,MAAM,CAAC,EAAE,UAAU,EACnB,EAAE,CAAC,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM;IAOhB,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EA0ElC;IAED,IAAI,KAAK,IA5EQ,MAAM,GAAG,SAAS,CA+FlC;IAED,IAAI,QAAQ,SAEX;IAED,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,EAC7C,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,CAAC,EACR,MAAM,UAAQ;IAUf,OAAO,CAAC,iBAAiB;IAgBzB,MAAM,CAAC,KAAK,UAAO,GAAG,MAAM,GAAG,SAAS;IAUxC,OAAO,CAAC,UAAU,SAAgB,GAAG,MAAM,GAAG,SAAS;IAsBvD,WAAW;IAIX,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,UAAQ;CAG1C;AAED,eAAO,MAAM,gBAAgB,GAC5B,SAAS,UAAU,EACnB,KAAK,MAAM,EACX,OAAO,MAAM,EACb,SAAS,MAAM,KACb,aAAa,CAAC,UAAU,CAI1B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,UAOvD,CAAC"}
|