@pbkware/fielded-text-web 0.1.0 → 0.2.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/README.md +68 -0
- package/dist/api/ft-reader.js +1 -1
- package/dist/api/ft-reader.js.map +1 -1
- package/dist/api/ft-serialization.js +4 -4
- package/dist/api/ft-serialization.js.map +1 -1
- package/dist/factory/ft-field-factory.js +1 -1
- package/dist/factory/ft-field-factory.js.map +1 -1
- package/dist/factory/ft-sequence-redirect-factory.js +3 -3
- package/dist/factory/ft-sequence-redirect-factory.js.map +1 -1
- package/dist/fields/definitions/ft-boolean-field-definition.js +1 -1
- package/dist/fields/definitions/ft-boolean-field-definition.js.map +1 -1
- package/dist/fields/definitions/ft-date-time-field-definition.js +1 -1
- package/dist/fields/definitions/ft-date-time-field-definition.js.map +1 -1
- package/dist/fields/definitions/ft-decimal-field-definition.js +1 -1
- package/dist/fields/definitions/ft-decimal-field-definition.js.map +1 -1
- package/dist/fields/definitions/ft-field-definition.js +1 -1
- package/dist/fields/definitions/ft-field-definition.js.map +1 -1
- package/dist/fields/definitions/ft-float-field-definition.js +1 -1
- package/dist/fields/definitions/ft-float-field-definition.js.map +1 -1
- package/dist/fields/definitions/ft-integer-field-definition.js +1 -1
- package/dist/fields/definitions/ft-integer-field-definition.js.map +1 -1
- package/dist/fields/definitions/ft-string-field-definition.js +1 -1
- package/dist/fields/definitions/ft-string-field-definition.js.map +1 -1
- package/dist/fields/instances/errors/ft-field-null-error.js +11 -0
- package/dist/fields/instances/errors/ft-field-null-error.js.map +1 -0
- package/dist/fields/instances/errors/ft-field-type-error.js +11 -0
- package/dist/fields/instances/errors/ft-field-type-error.js.map +1 -0
- package/dist/fields/instances/ft-boolean-field.js +14 -6
- package/dist/fields/instances/ft-boolean-field.js.map +1 -1
- package/dist/fields/instances/ft-date-time-field.js +26 -8
- package/dist/fields/instances/ft-date-time-field.js.map +1 -1
- package/dist/fields/instances/ft-decimal-field.js +14 -6
- package/dist/fields/instances/ft-decimal-field.js.map +1 -1
- package/dist/fields/instances/ft-field.js +315 -123
- package/dist/fields/instances/ft-field.js.map +1 -1
- package/dist/fields/instances/ft-float-field.js +14 -6
- package/dist/fields/instances/ft-float-field.js.map +1 -1
- package/dist/fields/instances/ft-generic-field.js +29 -67
- package/dist/fields/instances/ft-generic-field.js.map +1 -1
- package/dist/fields/instances/ft-integer-field.js +24 -8
- package/dist/fields/instances/ft-integer-field.js.map +1 -1
- package/dist/fields/instances/ft-string-field.js +13 -13
- package/dist/fields/instances/ft-string-field.js.map +1 -1
- package/dist/index.d.ts +616 -288
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/meta/sequences/core/ft-meta-sequence-list.js +4 -2
- package/dist/meta/sequences/core/ft-meta-sequence-list.js.map +1 -1
- package/dist/meta/sequences/redirects/ft-meta-sequence-redirect-list.js +1 -1
- package/dist/meta/sequences/redirects/ft-meta-sequence-redirect-list.js.map +1 -1
- package/dist/meta-serialization/format/ft-xml-meta-serialization.js +4 -6
- package/dist/meta-serialization/format/ft-xml-meta-serialization.js.map +1 -1
- package/dist/meta-serialization/styles/ft-number-styles-meta-serialization.js +1 -1
- package/dist/meta-serialization/styles/ft-number-styles-meta-serialization.js.map +1 -1
- package/dist/meta-serialization/types/date-time-meta-serialization.js +1 -1
- package/dist/meta-serialization/types/date-time-meta-serialization.js.map +1 -1
- package/dist/meta-serialization/types/enums/sequence-redirect-type-meta-serialisation.js +1 -1
- package/dist/meta-serialization/types/enums/sequence-redirect-type-meta-serialisation.js.map +1 -1
- package/dist/meta-serialization/types/float-meta-serialization.js +2 -2
- package/dist/meta-serialization/types/float-meta-serialization.js.map +1 -1
- package/dist/meta-serialization/types/integer-float-meta-serialization.js +2 -2
- package/dist/meta-serialization/types/integer-float-meta-serialization.js.map +1 -1
- package/dist/meta-serialization/utils/implicit-explicit-index-sorter.js +4 -10
- package/dist/meta-serialization/utils/implicit-explicit-index-sorter.js.map +1 -1
- package/dist/meta-serialization/utils/meta-serialization-sequence-name-resolver.js +25 -2
- package/dist/meta-serialization/utils/meta-serialization-sequence-name-resolver.js.map +1 -1
- package/dist/meta-serialization/utils/sequence-item-field-indices.js +2 -2
- package/dist/meta-serialization/utils/sequence-item-field-indices.js.map +1 -1
- package/dist/sequences/redirects/ft-case-insensitive-string-sequence-redirect.js +3 -1
- package/dist/sequences/redirects/ft-case-insensitive-string-sequence-redirect.js.map +1 -1
- package/dist/serialization/char-reader.js +2 -2
- package/dist/serialization/char-reader.js.map +1 -1
- package/dist/serialization/declaration-parser.js +1 -1
- package/dist/serialization/declaration-parser.js.map +1 -1
- package/dist/serialization/delimited-field-parser.js.map +1 -1
- package/dist/serialization/events/ft-field-heading-ready-event-args.js.map +1 -0
- package/dist/serialization/events/ft-field-value-ready-event-args.js.map +1 -0
- package/dist/serialization/events/ft-heading-line-finished-event-args.js.map +1 -0
- package/dist/serialization/events/ft-heading-line-started-event-args.js.map +1 -0
- package/dist/serialization/events/ft-record-finished-event-args.js.map +1 -0
- package/dist/serialization/events/ft-record-started-event-args.js.map +1 -0
- package/dist/serialization/events/ft-sequence-redirected-event-args.js.map +1 -0
- package/dist/serialization/fixed-width-field-parser.js +1 -1
- package/dist/serialization/fixed-width-field-parser.js.map +1 -1
- package/dist/serialization/ft-declared-parameters.js +9 -8
- package/dist/serialization/ft-declared-parameters.js.map +1 -1
- package/dist/serialization/{serialization-core.js → ft-serialization-core.js} +114 -11
- package/dist/serialization/ft-serialization-core.js.map +1 -0
- package/dist/{types/errors/ft-serialization-error.js → serialization/ft-serialization-error-code.js} +2 -2
- package/dist/serialization/ft-serialization-error-code.js.map +1 -0
- package/dist/{types/errors/ft-serialization-exception.js → serialization/ft-serialization-error.js} +7 -7
- package/dist/serialization/ft-serialization-error.js.map +1 -0
- package/dist/serialization/ft-serialization-reader.js +19 -47
- package/dist/serialization/ft-serialization-reader.js.map +1 -1
- package/dist/serialization/ft-serialization-writer.js +86 -49
- package/dist/serialization/ft-serialization-writer.js.map +1 -1
- package/dist/serialization/heading-line-record-parser.js +7 -7
- package/dist/serialization/heading-line-record-parser.js.map +1 -1
- package/dist/serialization/line-parser.js +1 -1
- package/dist/serialization/line-parser.js.map +1 -1
- package/dist/serialization/{ft-text-reader.js → text-reader/ft-string-reader.js} +1 -13
- package/dist/serialization/text-reader/ft-string-reader.js.map +1 -0
- package/dist/serialization/text-reader/ft-text-reader.js +13 -0
- package/dist/serialization/text-reader/ft-text-reader.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types/enums/ft-heading-constraint.js +5 -0
- package/dist/types/enums/ft-heading-constraint.js.map +1 -1
- package/dist/utils/ft-comma-text.js +247 -0
- package/dist/utils/ft-comma-text.js.map +1 -0
- package/dist/utils/ft-internal-error.js +129 -0
- package/dist/utils/ft-internal-error.js.map +1 -0
- package/dist/utils/ft-result.js +2 -0
- package/dist/utils/ft-result.js.map +1 -0
- package/dist/utils/number-parse.js +33 -0
- package/dist/utils/number-parse.js.map +1 -0
- package/dist/utils/string-builder.js +40 -0
- package/dist/utils/string-builder.js.map +1 -0
- package/package.json +27 -25
- package/src/api/ft-reader.ts +2 -1
- package/src/api/ft-serialization.ts +13 -13
- package/src/factory/ft-field-factory.ts +1 -1
- package/src/factory/ft-sequence-redirect-factory.ts +4 -4
- package/src/fields/definitions/ft-boolean-field-definition.ts +1 -1
- package/src/fields/definitions/ft-date-time-field-definition.ts +1 -1
- package/src/fields/definitions/ft-decimal-field-definition.ts +1 -1
- package/src/fields/definitions/ft-field-definition.ts +1 -1
- package/src/fields/definitions/ft-float-field-definition.ts +1 -1
- package/src/fields/definitions/ft-generic-field-definition.ts +1 -1
- package/src/fields/definitions/ft-integer-field-definition.ts +1 -1
- package/src/fields/definitions/ft-string-field-definition.ts +1 -1
- package/src/fields/instances/errors/ft-field-null-error.ts +10 -0
- package/src/fields/instances/errors/ft-field-type-error.ts +10 -0
- package/src/fields/instances/ft-boolean-field.ts +17 -6
- package/src/fields/instances/ft-date-time-field.ts +28 -7
- package/src/fields/instances/ft-decimal-field.ts +17 -6
- package/src/fields/instances/ft-field.ts +329 -145
- package/src/fields/instances/ft-float-field.ts +17 -6
- package/src/fields/instances/ft-generic-field.ts +32 -88
- package/src/fields/instances/ft-integer-field.ts +29 -7
- package/src/fields/instances/ft-string-field.ts +15 -12
- package/src/index.ts +21 -12
- package/src/meta/sequences/core/ft-meta-sequence-list.ts +4 -3
- package/src/meta/sequences/redirects/ft-meta-sequence-redirect-list.ts +1 -1
- package/src/meta-serialization/format/ft-xml-meta-serialization.ts +4 -7
- package/src/meta-serialization/styles/ft-number-styles-meta-serialization.ts +1 -1
- package/src/meta-serialization/types/date-time-meta-serialization.ts +1 -1
- package/src/meta-serialization/types/enums/meta-element-type-meta-serialization.ts +4 -4
- package/src/meta-serialization/types/enums/sequence-redirect-type-meta-serialisation.ts +1 -1
- package/src/meta-serialization/types/float-meta-serialization.ts +2 -2
- package/src/meta-serialization/types/integer-float-meta-serialization.ts +2 -2
- package/src/meta-serialization/utils/implicit-explicit-index-sorter.ts +18 -12
- package/src/meta-serialization/utils/meta-serialization-sequence-name-resolver.ts +25 -2
- package/src/meta-serialization/utils/sequence-item-field-indices.ts +2 -2
- package/src/sequences/redirects/ft-case-insensitive-string-sequence-redirect.ts +3 -1
- package/src/serialization/char-reader.ts +2 -2
- package/src/serialization/declaration-parser.ts +1 -1
- package/src/serialization/delimited-field-parser.ts +3 -3
- package/src/serialization/fixed-width-field-parser.ts +4 -4
- package/src/serialization/ft-declared-parameters.ts +12 -11
- package/src/serialization/{serialization-core.ts → ft-serialization-core.ts} +133 -17
- package/src/{types/errors/ft-serialization-error.ts → serialization/ft-serialization-error-code.ts} +2 -2
- package/src/{types/errors/ft-serialization-exception.ts → serialization/ft-serialization-error.ts} +14 -9
- package/src/serialization/ft-serialization-reader.ts +21 -54
- package/src/serialization/ft-serialization-writer.ts +97 -64
- package/src/serialization/heading-line-record-parser.ts +10 -10
- package/src/serialization/line-parser.ts +1 -1
- package/src/serialization/{ft-text-reader.ts → text-reader/ft-string-reader.ts} +1 -24
- package/src/serialization/text-reader/ft-text-reader.ts +24 -0
- package/src/types/enums/ft-heading-constraint.ts +5 -0
- package/src/utils/ft-comma-text.ts +285 -0
- package/src/utils/ft-internal-error.ts +143 -0
- package/src/utils/ft-result.ts +1 -0
- package/src/utils/number-parse.ts +35 -0
- package/src/utils/string-builder.ts +47 -0
- package/dist/serialization/ft-text-reader.js.map +0 -1
- package/dist/serialization/serialization-core.js.map +0 -1
- package/dist/types/errors/ft-internal-error.js +0 -14
- package/dist/types/errors/ft-internal-error.js.map +0 -1
- package/dist/types/errors/ft-serialization-error.js.map +0 -1
- package/dist/types/errors/ft-serialization-exception.js.map +0 -1
- package/dist/types/events/ft-field-heading-ready-event-args.js.map +0 -1
- package/dist/types/events/ft-field-value-ready-event-args.js.map +0 -1
- package/dist/types/events/ft-heading-line-finished-event-args.js.map +0 -1
- package/dist/types/events/ft-heading-line-started-event-args.js.map +0 -1
- package/dist/types/events/ft-record-finished-event-args.js.map +0 -1
- package/dist/types/events/ft-record-started-event-args.js.map +0 -1
- package/dist/types/events/ft-sequence-redirected-event-args.js.map +0 -1
- package/src/types/errors/ft-internal-error.ts +0 -15
- /package/dist/{types → serialization}/events/ft-field-heading-ready-event-args.js +0 -0
- /package/dist/{types → serialization}/events/ft-field-value-ready-event-args.js +0 -0
- /package/dist/{types → serialization}/events/ft-heading-line-finished-event-args.js +0 -0
- /package/dist/{types → serialization}/events/ft-heading-line-started-event-args.js +0 -0
- /package/dist/{types → serialization}/events/ft-record-finished-event-args.js +0 -0
- /package/dist/{types → serialization}/events/ft-record-started-event-args.js +0 -0
- /package/dist/{types → serialization}/events/ft-sequence-redirected-event-args.js +0 -0
- /package/src/{types → serialization}/events/ft-field-heading-ready-event-args.ts +0 -0
- /package/src/{types → serialization}/events/ft-field-value-ready-event-args.ts +0 -0
- /package/src/{types → serialization}/events/ft-heading-line-finished-event-args.ts +0 -0
- /package/src/{types → serialization}/events/ft-heading-line-started-event-args.ts +0 -0
- /package/src/{types → serialization}/events/ft-record-finished-event-args.ts +0 -0
- /package/src/{types → serialization}/events/ft-record-started-event-args.ts +0 -0
- /package/src/{types → serialization}/events/ft-sequence-redirected-event-args.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CommaText } from '@pbkware/js-utils';
|
|
2
1
|
import { FtMetaFieldList } from '../../meta/fields/ft-meta-field-list.js';
|
|
3
2
|
import { FtMetaField } from '../../meta/fields/ft-meta-field.js';
|
|
4
3
|
import { FtMetaSequence } from '../../meta/sequences/core/ft-meta-sequence.js';
|
|
4
|
+
import { FtCommaText } from '../../utils/ft-comma-text.js';
|
|
5
5
|
import { IntegerFloatMetaSerialization } from '../types/integer-float-meta-serialization.js';
|
|
6
6
|
|
|
7
7
|
export namespace SequenceItemFieldIndexSerialization {
|
|
@@ -27,7 +27,7 @@ export namespace SequenceItemFieldIndexSerialization {
|
|
|
27
27
|
}
|
|
28
28
|
fieldIndices.length = count; // Trim to actual count
|
|
29
29
|
|
|
30
|
-
const commaTextFieldIndices = count > 0 ?
|
|
30
|
+
const commaTextFieldIndices = count > 0 ? FtCommaText.fromIntegerArray(fieldIndices) : undefined;
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
33
|
commaTextFieldIndices,
|
|
@@ -13,6 +13,7 @@ export class FtCaseInsensitiveStringSequenceRedirect extends FtSequenceRedirect
|
|
|
13
13
|
static readonly TYPE = FtSequenceRedirectType.CaseInsensitiveString;
|
|
14
14
|
|
|
15
15
|
private _value = '';
|
|
16
|
+
private _lowerCaseValue = '';
|
|
16
17
|
|
|
17
18
|
constructor(index: number) {
|
|
18
19
|
super(index, FtCaseInsensitiveStringSequenceRedirect.TYPE);
|
|
@@ -27,7 +28,7 @@ export class FtCaseInsensitiveStringSequenceRedirect extends FtSequenceRedirect
|
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
29
30
|
try {
|
|
30
|
-
return field.asRedirectString.toLowerCase() === this.
|
|
31
|
+
return field.asRedirectString.toLowerCase() === this._lowerCaseValue;
|
|
31
32
|
} catch {
|
|
32
33
|
return false;
|
|
33
34
|
}
|
|
@@ -42,5 +43,6 @@ export class FtCaseInsensitiveStringSequenceRedirect extends FtSequenceRedirect
|
|
|
42
43
|
super.loadMeta(metaSequenceRedirect, metaSequenceList, sequenceList);
|
|
43
44
|
|
|
44
45
|
this._value = metaSequenceRedirect.value;
|
|
46
|
+
this._lowerCaseValue = this._value.toLowerCase();
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FtUnreachableCaseError } from '../
|
|
2
|
-
import { FtTextReader } from './ft-text-reader.js';
|
|
1
|
+
import { FtUnreachableCaseError } from '../utils/ft-internal-error.js';
|
|
2
|
+
import { FtTextReader } from './text-reader/ft-text-reader.js';
|
|
3
3
|
|
|
4
4
|
const State = {
|
|
5
5
|
Read: 'Read',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FtUnreachableCaseError } from '../
|
|
1
|
+
import { FtUnreachableCaseError } from '../utils/ft-internal-error.js';
|
|
2
2
|
import { CharReader } from './char-reader.js';
|
|
3
3
|
import { FtDeclaredParameters } from './ft-declared-parameters.js';
|
|
4
4
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FtField } from '../fields/instances/ft-field.js';
|
|
2
2
|
import { FtQuotedType } from '../types/enums/ft-quoted-type.js';
|
|
3
3
|
import { CharReader } from './char-reader.js';
|
|
4
|
-
import {
|
|
4
|
+
import { FtSerializationCore } from './ft-serialization-core.js';
|
|
5
5
|
|
|
6
6
|
const QuotedState = {
|
|
7
7
|
NeverOpen: 'NeverOpen',
|
|
@@ -23,7 +23,7 @@ type QuotedState = (typeof QuotedState)[keyof typeof QuotedState];
|
|
|
23
23
|
export class DelimitedFieldParser {
|
|
24
24
|
private readonly _headings: boolean;
|
|
25
25
|
private readonly _charReader: CharReader;
|
|
26
|
-
private readonly _core:
|
|
26
|
+
private readonly _core: FtSerializationCore;
|
|
27
27
|
private _textBuilder: string[] = [];
|
|
28
28
|
|
|
29
29
|
private _field: FtField | undefined = undefined;
|
|
@@ -39,7 +39,7 @@ export class DelimitedFieldParser {
|
|
|
39
39
|
private _rawOffset = -1;
|
|
40
40
|
private _rawLength = 0;
|
|
41
41
|
|
|
42
|
-
constructor(core:
|
|
42
|
+
constructor(core: FtSerializationCore, charReader: CharReader, forHeadings: boolean) {
|
|
43
43
|
this._headings = forHeadings;
|
|
44
44
|
this._charReader = charReader;
|
|
45
45
|
this._core = core;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FtField } from '../fields/instances/ft-field.js';
|
|
2
2
|
import { FtPadCharType } from '../types/enums/ft-pad-char-type.js';
|
|
3
|
-
import { FtAssertError, FtUnreachableCaseError } from '../
|
|
3
|
+
import { FtAssertError, FtUnreachableCaseError } from '../utils/ft-internal-error.js';
|
|
4
4
|
import { CharReader } from './char-reader.js';
|
|
5
|
-
import {
|
|
5
|
+
import { FtSerializationCore } from './ft-serialization-core.js';
|
|
6
6
|
|
|
7
7
|
const State = {
|
|
8
8
|
WaitingLeftEndOfValue: 'WaitingLeftEndOfValue',
|
|
@@ -24,7 +24,7 @@ type State = (typeof State)[keyof typeof State];
|
|
|
24
24
|
export class FixedWidthFieldParser {
|
|
25
25
|
private readonly _headings: boolean;
|
|
26
26
|
private readonly _charReader: CharReader;
|
|
27
|
-
private readonly _core:
|
|
27
|
+
private readonly _core: FtSerializationCore;
|
|
28
28
|
private _textBuilder: string[] = [];
|
|
29
29
|
|
|
30
30
|
private _state: State = State.NoMorePadding;
|
|
@@ -42,7 +42,7 @@ export class FixedWidthFieldParser {
|
|
|
42
42
|
private _fieldPadChar = '';
|
|
43
43
|
private _rightPaddingCharCount = 0;
|
|
44
44
|
|
|
45
|
-
constructor(core:
|
|
45
|
+
constructor(core: FtSerializationCore, charReader: CharReader, forHeadings: boolean) {
|
|
46
46
|
this._headings = forHeadings;
|
|
47
47
|
this._charReader = charReader;
|
|
48
48
|
this._core = core;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Err, isStringifiedInteger, Ok, Result } from '@pbkware/js-utils';
|
|
2
1
|
import { FtMetaReferenceType } from '../types/enums/ft-meta-reference-type.js';
|
|
3
|
-
import { FtUnreachableCaseError } from '../
|
|
2
|
+
import { FtUnreachableCaseError } from '../utils/ft-internal-error.js';
|
|
3
|
+
import { FtErr, FtOk, FtResult } from '../utils/ft-result.js';
|
|
4
|
+
import { isStringifiedInteger } from '../utils/number-parse.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Parameter record for declared parameters.
|
|
@@ -82,12 +83,12 @@ export class FtDeclaredParameters {
|
|
|
82
83
|
this.add(FtDeclaredParameters.VERSION_PARAMETER_NAME, this.versionToText(major, minor, comment));
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
tryGetVersion():
|
|
86
|
+
tryGetVersion(): FtResult<Version, boolean> {
|
|
86
87
|
const idx = this.indexOfVersion();
|
|
87
88
|
if (idx >= 0) {
|
|
88
89
|
return this.parseVersionValue(this._list[idx].value);
|
|
89
90
|
} else {
|
|
90
|
-
return new
|
|
91
|
+
return new FtErr(false);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -173,10 +174,10 @@ export class FtDeclaredParameters {
|
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
private parseVersionValue(text: string):
|
|
177
|
+
private parseVersionValue(text: string): FtResult<Version, boolean> {
|
|
177
178
|
const majorMinorSeparatorIdx = text.indexOf(FtDeclaredParameters.VERSION_PARTS_SEPARATOR);
|
|
178
179
|
if (majorMinorSeparatorIdx <= 0 || majorMinorSeparatorIdx >= text.length - 1) {
|
|
179
|
-
return new
|
|
180
|
+
return new FtErr(false);
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
let minorCommentSeparatorIdx = text.indexOf(FtDeclaredParameters.VERSION_PARTS_SEPARATOR, majorMinorSeparatorIdx + 1);
|
|
@@ -204,22 +205,22 @@ export class FtDeclaredParameters {
|
|
|
204
205
|
return minorResult.createType();
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
return new
|
|
208
|
+
return new FtOk({
|
|
208
209
|
major: majorResult.value,
|
|
209
210
|
minor: minorResult.value,
|
|
210
211
|
comment,
|
|
211
212
|
});
|
|
212
213
|
}
|
|
213
214
|
|
|
214
|
-
private parseMajorMinorVersionText(text: string):
|
|
215
|
+
private parseMajorMinorVersionText(text: string): FtResult<number, boolean> {
|
|
215
216
|
if (!isStringifiedInteger(text)) {
|
|
216
|
-
return new
|
|
217
|
+
return new FtErr(false);
|
|
217
218
|
} else {
|
|
218
219
|
const result = parseInt(text, 10);
|
|
219
220
|
if (Number.isNaN(result)) {
|
|
220
|
-
return new
|
|
221
|
+
return new FtErr(false);
|
|
221
222
|
} else {
|
|
222
|
-
return new
|
|
223
|
+
return new FtOk(result);
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
}
|
|
@@ -19,22 +19,22 @@ import { FtQuotedType } from '../types/enums/ft-quoted-type.js';
|
|
|
19
19
|
import { FtSequenceInvokationDelay } from '../types/enums/ft-sequence-invokation-delay.js';
|
|
20
20
|
import { FtSubstitutionType } from '../types/enums/ft-substitution-type.js';
|
|
21
21
|
import { FtTruncateType } from '../types/enums/ft-truncate-type.js';
|
|
22
|
-
import { FtUnreachableCaseError } from '../
|
|
23
|
-
import { FtFieldHeadingReadyEventArgs } from '../types/events/ft-field-heading-ready-event-args.js';
|
|
24
|
-
import { FtFieldValueReadyEventArgs } from '../types/events/ft-field-value-ready-event-args.js';
|
|
25
|
-
import { FtHeadingLineFinishedEventArgs } from '../types/events/ft-heading-line-finished-event-args.js';
|
|
26
|
-
import { FtHeadingLineStartedEventArgs } from '../types/events/ft-heading-line-started-event-args.js';
|
|
27
|
-
import { FtRecordFinishedEventArgs } from '../types/events/ft-record-finished-event-args.js';
|
|
28
|
-
import { FtRecordStartedEventArgs } from '../types/events/ft-record-started-event-args.js';
|
|
29
|
-
import { FtSequenceRedirectedEventArgs } from '../types/events/ft-sequence-redirected-event-args.js';
|
|
22
|
+
import { FtUnreachableCaseError } from '../utils/ft-internal-error.js';
|
|
30
23
|
import { CharReader } from './char-reader.js';
|
|
24
|
+
import { FtFieldHeadingReadyEventArgs } from './events/ft-field-heading-ready-event-args.js';
|
|
25
|
+
import { FtFieldValueReadyEventArgs } from './events/ft-field-value-ready-event-args.js';
|
|
26
|
+
import { FtHeadingLineFinishedEventArgs } from './events/ft-heading-line-finished-event-args.js';
|
|
27
|
+
import { FtHeadingLineStartedEventArgs } from './events/ft-heading-line-started-event-args.js';
|
|
28
|
+
import { FtRecordFinishedEventArgs } from './events/ft-record-finished-event-args.js';
|
|
29
|
+
import { FtRecordStartedEventArgs } from './events/ft-record-started-event-args.js';
|
|
30
|
+
import { FtSequenceRedirectedEventArgs } from './events/ft-sequence-redirected-event-args.js';
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Base class for serialization (reading/writing).
|
|
34
34
|
* Manages configuration, field lists, sequences, and events.
|
|
35
35
|
* @public
|
|
36
36
|
*/
|
|
37
|
-
export abstract class
|
|
37
|
+
export abstract class FtSerializationCore {
|
|
38
38
|
static readonly VersionMajor = 1;
|
|
39
39
|
static readonly VersionMinor = 1;
|
|
40
40
|
static readonly PrefixSpaceChar = ' ';
|
|
@@ -227,38 +227,154 @@ export abstract class SerializationCore {
|
|
|
227
227
|
return this._headingEndOfValueChar;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Number of fields in the current record.
|
|
232
|
+
*
|
|
233
|
+
* IDataReader member
|
|
234
|
+
*/
|
|
231
235
|
get fieldCount(): number {
|
|
232
236
|
return this._fieldList.count;
|
|
233
237
|
}
|
|
234
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Number of sequences currently invoked (depth of sequence invokation stack).
|
|
241
|
+
*
|
|
242
|
+
* IDataReader member
|
|
243
|
+
*/
|
|
235
244
|
get depth(): number {
|
|
236
245
|
return this._sequenceInvokationList.count;
|
|
237
246
|
}
|
|
238
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Whether the reader/writer is closed.
|
|
250
|
+
*
|
|
251
|
+
* IDataReader member
|
|
252
|
+
*/
|
|
239
253
|
abstract get isClosed(): boolean;
|
|
240
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Name of the field at the given index.
|
|
257
|
+
* Alias for {@link getFieldName}.
|
|
258
|
+
*
|
|
259
|
+
* IDataReader member
|
|
260
|
+
*/
|
|
241
261
|
getName(idx: number): string {
|
|
242
262
|
return this._fieldList.get(idx).name;
|
|
243
263
|
}
|
|
244
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Get a index of field in record by its name.
|
|
267
|
+
*
|
|
268
|
+
* IDataReader member
|
|
269
|
+
* @throws Error if the field is not found.
|
|
270
|
+
*/
|
|
245
271
|
getOrdinal(name: string): number {
|
|
272
|
+
const result = this.getFieldIndexByName(name);
|
|
273
|
+
if (result === undefined) {
|
|
274
|
+
throw new Error(`Field not found: ${name}`);
|
|
275
|
+
} else {
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Whether the field value at the given index is null.
|
|
282
|
+
* Alias for {@link isFieldNull}.
|
|
283
|
+
*
|
|
284
|
+
* IDataReader member
|
|
285
|
+
*/
|
|
286
|
+
isDBNull(idx: number): boolean {
|
|
287
|
+
return this.isFieldNull(idx);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Get a FtField object at index.
|
|
292
|
+
*/
|
|
293
|
+
getField(idx: number): FtField {
|
|
294
|
+
return this._fieldList.get(idx);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Get a FtField object by name.
|
|
299
|
+
*/
|
|
300
|
+
getFieldByName(name: string): FtField | undefined {
|
|
301
|
+
return this._fieldList.getByName(name);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Get a index of field in record by its name.
|
|
306
|
+
* @throws Error if the field is not found.
|
|
307
|
+
*/
|
|
308
|
+
getFieldIndexByName(name: string): number | undefined {
|
|
246
309
|
const result = this._fieldList.indexOfName(name);
|
|
247
310
|
if (result >= 0) {
|
|
248
311
|
return result;
|
|
249
312
|
} else {
|
|
250
|
-
|
|
313
|
+
return undefined;
|
|
251
314
|
}
|
|
252
315
|
}
|
|
253
316
|
|
|
254
|
-
|
|
255
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Get the name of the field at the given index.
|
|
319
|
+
*/
|
|
320
|
+
getFieldName(idx: number): string {
|
|
321
|
+
return this._fieldList.get(idx).name;
|
|
256
322
|
}
|
|
257
323
|
|
|
258
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Get a field value by index.
|
|
326
|
+
* @throws FtFieldNullError if the field value is null.
|
|
327
|
+
*/
|
|
328
|
+
getFieldValue(idx: number): FtField.Value | null {
|
|
329
|
+
return this._fieldList.get(idx).value;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Whether the field value at the given index is null.
|
|
334
|
+
*/
|
|
335
|
+
isFieldNull(idx: number): boolean {
|
|
259
336
|
return this._fieldList.get(idx).isNull();
|
|
260
337
|
}
|
|
261
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Get the value type of the field at the given index.
|
|
341
|
+
*/
|
|
342
|
+
getFieldValueType(idx: number): string {
|
|
343
|
+
return this._fieldList.get(idx).valueType;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get a field value by index. Returns `null` if the field value is null.
|
|
348
|
+
*/
|
|
349
|
+
getFieldNullableValue(idx: number): FtField.Value | null {
|
|
350
|
+
return this._fieldList.get(idx).nullableValue;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Get a field value by name.
|
|
355
|
+
* @throws FtFieldNullError if the field value is null.
|
|
356
|
+
* @throws Error if the field is not found.
|
|
357
|
+
*/
|
|
358
|
+
getFieldValueByName(name: string): FtField.Value | null {
|
|
359
|
+
const field = this._fieldList.getByName(name);
|
|
360
|
+
if (!field) {
|
|
361
|
+
throw new Error(`Field not found: ${name}`);
|
|
362
|
+
}
|
|
363
|
+
return field.value;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Get a field value by name. Returns `null` if the field value is null.
|
|
368
|
+
* @throws Error if the field is not found.
|
|
369
|
+
*/
|
|
370
|
+
getFieldNullableValueByName(name: string): FtField.Value | null {
|
|
371
|
+
const field = this._fieldList.getByName(name);
|
|
372
|
+
if (!field) {
|
|
373
|
+
throw new Error(`Field not found: ${name}`);
|
|
374
|
+
}
|
|
375
|
+
return field.nullableValue;
|
|
376
|
+
}
|
|
377
|
+
|
|
262
378
|
tryGetSubstitutionValue(token: string): { found: boolean; value: string } {
|
|
263
379
|
return this._substitutionList.tryGetValue(token);
|
|
264
380
|
}
|
|
@@ -616,11 +732,11 @@ export abstract class SerializationCore {
|
|
|
616
732
|
private calculateAutoEndOfLineSubstitutionValue(): string {
|
|
617
733
|
switch (this._endOfLineAutoWriteType) {
|
|
618
734
|
case FtEndOfLineAutoWriteType.CrLf:
|
|
619
|
-
return
|
|
735
|
+
return FtSerializationCore.CarriageReturnLineFeedString;
|
|
620
736
|
case FtEndOfLineAutoWriteType.Cr:
|
|
621
|
-
return
|
|
737
|
+
return FtSerializationCore.CarriageReturnChar;
|
|
622
738
|
case FtEndOfLineAutoWriteType.Lf:
|
|
623
|
-
return
|
|
739
|
+
return FtSerializationCore.LineFeedChar;
|
|
624
740
|
case FtEndOfLineAutoWriteType.Local:
|
|
625
741
|
return '\n';
|
|
626
742
|
default:
|
package/src/{types/errors/ft-serialization-error.ts → serialization/ft-serialization-error-code.ts}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Enumeration of serialization error codes.
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
-
export const
|
|
5
|
+
export const FtSerializationErrorCode = {
|
|
6
6
|
Abort: 'Abort',
|
|
7
7
|
DeclarationParameterNameIsZeroLength: 'DeclarationParameterNameIsZeroLength',
|
|
8
8
|
DeclaredParameterNameContainsSeparator: 'DeclaredParameterNameContainsSeparator',
|
|
@@ -50,4 +50,4 @@ export const FtSerializationError = {
|
|
|
50
50
|
/**
|
|
51
51
|
* @public
|
|
52
52
|
*/
|
|
53
|
-
export type
|
|
53
|
+
export type FtSerializationErrorCode = (typeof FtSerializationErrorCode)[keyof typeof FtSerializationErrorCode];
|
package/src/{types/errors/ft-serialization-exception.ts → serialization/ft-serialization-error.ts}
RENAMED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { FtField } from '
|
|
2
|
-
import {
|
|
1
|
+
import { FtField } from '../fields/instances/ft-field.js';
|
|
2
|
+
import { FtSerializationErrorCode } from './ft-serialization-error-code.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Exception thrown during fielded text serialization/deserialization.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export class
|
|
9
|
-
private readonly _error:
|
|
8
|
+
export class FtSerializationError extends Error {
|
|
9
|
+
private readonly _error: FtSerializationErrorCode;
|
|
10
10
|
private readonly _fieldName: string | undefined;
|
|
11
11
|
private readonly _fieldIndex: number;
|
|
12
12
|
private readonly _sequenceName: string | undefined;
|
|
13
13
|
private readonly _sequenceItemIndex: number;
|
|
14
14
|
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(
|
|
16
|
+
errorCode: FtSerializationErrorCode,
|
|
17
|
+
fieldOrMessage: FtField | string | undefined,
|
|
18
|
+
messageOrInner?: string | Error,
|
|
19
|
+
innerException?: Error,
|
|
20
|
+
) {
|
|
16
21
|
let message: string;
|
|
17
22
|
let field: FtField | undefined = undefined;
|
|
18
23
|
let inner: Error | undefined = undefined;
|
|
@@ -38,12 +43,12 @@ export class FtSerializationException extends Error {
|
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
const errorName =
|
|
46
|
+
const errorName = FtSerializationErrorCode[errorCode];
|
|
42
47
|
const fullMessage = errorName + (message ? ': ' + message : '');
|
|
43
48
|
super(fullMessage);
|
|
44
49
|
|
|
45
|
-
this.name = '
|
|
46
|
-
this._error =
|
|
50
|
+
this.name = 'FtSerializationError';
|
|
51
|
+
this._error = errorCode;
|
|
47
52
|
|
|
48
53
|
if (field === undefined) {
|
|
49
54
|
this._fieldName = undefined;
|
|
@@ -64,7 +69,7 @@ export class FtSerializationException extends Error {
|
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
get error():
|
|
72
|
+
get error(): FtSerializationErrorCode {
|
|
68
73
|
return this._error;
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FtField } from '../fields/instances/ft-field.js';
|
|
2
1
|
import { FtMetaSerialization } from '../meta-serialization/ft-meta-serialization.js';
|
|
3
2
|
import { FtMeta } from '../meta/ft-meta.js';
|
|
4
3
|
import { FtLastLineEndedType } from '../types/enums/ft-last-line-ended-type.js';
|
|
@@ -6,23 +5,23 @@ import { FtLineType } from '../types/enums/ft-line-type.js';
|
|
|
6
5
|
import { FtMetaReferenceType } from '../types/enums/ft-meta-reference-type.js';
|
|
7
6
|
import { FtMetaSerializationFormat } from '../types/enums/ft-meta-serialization-format.js';
|
|
8
7
|
import { FtReadRecordResult } from '../types/enums/ft-read-record-result.js';
|
|
9
|
-
import { FtUnreachableCaseError } from '../
|
|
10
|
-
import { FtSerializationError } from '../types/errors/ft-serialization-error.js';
|
|
11
|
-
import { FtSerializationException } from '../types/errors/ft-serialization-exception.js';
|
|
8
|
+
import { FtUnreachableCaseError } from '../utils/ft-internal-error.js';
|
|
12
9
|
import { CharReader } from './char-reader.js';
|
|
13
10
|
import { DeclarationParser } from './declaration-parser.js';
|
|
14
11
|
import { EmbeddedMetaParser } from './embedded-meta-parser.js';
|
|
15
12
|
import { FtDeclaredParameters } from './ft-declared-parameters.js';
|
|
16
|
-
import {
|
|
13
|
+
import { FtSerializationCore } from './ft-serialization-core.js';
|
|
14
|
+
import { FtSerializationErrorCode } from './ft-serialization-error-code.js';
|
|
15
|
+
import { FtSerializationError } from './ft-serialization-error.js';
|
|
17
16
|
import { HeadingLineRecordParser } from './heading-line-record-parser.js';
|
|
18
17
|
import { LineEndedType, LineParser } from './line-parser.js';
|
|
19
|
-
import {
|
|
18
|
+
import { FtTextReader } from './text-reader/ft-text-reader.js';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Reader for fielded text streams. Coordinates all parsing components.
|
|
23
22
|
* @public
|
|
24
23
|
*/
|
|
25
|
-
export class FtSerializationReader extends
|
|
24
|
+
export class FtSerializationReader extends FtSerializationCore {
|
|
26
25
|
/**
|
|
27
26
|
* Event fired when seeking through records.
|
|
28
27
|
*/
|
|
@@ -396,38 +395,6 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
396
395
|
}
|
|
397
396
|
}
|
|
398
397
|
|
|
399
|
-
/**
|
|
400
|
-
* Get a field object by index.
|
|
401
|
-
*/
|
|
402
|
-
getField(idx: number): FtField {
|
|
403
|
-
return this.fieldList.get(idx);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Get a field object by name.
|
|
408
|
-
*/
|
|
409
|
-
getFieldByName(name: string): FtField | undefined {
|
|
410
|
-
return this.fieldList.getByName(name);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Get a field value by index.
|
|
415
|
-
*/
|
|
416
|
-
getFieldValue(idx: number): unknown {
|
|
417
|
-
return this.fieldList.get(idx).asObject;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Get a field value by name.
|
|
422
|
-
*/
|
|
423
|
-
getFieldValueByName(name: string): unknown {
|
|
424
|
-
const field = this.fieldList.getByName(name);
|
|
425
|
-
if (!field) {
|
|
426
|
-
throw new Error(`Field not found: ${name}`);
|
|
427
|
-
}
|
|
428
|
-
return field.asObject;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
398
|
/**
|
|
432
399
|
* Load metadata from a pre-parsed FtMeta object.
|
|
433
400
|
* @param meta - The metadata to load.
|
|
@@ -483,8 +450,8 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
483
450
|
protected getFileMetaAsText(fileMetaReference: string): FtSerializationReader.FileMetaAsTextResult | string {
|
|
484
451
|
// Descendants can override this method. Clients can subscribe to onRequireFileMetaAsText event
|
|
485
452
|
if (!this.onRequireFileMetaAsText) {
|
|
486
|
-
throw new
|
|
487
|
-
|
|
453
|
+
throw new FtSerializationError(
|
|
454
|
+
FtSerializationErrorCode.MetaReferenceFileNoHandler,
|
|
488
455
|
'Meta reference is file but no handler provided to retrieve file content',
|
|
489
456
|
);
|
|
490
457
|
} else {
|
|
@@ -495,8 +462,8 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
495
462
|
protected getUrlMetaAsText(urlMetaReference: string): FtSerializationReader.FileMetaAsTextResult | string {
|
|
496
463
|
// Descendants can override this method. Clients can subscribe to onRequireUrlMetaAsText event
|
|
497
464
|
if (!this.onRequireUrlMetaAsText) {
|
|
498
|
-
throw new
|
|
499
|
-
|
|
465
|
+
throw new FtSerializationError(
|
|
466
|
+
FtSerializationErrorCode.MetaReferenceUrlNoHandler,
|
|
500
467
|
'Meta reference is URL but no handler provided to retrieve URL content',
|
|
501
468
|
);
|
|
502
469
|
} else {
|
|
@@ -609,7 +576,7 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
609
576
|
// Must be a heading line
|
|
610
577
|
this._lineType = FtLineType.Heading;
|
|
611
578
|
if (this._metaEmbedded && !this._embeddedMetaRead) {
|
|
612
|
-
throw new
|
|
579
|
+
throw new FtSerializationError(FtSerializationErrorCode.EmbeddedMetaNotFound, 'Embedded meta line not blank or comment');
|
|
613
580
|
} else {
|
|
614
581
|
if (!(this.headingLineCount > 0 && !this._headingLinesRead)) {
|
|
615
582
|
throw new Error('Unexpected heading line state');
|
|
@@ -637,7 +604,7 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
637
604
|
this._recordParser.parseChar(aChar);
|
|
638
605
|
} else {
|
|
639
606
|
if (!this.ignoreBlankLines) {
|
|
640
|
-
throw new
|
|
607
|
+
throw new FtSerializationError(FtSerializationErrorCode.RecordNotEnoughFields, 'Blank records not allowed');
|
|
641
608
|
}
|
|
642
609
|
}
|
|
643
610
|
}
|
|
@@ -722,7 +689,7 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
722
689
|
this.finishLastLine();
|
|
723
690
|
|
|
724
691
|
if (this.lastLineEndedType === FtLastLineEndedType.Always) {
|
|
725
|
-
throw new
|
|
692
|
+
throw new FtSerializationError(FtSerializationErrorCode.LastLineEndedError, 'Always ended but in line');
|
|
726
693
|
} else {
|
|
727
694
|
this._lineParser.exitLine();
|
|
728
695
|
result = true;
|
|
@@ -732,17 +699,17 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
732
699
|
result = false;
|
|
733
700
|
} else {
|
|
734
701
|
if (!this.ignoreBlankLines) {
|
|
735
|
-
throw new
|
|
702
|
+
throw new FtSerializationError(FtSerializationErrorCode.LastLineEndedError, 'Never ended but out of line');
|
|
736
703
|
} else {
|
|
737
704
|
// Since last line cannot be ended, there is another ignored blank line
|
|
738
705
|
|
|
739
706
|
// Throw exception if blank line not allowed
|
|
740
707
|
switch (this._lineType) {
|
|
741
708
|
case FtLineType.Signature:
|
|
742
|
-
throw new
|
|
709
|
+
throw new FtSerializationError(FtSerializationErrorCode.IncompleteDeclaration, 'Declaration missing second line');
|
|
743
710
|
case FtLineType.Heading:
|
|
744
711
|
if (!this._headingLinesRead) {
|
|
745
|
-
throw new
|
|
712
|
+
throw new FtSerializationError(FtSerializationErrorCode.InsufficientHeadingLines, '');
|
|
746
713
|
}
|
|
747
714
|
break;
|
|
748
715
|
}
|
|
@@ -779,7 +746,7 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
779
746
|
case FtLineType.Comment:
|
|
780
747
|
if (!this._headerRead) {
|
|
781
748
|
if (this._metaEmbedded && !this._embeddedMetaRead) {
|
|
782
|
-
throw new
|
|
749
|
+
throw new FtSerializationError(FtSerializationErrorCode.EmbeddedMetaNotFound, 'End of file encountered');
|
|
783
750
|
}
|
|
784
751
|
}
|
|
785
752
|
break;
|
|
@@ -788,7 +755,7 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
788
755
|
if (this._embeddedMetaParser.ready) {
|
|
789
756
|
this.finishEmbeddedMeta();
|
|
790
757
|
} else {
|
|
791
|
-
throw new
|
|
758
|
+
throw new FtSerializationError(FtSerializationErrorCode.IncompleteEmbeddedMeta, 'End of file encountered');
|
|
792
759
|
}
|
|
793
760
|
break;
|
|
794
761
|
|
|
@@ -916,13 +883,13 @@ export class FtSerializationReader extends SerializationCore {
|
|
|
916
883
|
private checkCompleteness(): void {
|
|
917
884
|
if (!this._headerRead) {
|
|
918
885
|
if (this._declared && !this._declarationRead) {
|
|
919
|
-
throw new
|
|
886
|
+
throw new FtSerializationError(FtSerializationErrorCode.IncompleteDeclaration, '');
|
|
920
887
|
} else {
|
|
921
888
|
if (this._metaEmbedded && !this._embeddedMetaRead) {
|
|
922
|
-
throw new
|
|
889
|
+
throw new FtSerializationError(FtSerializationErrorCode.IncompleteEmbeddedMeta, '');
|
|
923
890
|
} else {
|
|
924
891
|
if (this.headingLineCount > 0 && !this._headingLinesRead) {
|
|
925
|
-
throw new
|
|
892
|
+
throw new FtSerializationError(FtSerializationErrorCode.InsufficientHeadingLines, this._headingLineReadCount.toString());
|
|
926
893
|
}
|
|
927
894
|
}
|
|
928
895
|
}
|