@pbkware/fielded-text-web 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/ft-reader.js +59 -0
- package/dist/api/ft-reader.js.map +1 -0
- package/dist/api/ft-serialization.js +147 -0
- package/dist/api/ft-serialization.js.map +1 -0
- package/dist/api/ft-writer-settings.js +31 -0
- package/dist/api/ft-writer-settings.js.map +1 -0
- package/dist/api/ft-writer.js +22 -0
- package/dist/api/ft-writer.js.map +1 -0
- package/dist/factory/ft-field-factory.js +86 -0
- package/dist/factory/ft-field-factory.js.map +1 -0
- package/dist/factory/ft-meta-constructor.js +16 -0
- package/dist/factory/ft-meta-constructor.js.map +1 -0
- package/dist/factory/ft-meta-factory.js +30 -0
- package/dist/factory/ft-meta-factory.js.map +1 -0
- package/dist/factory/ft-sequence-constructor.js +11 -0
- package/dist/factory/ft-sequence-constructor.js.map +1 -0
- package/dist/factory/ft-sequence-factory.js +18 -0
- package/dist/factory/ft-sequence-factory.js.map +1 -0
- package/dist/factory/ft-sequence-item-constructor.js +11 -0
- package/dist/factory/ft-sequence-item-constructor.js.map +1 -0
- package/dist/factory/ft-sequence-item-factory.js +18 -0
- package/dist/factory/ft-sequence-item-factory.js.map +1 -0
- package/dist/factory/ft-sequence-redirect-constructor.js +13 -0
- package/dist/factory/ft-sequence-redirect-constructor.js.map +1 -0
- package/dist/factory/ft-sequence-redirect-factory.js +176 -0
- package/dist/factory/ft-sequence-redirect-factory.js.map +1 -0
- package/dist/factory/ft-substitution-constructor.js +23 -0
- package/dist/factory/ft-substitution-constructor.js.map +1 -0
- package/dist/factory/ft-substitution-factory.js +37 -0
- package/dist/factory/ft-substitution-factory.js.map +1 -0
- package/dist/fields/definitions/ft-boolean-field-definition.js +36 -0
- package/dist/fields/definitions/ft-boolean-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-date-time-field-definition.js +39 -0
- package/dist/fields/definitions/ft-date-time-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-decimal-field-definition.js +32 -0
- package/dist/fields/definitions/ft-decimal-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-field-definition-list.js +26 -0
- package/dist/fields/definitions/ft-field-definition-list.js.map +1 -0
- package/dist/fields/definitions/ft-field-definition.js +245 -0
- package/dist/fields/definitions/ft-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-float-field-definition.js +32 -0
- package/dist/fields/definitions/ft-float-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-generic-field-definition.js +30 -0
- package/dist/fields/definitions/ft-generic-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-integer-field-definition.js +33 -0
- package/dist/fields/definitions/ft-integer-field-definition.js.map +1 -0
- package/dist/fields/definitions/ft-string-field-definition.js +21 -0
- package/dist/fields/definitions/ft-string-field-definition.js.map +1 -0
- package/dist/fields/instances/ft-boolean-field.js +38 -0
- package/dist/fields/instances/ft-boolean-field.js.map +1 -0
- package/dist/fields/instances/ft-date-time-field.js +35 -0
- package/dist/fields/instances/ft-date-time-field.js.map +1 -0
- package/dist/fields/instances/ft-decimal-field.js +35 -0
- package/dist/fields/instances/ft-decimal-field.js.map +1 -0
- package/dist/fields/instances/ft-field-list.js +56 -0
- package/dist/fields/instances/ft-field-list.js.map +1 -0
- package/dist/fields/instances/ft-field.js +561 -0
- package/dist/fields/instances/ft-field.js.map +1 -0
- package/dist/fields/instances/ft-float-field.js +35 -0
- package/dist/fields/instances/ft-float-field.js.map +1 -0
- package/dist/fields/instances/ft-generic-field.js +173 -0
- package/dist/fields/instances/ft-generic-field.js.map +1 -0
- package/dist/fields/instances/ft-integer-field.js +35 -0
- package/dist/fields/instances/ft-integer-field.js.map +1 -0
- package/dist/fields/instances/ft-string-field.js +34 -0
- package/dist/fields/instances/ft-string-field.js.map +1 -0
- package/dist/index.d.ts +3483 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/fields/ft-boolean-meta-field.js +65 -0
- package/dist/meta/fields/ft-boolean-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-date-time-meta-field.js +55 -0
- package/dist/meta/fields/ft-date-time-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-decimal-meta-field.js +55 -0
- package/dist/meta/fields/ft-decimal-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-float-meta-field.js +55 -0
- package/dist/meta/fields/ft-float-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-generic-meta-field.js +32 -0
- package/dist/meta/fields/ft-generic-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-integer-meta-field.js +55 -0
- package/dist/meta/fields/ft-integer-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-meta-field-list.js +183 -0
- package/dist/meta/fields/ft-meta-field-list.js.map +1 -0
- package/dist/meta/fields/ft-meta-field.js +351 -0
- package/dist/meta/fields/ft-meta-field.js.map +1 -0
- package/dist/meta/fields/ft-string-meta-field.js +27 -0
- package/dist/meta/fields/ft-string-meta-field.js.map +1 -0
- package/dist/meta/ft-meta-defaults.js +152 -0
- package/dist/meta/ft-meta-defaults.js.map +1 -0
- package/dist/meta/ft-meta.js +391 -0
- package/dist/meta/ft-meta.js.map +1 -0
- package/dist/meta/sequences/core/ft-meta-sequence-item-list.js +82 -0
- package/dist/meta/sequences/core/ft-meta-sequence-item-list.js.map +1 -0
- package/dist/meta/sequences/core/ft-meta-sequence-item.js +62 -0
- package/dist/meta/sequences/core/ft-meta-sequence-item.js.map +1 -0
- package/dist/meta/sequences/core/ft-meta-sequence-list.js +164 -0
- package/dist/meta/sequences/core/ft-meta-sequence-list.js.map +1 -0
- package/dist/meta/sequences/core/ft-meta-sequence.js +96 -0
- package/dist/meta/sequences/core/ft-meta-sequence.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-boolean-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-boolean-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-case-insensitive-string-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-case-insensitive-string-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-date-meta-sequence-redirect.js +45 -0
- package/dist/meta/sequences/redirects/ft-date-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-exact-date-time-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-exact-date-time-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-exact-decimal-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-exact-decimal-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-exact-float-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-exact-float-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-exact-integer-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-exact-integer-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-exact-string-meta-sequence-redirect.js +40 -0
- package/dist/meta/sequences/redirects/ft-exact-string-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-meta-sequence-redirect-list.js +85 -0
- package/dist/meta/sequences/redirects/ft-meta-sequence-redirect-list.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-meta-sequence-redirect.js +68 -0
- package/dist/meta/sequences/redirects/ft-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/sequences/redirects/ft-null-meta-sequence-redirect.js +21 -0
- package/dist/meta/sequences/redirects/ft-null-meta-sequence-redirect.js.map +1 -0
- package/dist/meta/substitutions/ft-meta-substitution-list.js +51 -0
- package/dist/meta/substitutions/ft-meta-substitution-list.js.map +1 -0
- package/dist/meta-serialization/format/ft-json-meta-serialization.js +283 -0
- package/dist/meta-serialization/format/ft-json-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/format/ft-xml-meta-serialization.js +706 -0
- package/dist/meta-serialization/format/ft-xml-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/format/meta-serializer-options.js +12 -0
- package/dist/meta-serialization/format/meta-serializer-options.js.map +1 -0
- package/dist/meta-serialization/ft-meta-serialization.js +59 -0
- package/dist/meta-serialization/ft-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/styles/ft-boolean-styles-meta-serialization.js +83 -0
- package/dist/meta-serialization/styles/ft-boolean-styles-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/styles/ft-date-time-styles-meta-serialization.js +54 -0
- package/dist/meta-serialization/styles/ft-date-time-styles-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/styles/ft-number-styles-meta-serialization.js +199 -0
- package/dist/meta-serialization/styles/ft-number-styles-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/boolean-meta-serialization.js +39 -0
- package/dist/meta-serialization/types/boolean-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/char-meta-serialization.js +32 -0
- package/dist/meta-serialization/types/char-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/date-time-meta-serialization.js +227 -0
- package/dist/meta-serialization/types/date-time-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/decimal-meta-serialization.js +12 -0
- package/dist/meta-serialization/types/decimal-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/data-type-meta-serialisation.js +55 -0
- package/dist/meta-serialization/types/enums/data-type-meta-serialisation.js.map +1 -0
- package/dist/meta-serialization/types/enums/end-of-line-auto-write-type-meta-serialization.js +50 -0
- package/dist/meta-serialization/types/enums/end-of-line-auto-write-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/end-of-line-type-meta-serialization.js +49 -0
- package/dist/meta-serialization/types/enums/end-of-line-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/heading-constraint-meta-serialization.js +55 -0
- package/dist/meta-serialization/types/enums/heading-constraint-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/last-line-ended-type-meta-serialization.js +48 -0
- package/dist/meta-serialization/types/enums/last-line-ended-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/pad-alignment-meta-serialization.js +52 -0
- package/dist/meta-serialization/types/enums/pad-alignment-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/pad-char-type-meta-serialization.js +52 -0
- package/dist/meta-serialization/types/enums/pad-char-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/quoted-type-meta-serialization.js +52 -0
- package/dist/meta-serialization/types/enums/quoted-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/sequence-invokation-delay-meta-serialization.js +47 -0
- package/dist/meta-serialization/types/enums/sequence-invokation-delay-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/sequence-redirect-type-meta-serialisation.js +88 -0
- package/dist/meta-serialization/types/enums/sequence-redirect-type-meta-serialisation.js.map +1 -0
- package/dist/meta-serialization/types/enums/substitution-type-meta-serialization.js +47 -0
- package/dist/meta-serialization/types/enums/substitution-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/enums/truncate-type-meta-serialization.js +56 -0
- package/dist/meta-serialization/types/enums/truncate-type-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/float-meta-serialization.js +99 -0
- package/dist/meta-serialization/types/float-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/integer-float-meta-serialization.js +52 -0
- package/dist/meta-serialization/types/integer-float-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/integer-meta-serialization.js +50 -0
- package/dist/meta-serialization/types/integer-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/types/string-meta-serialization.js +35 -0
- package/dist/meta-serialization/types/string-meta-serialization.js.map +1 -0
- package/dist/meta-serialization/utils/implicit-explicit-index-sorter.js +57 -0
- package/dist/meta-serialization/utils/implicit-explicit-index-sorter.js.map +1 -0
- package/dist/meta-serialization/utils/meta-serialization-redirect-sequence-resolver.js +33 -0
- package/dist/meta-serialization/utils/meta-serialization-redirect-sequence-resolver.js.map +1 -0
- package/dist/meta-serialization/utils/meta-serialization-sequence-name-resolver.js +67 -0
- package/dist/meta-serialization/utils/meta-serialization-sequence-name-resolver.js.map +1 -0
- package/dist/meta-serialization/utils/sequence-item-field-indices.js +70 -0
- package/dist/meta-serialization/utils/sequence-item-field-indices.js.map +1 -0
- package/dist/sequences/core/ft-sequence-invokation-list.js +91 -0
- package/dist/sequences/core/ft-sequence-invokation-list.js.map +1 -0
- package/dist/sequences/core/ft-sequence-invokation.js +143 -0
- package/dist/sequences/core/ft-sequence-invokation.js.map +1 -0
- package/dist/sequences/core/ft-sequence-item-list.js +34 -0
- package/dist/sequences/core/ft-sequence-item-list.js.map +1 -0
- package/dist/sequences/core/ft-sequence-item.js +46 -0
- package/dist/sequences/core/ft-sequence-item.js.map +1 -0
- package/dist/sequences/core/ft-sequence-list.js +62 -0
- package/dist/sequences/core/ft-sequence-list.js.map +1 -0
- package/dist/sequences/core/ft-sequence.js +59 -0
- package/dist/sequences/core/ft-sequence.js.map +1 -0
- package/dist/sequences/redirects/ft-boolean-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-boolean-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-case-insensitive-string-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-case-insensitive-string-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-date-sequence-redirect.js +37 -0
- package/dist/sequences/redirects/ft-date-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-exact-date-time-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-exact-date-time-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-exact-decimal-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-exact-decimal-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-exact-float-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-exact-float-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-exact-integer-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-exact-integer-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-exact-string-sequence-redirect.js +33 -0
- package/dist/sequences/redirects/ft-exact-string-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-null-sequence-redirect.js +20 -0
- package/dist/sequences/redirects/ft-null-sequence-redirect.js.map +1 -0
- package/dist/sequences/redirects/ft-sequence-redirect-list.js +35 -0
- package/dist/sequences/redirects/ft-sequence-redirect-list.js.map +1 -0
- package/dist/sequences/redirects/ft-sequence-redirect.js +47 -0
- package/dist/sequences/redirects/ft-sequence-redirect.js.map +1 -0
- package/dist/serialization/char-reader.js +178 -0
- package/dist/serialization/char-reader.js.map +1 -0
- package/dist/serialization/declaration-parser.js +176 -0
- package/dist/serialization/declaration-parser.js.map +1 -0
- package/dist/serialization/delimited-field-parser.js +278 -0
- package/dist/serialization/delimited-field-parser.js.map +1 -0
- package/dist/serialization/embedded-meta-parser.js +129 -0
- package/dist/serialization/embedded-meta-parser.js.map +1 -0
- package/dist/serialization/fixed-width-field-parser.js +196 -0
- package/dist/serialization/fixed-width-field-parser.js.map +1 -0
- package/dist/serialization/formatting/ft-boolean-field-formatter.js +113 -0
- package/dist/serialization/formatting/ft-boolean-field-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-date-time-field-formatter.js +54 -0
- package/dist/serialization/formatting/ft-date-time-field-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-decimal-field-formatter.js +46 -0
- package/dist/serialization/formatting/ft-decimal-field-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-declared-parameters-formatter.js +52 -0
- package/dist/serialization/formatting/ft-declared-parameters-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-field-formatter.js +15 -0
- package/dist/serialization/formatting/ft-field-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-float-field-formatter.js +46 -0
- package/dist/serialization/formatting/ft-float-field-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-integer-field-formatter.js +47 -0
- package/dist/serialization/formatting/ft-integer-field-formatter.js.map +1 -0
- package/dist/serialization/formatting/ft-string-field-formatter.js +14 -0
- package/dist/serialization/formatting/ft-string-field-formatter.js.map +1 -0
- package/dist/serialization/ft-declared-parameters.js +199 -0
- package/dist/serialization/ft-declared-parameters.js.map +1 -0
- package/dist/serialization/ft-serialization-reader.js +865 -0
- package/dist/serialization/ft-serialization-reader.js.map +1 -0
- package/dist/serialization/ft-serialization-writer.js +633 -0
- package/dist/serialization/ft-serialization-writer.js.map +1 -0
- package/dist/serialization/ft-text-reader.js +48 -0
- package/dist/serialization/ft-text-reader.js.map +1 -0
- package/dist/serialization/ft-text-writer.js +46 -0
- package/dist/serialization/ft-text-writer.js.map +1 -0
- package/dist/serialization/heading-line-record-parser.js +253 -0
- package/dist/serialization/heading-line-record-parser.js.map +1 -0
- package/dist/serialization/line-parser.js +205 -0
- package/dist/serialization/line-parser.js.map +1 -0
- package/dist/serialization/serialization-core.js +551 -0
- package/dist/serialization/serialization-core.js.map +1 -0
- package/dist/substitutions/ft-substitution-list.js +54 -0
- package/dist/substitutions/ft-substitution-list.js.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/enums/ft-boolean-styles.js +12 -0
- package/dist/types/enums/ft-boolean-styles.js.map +1 -0
- package/dist/types/enums/ft-data-type.js +12 -0
- package/dist/types/enums/ft-data-type.js.map +1 -0
- package/dist/types/enums/ft-end-of-line-auto-write-type.js +10 -0
- package/dist/types/enums/ft-end-of-line-auto-write-type.js.map +1 -0
- package/dist/types/enums/ft-end-of-line-type.js +9 -0
- package/dist/types/enums/ft-end-of-line-type.js.map +1 -0
- package/dist/types/enums/ft-heading-constraint.js +11 -0
- package/dist/types/enums/ft-heading-constraint.js.map +1 -0
- package/dist/types/enums/ft-last-line-ended-type.js +9 -0
- package/dist/types/enums/ft-last-line-ended-type.js.map +1 -0
- package/dist/types/enums/ft-line-type.js +13 -0
- package/dist/types/enums/ft-line-type.js.map +1 -0
- package/dist/types/enums/ft-meta-element-type.js +12 -0
- package/dist/types/enums/ft-meta-element-type.js.map +1 -0
- package/dist/types/enums/ft-meta-reference-type.js +10 -0
- package/dist/types/enums/ft-meta-reference-type.js.map +1 -0
- package/dist/types/enums/ft-meta-serialization-format.js +15 -0
- package/dist/types/enums/ft-meta-serialization-format.js.map +1 -0
- package/dist/types/enums/ft-pad-alignment.js +9 -0
- package/dist/types/enums/ft-pad-alignment.js.map +1 -0
- package/dist/types/enums/ft-pad-char-type.js +9 -0
- package/dist/types/enums/ft-pad-char-type.js.map +1 -0
- package/dist/types/enums/ft-quoted-type.js +9 -0
- package/dist/types/enums/ft-quoted-type.js.map +1 -0
- package/dist/types/enums/ft-read-record-result.js +9 -0
- package/dist/types/enums/ft-read-record-result.js.map +1 -0
- package/dist/types/enums/ft-sequence-invokation-delay.js +8 -0
- package/dist/types/enums/ft-sequence-invokation-delay.js.map +1 -0
- package/dist/types/enums/ft-sequence-redirect-type.js +15 -0
- package/dist/types/enums/ft-sequence-redirect-type.js.map +1 -0
- package/dist/types/enums/ft-substitution-type.js +12 -0
- package/dist/types/enums/ft-substitution-type.js.map +1 -0
- package/dist/types/enums/ft-truncate-type.js +11 -0
- package/dist/types/enums/ft-truncate-type.js.map +1 -0
- package/dist/types/errors/ft-internal-error.js +14 -0
- package/dist/types/errors/ft-internal-error.js.map +1 -0
- package/dist/types/errors/ft-serialization-error.js +49 -0
- package/dist/types/errors/ft-serialization-error.js.map +1 -0
- package/dist/types/errors/ft-serialization-exception.js +78 -0
- package/dist/types/errors/ft-serialization-exception.js.map +1 -0
- package/dist/types/events/ft-field-heading-ready-event-args.js +2 -0
- package/dist/types/events/ft-field-heading-ready-event-args.js.map +1 -0
- package/dist/types/events/ft-field-value-ready-event-args.js +2 -0
- package/dist/types/events/ft-field-value-ready-event-args.js.map +1 -0
- package/dist/types/events/ft-heading-line-finished-event-args.js +2 -0
- package/dist/types/events/ft-heading-line-finished-event-args.js.map +1 -0
- package/dist/types/events/ft-heading-line-started-event-args.js +2 -0
- package/dist/types/events/ft-heading-line-started-event-args.js.map +1 -0
- package/dist/types/events/ft-record-finished-event-args.js +2 -0
- package/dist/types/events/ft-record-finished-event-args.js.map +1 -0
- package/dist/types/events/ft-record-started-event-args.js +2 -0
- package/dist/types/events/ft-record-started-event-args.js.map +1 -0
- package/dist/types/events/ft-sequence-redirected-event-args.js +2 -0
- package/dist/types/events/ft-sequence-redirected-event-args.js.map +1 -0
- package/package.json +84 -0
- package/src/api/ft-reader.ts +106 -0
- package/src/api/ft-serialization.ts +216 -0
- package/src/api/ft-writer-settings.ts +76 -0
- package/src/api/ft-writer.ts +26 -0
- package/src/factory/ft-field-factory.ts +94 -0
- package/src/factory/ft-meta-constructor.ts +16 -0
- package/src/factory/ft-meta-factory.ts +34 -0
- package/src/factory/ft-sequence-constructor.ts +11 -0
- package/src/factory/ft-sequence-factory.ts +22 -0
- package/src/factory/ft-sequence-item-constructor.ts +11 -0
- package/src/factory/ft-sequence-item-factory.ts +22 -0
- package/src/factory/ft-sequence-redirect-constructor.ts +19 -0
- package/src/factory/ft-sequence-redirect-factory.ts +197 -0
- package/src/factory/ft-substitution-constructor.ts +24 -0
- package/src/factory/ft-substitution-factory.ts +43 -0
- package/src/fields/definitions/ft-boolean-field-definition.ts +49 -0
- package/src/fields/definitions/ft-date-time-field-definition.ts +52 -0
- package/src/fields/definitions/ft-decimal-field-definition.ts +43 -0
- package/src/fields/definitions/ft-field-definition-list.ts +33 -0
- package/src/fields/definitions/ft-field-definition.ts +276 -0
- package/src/fields/definitions/ft-float-field-definition.ts +43 -0
- package/src/fields/definitions/ft-generic-field-definition.ts +49 -0
- package/src/fields/definitions/ft-integer-field-definition.ts +44 -0
- package/src/fields/definitions/ft-string-field-definition.ts +26 -0
- package/src/fields/instances/ft-boolean-field.ts +49 -0
- package/src/fields/instances/ft-date-time-field.ts +44 -0
- package/src/fields/instances/ft-decimal-field.ts +44 -0
- package/src/fields/instances/ft-field-list.ts +68 -0
- package/src/fields/instances/ft-field.ts +691 -0
- package/src/fields/instances/ft-float-field.ts +44 -0
- package/src/fields/instances/ft-generic-field.ts +219 -0
- package/src/fields/instances/ft-integer-field.ts +44 -0
- package/src/fields/instances/ft-string-field.ts +40 -0
- package/src/index.ts +185 -0
- package/src/meta/fields/ft-boolean-meta-field.ts +79 -0
- package/src/meta/fields/ft-date-time-meta-field.ts +68 -0
- package/src/meta/fields/ft-decimal-meta-field.ts +68 -0
- package/src/meta/fields/ft-float-meta-field.ts +68 -0
- package/src/meta/fields/ft-generic-meta-field.ts +38 -0
- package/src/meta/fields/ft-integer-meta-field.ts +68 -0
- package/src/meta/fields/ft-meta-field-list.ts +208 -0
- package/src/meta/fields/ft-meta-field.ts +399 -0
- package/src/meta/fields/ft-string-meta-field.ts +34 -0
- package/src/meta/ft-meta-defaults.ts +151 -0
- package/src/meta/ft-meta.ts +453 -0
- package/src/meta/sequences/core/ft-meta-sequence-item-list.ts +97 -0
- package/src/meta/sequences/core/ft-meta-sequence-item.ts +78 -0
- package/src/meta/sequences/core/ft-meta-sequence-list.ts +203 -0
- package/src/meta/sequences/core/ft-meta-sequence.ts +127 -0
- package/src/meta/sequences/redirects/ft-boolean-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-case-insensitive-string-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-date-meta-sequence-redirect.ts +54 -0
- package/src/meta/sequences/redirects/ft-exact-date-time-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-exact-decimal-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-exact-float-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-exact-integer-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-exact-string-meta-sequence-redirect.ts +49 -0
- package/src/meta/sequences/redirects/ft-meta-sequence-redirect-list.ts +99 -0
- package/src/meta/sequences/redirects/ft-meta-sequence-redirect.ts +89 -0
- package/src/meta/sequences/redirects/ft-null-meta-sequence-redirect.ts +25 -0
- package/src/meta/substitutions/ft-meta-substitution-list.ts +54 -0
- package/src/meta-serialization/format/ft-json-meta-serialization.ts +288 -0
- package/src/meta-serialization/format/ft-xml-meta-serialization.ts +885 -0
- package/src/meta-serialization/format/meta-serializer-options.ts +21 -0
- package/src/meta-serialization/ft-meta-serialization.ts +60 -0
- package/src/meta-serialization/styles/ft-boolean-styles-meta-serialization.ts +88 -0
- package/src/meta-serialization/styles/ft-date-time-styles-meta-serialization.ts +50 -0
- package/src/meta-serialization/styles/ft-number-styles-meta-serialization.ts +212 -0
- package/src/meta-serialization/types/boolean-meta-serialization.ts +36 -0
- package/src/meta-serialization/types/char-meta-serialization.ts +28 -0
- package/src/meta-serialization/types/date-time-meta-serialization.ts +220 -0
- package/src/meta-serialization/types/decimal-meta-serialization.ts +13 -0
- package/src/meta-serialization/types/enums/data-type-meta-serialisation.ts +52 -0
- package/src/meta-serialization/types/enums/end-of-line-auto-write-type-meta-serialization.ts +47 -0
- package/src/meta-serialization/types/enums/end-of-line-type-meta-serialization.ts +46 -0
- package/src/meta-serialization/types/enums/heading-constraint-meta-serialization.ts +52 -0
- package/src/meta-serialization/types/enums/last-line-ended-type-meta-serialization.ts +45 -0
- package/src/meta-serialization/types/enums/meta-element-type-meta-serialization.ts +36 -0
- package/src/meta-serialization/types/enums/pad-alignment-meta-serialization.ts +54 -0
- package/src/meta-serialization/types/enums/pad-char-type-meta-serialization.ts +54 -0
- package/src/meta-serialization/types/enums/quoted-type-meta-serialization.ts +54 -0
- package/src/meta-serialization/types/enums/sequence-invokation-delay-meta-serialization.ts +44 -0
- package/src/meta-serialization/types/enums/sequence-redirect-type-meta-serialisation.ts +86 -0
- package/src/meta-serialization/types/enums/substitution-type-meta-serialization.ts +44 -0
- package/src/meta-serialization/types/enums/truncate-type-meta-serialization.ts +58 -0
- package/src/meta-serialization/types/float-meta-serialization.ts +96 -0
- package/src/meta-serialization/types/integer-float-meta-serialization.ts +46 -0
- package/src/meta-serialization/types/integer-meta-serialization.ts +44 -0
- package/src/meta-serialization/types/string-meta-serialization.ts +32 -0
- package/src/meta-serialization/utils/implicit-explicit-index-sorter.ts +61 -0
- package/src/meta-serialization/utils/meta-serialization-redirect-sequence-resolver.ts +43 -0
- package/src/meta-serialization/utils/meta-serialization-sequence-name-resolver.ts +85 -0
- package/src/meta-serialization/utils/sequence-item-field-indices.ts +76 -0
- package/src/sequences/core/ft-sequence-invokation-list.ts +109 -0
- package/src/sequences/core/ft-sequence-invokation.ts +166 -0
- package/src/sequences/core/ft-sequence-item-list.ts +40 -0
- package/src/sequences/core/ft-sequence-item.ts +59 -0
- package/src/sequences/core/ft-sequence-list.ts +73 -0
- package/src/sequences/core/ft-sequence.ts +75 -0
- package/src/sequences/redirects/ft-boolean-sequence-redirect.ts +42 -0
- package/src/sequences/redirects/ft-case-insensitive-string-sequence-redirect.ts +46 -0
- package/src/sequences/redirects/ft-date-sequence-redirect.ts +48 -0
- package/src/sequences/redirects/ft-exact-date-time-sequence-redirect.ts +46 -0
- package/src/sequences/redirects/ft-exact-decimal-sequence-redirect.ts +46 -0
- package/src/sequences/redirects/ft-exact-float-sequence-redirect.ts +46 -0
- package/src/sequences/redirects/ft-exact-integer-sequence-redirect.ts +46 -0
- package/src/sequences/redirects/ft-exact-string-sequence-redirect.ts +46 -0
- package/src/sequences/redirects/ft-null-sequence-redirect.ts +27 -0
- package/src/sequences/redirects/ft-sequence-redirect-list.ts +42 -0
- package/src/sequences/redirects/ft-sequence-redirect.ts +68 -0
- package/src/serialization/char-reader.ts +203 -0
- package/src/serialization/declaration-parser.ts +203 -0
- package/src/serialization/delimited-field-parser.ts +296 -0
- package/src/serialization/embedded-meta-parser.ts +147 -0
- package/src/serialization/fixed-width-field-parser.ts +220 -0
- package/src/serialization/formatting/ft-boolean-field-formatter.ts +114 -0
- package/src/serialization/formatting/ft-date-time-field-formatter.ts +61 -0
- package/src/serialization/formatting/ft-decimal-field-formatter.ts +52 -0
- package/src/serialization/formatting/ft-declared-parameters-formatter.ts +60 -0
- package/src/serialization/formatting/ft-field-formatter.ts +18 -0
- package/src/serialization/formatting/ft-float-field-formatter.ts +52 -0
- package/src/serialization/formatting/ft-integer-field-formatter.ts +53 -0
- package/src/serialization/formatting/ft-string-field-formatter.ts +15 -0
- package/src/serialization/formatting/index.ts +7 -0
- package/src/serialization/ft-declared-parameters.ts +232 -0
- package/src/serialization/ft-serialization-reader.ts +953 -0
- package/src/serialization/ft-serialization-writer.ts +760 -0
- package/src/serialization/ft-text-reader.ts +64 -0
- package/src/serialization/ft-text-writer.ts +61 -0
- package/src/serialization/heading-line-record-parser.ts +285 -0
- package/src/serialization/line-parser.ts +231 -0
- package/src/serialization/serialization-core.ts +632 -0
- package/src/substitutions/ft-substitution-list.ts +60 -0
- package/src/types/enums/ft-boolean-styles.ts +17 -0
- package/src/types/enums/ft-data-type.ts +21 -0
- package/src/types/enums/ft-end-of-line-auto-write-type.ts +14 -0
- package/src/types/enums/ft-end-of-line-type.ts +13 -0
- package/src/types/enums/ft-heading-constraint.ts +15 -0
- package/src/types/enums/ft-last-line-ended-type.ts +13 -0
- package/src/types/enums/ft-line-type.ts +17 -0
- package/src/types/enums/ft-meta-element-type.ts +16 -0
- package/src/types/enums/ft-meta-reference-type.ts +14 -0
- package/src/types/enums/ft-meta-serialization-format.ts +19 -0
- package/src/types/enums/ft-pad-alignment.ts +13 -0
- package/src/types/enums/ft-pad-char-type.ts +13 -0
- package/src/types/enums/ft-quoted-type.ts +13 -0
- package/src/types/enums/ft-read-record-result.ts +13 -0
- package/src/types/enums/ft-sequence-invokation-delay.ts +12 -0
- package/src/types/enums/ft-sequence-redirect-type.ts +19 -0
- package/src/types/enums/ft-substitution-type.ts +16 -0
- package/src/types/enums/ft-truncate-type.ts +15 -0
- package/src/types/errors/ft-internal-error.ts +15 -0
- package/src/types/errors/ft-serialization-error.ts +53 -0
- package/src/types/errors/ft-serialization-exception.ts +86 -0
- package/src/types/events/ft-field-heading-ready-event-args.ts +9 -0
- package/src/types/events/ft-field-value-ready-event-args.ts +9 -0
- package/src/types/events/ft-heading-line-finished-event-args.ts +6 -0
- package/src/types/events/ft-heading-line-started-event-args.ts +6 -0
- package/src/types/events/ft-record-finished-event-args.ts +6 -0
- package/src/types/events/ft-record-started-event-args.ts +6 -0
- package/src/types/events/ft-sequence-redirected-event-args.ts +9 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for reading characters from a text source.
|
|
3
|
+
* Mirrors .NET's TextReader for compatibility with C# implementation.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface FtTextReader {
|
|
7
|
+
/**
|
|
8
|
+
* Reads the next character from the text reader and advances the character position by one character.
|
|
9
|
+
* @returns The character read as a number (charCode), or -1 if the end of the text has been reached.
|
|
10
|
+
*/
|
|
11
|
+
read(): number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Namespace merged with TextReader interface to provide static constants.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export namespace FtTextReader {
|
|
19
|
+
/**
|
|
20
|
+
* Value returned by read() when the end of the text reader has been reached.
|
|
21
|
+
* Matches .NET's TextReader behavior.
|
|
22
|
+
*/
|
|
23
|
+
export const EofReadResult = -1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A TextReader implementation that reads from a string.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export class FtStringReader implements FtTextReader {
|
|
31
|
+
private _text: string;
|
|
32
|
+
private _position: number;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new FtStringReader.
|
|
36
|
+
* @param text - The string to read from.
|
|
37
|
+
*/
|
|
38
|
+
constructor(text: string) {
|
|
39
|
+
this._text = text;
|
|
40
|
+
this._position = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reads the next character from the string and advances the character position by one.
|
|
45
|
+
* @returns The character read as a number (charCode), or -1 if the end of the string has been reached.
|
|
46
|
+
*/
|
|
47
|
+
read(): number {
|
|
48
|
+
if (this._position >= this._text.length) {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const charCode = this._text.charCodeAt(this._position);
|
|
53
|
+
this._position++;
|
|
54
|
+
return charCode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Closes the FtStringReader and releases resources.
|
|
59
|
+
*/
|
|
60
|
+
close(): void {
|
|
61
|
+
this._text = '';
|
|
62
|
+
this._position = 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writer interface for outputting text.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export interface FtTextWriter {
|
|
6
|
+
write(text: string): void;
|
|
7
|
+
flush(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Simple text writer that accumulates to a string array.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export class FtStringWriter implements FtTextWriter {
|
|
15
|
+
private _parts: string[] = [];
|
|
16
|
+
|
|
17
|
+
write(text: string): void {
|
|
18
|
+
this._parts.push(text);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
flush(): void {
|
|
22
|
+
// No-op for string writer
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toString(): string {
|
|
26
|
+
return this._parts.join('');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
clear(): void {
|
|
30
|
+
this._parts = [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
close(): void {
|
|
34
|
+
this.clear();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Callback-based text writer for simple output accumulation.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export class FtCallbackTextWriter implements FtTextWriter {
|
|
43
|
+
constructor(
|
|
44
|
+
private readonly callback: (text: string) => void,
|
|
45
|
+
private readonly closeCallback?: () => void,
|
|
46
|
+
) {}
|
|
47
|
+
|
|
48
|
+
write(text: string): void {
|
|
49
|
+
this.callback(text);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
flush(): void {
|
|
53
|
+
// No-op
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
close(): void {
|
|
57
|
+
if (this.closeCallback) {
|
|
58
|
+
this.closeCallback();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { FtField } from '../fields/instances/ft-field.js';
|
|
2
|
+
import { FtAssertError, FtUnreachableCaseError } from '../types/errors/ft-internal-error.js';
|
|
3
|
+
import { FtSerializationError } from '../types/errors/ft-serialization-error.js';
|
|
4
|
+
import { FtSerializationException } from '../types/errors/ft-serialization-exception.js';
|
|
5
|
+
import { CharReader } from './char-reader.js';
|
|
6
|
+
import { DelimitedFieldParser } from './delimited-field-parser.js';
|
|
7
|
+
import { FixedWidthFieldParser } from './fixed-width-field-parser.js';
|
|
8
|
+
import { SerializationCore } from './serialization-core.js';
|
|
9
|
+
|
|
10
|
+
const State = {
|
|
11
|
+
Out: 'Out',
|
|
12
|
+
InOutField: 'InOutField',
|
|
13
|
+
InDelimitedField: 'InDelimitedField',
|
|
14
|
+
InFixedWidthField: 'InFixedWidthField',
|
|
15
|
+
OutIgnoreChars: 'OutIgnoreChars',
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
type State = (typeof State)[keyof typeof State];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Parses a single heading or data record line.
|
|
22
|
+
* Uses DelimitedFieldParser or FixedWidthFieldParser depending on field type.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export class HeadingLineRecordParser {
|
|
26
|
+
private readonly _core: SerializationCore;
|
|
27
|
+
private readonly _charReader: CharReader;
|
|
28
|
+
private readonly _headingLines: boolean;
|
|
29
|
+
|
|
30
|
+
private readonly _delimitedFieldParser: DelimitedFieldParser;
|
|
31
|
+
private readonly _fixedWidthFieldParser: FixedWidthFieldParser;
|
|
32
|
+
|
|
33
|
+
private _index = -1;
|
|
34
|
+
private _state: State = State.Out;
|
|
35
|
+
private _fieldCount = 0;
|
|
36
|
+
private _activeField: FtField | undefined = undefined;
|
|
37
|
+
|
|
38
|
+
private _startPosition = -1;
|
|
39
|
+
private _ignoreExtraCharsStartPosition = -1;
|
|
40
|
+
|
|
41
|
+
constructor(core: SerializationCore, charReader: CharReader, forHeadingLines: boolean) {
|
|
42
|
+
this._core = core;
|
|
43
|
+
this._charReader = charReader;
|
|
44
|
+
this._headingLines = forHeadingLines;
|
|
45
|
+
|
|
46
|
+
this._delimitedFieldParser = new DelimitedFieldParser(core, charReader, forHeadingLines);
|
|
47
|
+
this._fixedWidthFieldParser = new FixedWidthFieldParser(core, charReader, forHeadingLines);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get activeField(): FtField | undefined {
|
|
51
|
+
return this._activeField;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get fieldCount(): number {
|
|
55
|
+
return this._fieldCount;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getActiveFieldIndex(): number {
|
|
59
|
+
switch (this._state) {
|
|
60
|
+
case State.Out:
|
|
61
|
+
case State.OutIgnoreChars:
|
|
62
|
+
return -1;
|
|
63
|
+
default:
|
|
64
|
+
return this._fieldCount - 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getIgnoreExtraCharsLinePosition(): number {
|
|
69
|
+
if (this._ignoreExtraCharsStartPosition < 0) {
|
|
70
|
+
return -1;
|
|
71
|
+
} else {
|
|
72
|
+
return this._ignoreExtraCharsStartPosition - this._startPosition;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
isEndOfLineToBeEmbedded(): boolean {
|
|
77
|
+
if (this._state === State.InDelimitedField) {
|
|
78
|
+
return this._delimitedFieldParser.isEndOfLineToBeEmbedded();
|
|
79
|
+
} else {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Start parsing a new record.
|
|
86
|
+
*/
|
|
87
|
+
start(index: number): void {
|
|
88
|
+
if (this._state !== State.Out) {
|
|
89
|
+
throw new Error(`Unexpected RecordParser Start State: ${this._state}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this._index = index;
|
|
93
|
+
this._fieldCount = 0;
|
|
94
|
+
this._state = State.InOutField;
|
|
95
|
+
|
|
96
|
+
this._startPosition = this._charReader.position;
|
|
97
|
+
this._ignoreExtraCharsStartPosition = -1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Parse a single character.
|
|
102
|
+
*/
|
|
103
|
+
parseChar(aChar: string): void {
|
|
104
|
+
switch (this._state) {
|
|
105
|
+
case State.Out:
|
|
106
|
+
throw new Error('HeadingLineRecordParser parseChar called in Out state');
|
|
107
|
+
|
|
108
|
+
case State.InOutField:
|
|
109
|
+
if (this._fieldCount < this._core.fieldList.count) {
|
|
110
|
+
this.enterField(this._core.fieldList.get(this._fieldCount));
|
|
111
|
+
} else {
|
|
112
|
+
const error = this._headingLines ? FtSerializationError.HeadingLineTooManyFields : FtSerializationError.RecordTooManyFields;
|
|
113
|
+
const message = this._headingLines
|
|
114
|
+
? `Heading line has too many fields. Expected ${this._core.fieldList.count}`
|
|
115
|
+
: `Record has too many fields. Expected ${this._core.fieldList.count}`;
|
|
116
|
+
throw new FtSerializationException(error, message);
|
|
117
|
+
}
|
|
118
|
+
this.parseChar(aChar);
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case State.InFixedWidthField: {
|
|
122
|
+
const previousFieldFinished = this._fixedWidthFieldParser.parseChar(aChar);
|
|
123
|
+
if (previousFieldFinished) {
|
|
124
|
+
if (!this._core.seeking) {
|
|
125
|
+
this.loadFixedWidthHeadingValue();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.exitActiveField();
|
|
129
|
+
|
|
130
|
+
if (this._fieldCount < this._core.fieldList.count || !this._core.ignoreExtraChars) {
|
|
131
|
+
this._state = State.InOutField;
|
|
132
|
+
} else {
|
|
133
|
+
this._state = State.OutIgnoreChars;
|
|
134
|
+
this._ignoreExtraCharsStartPosition = this._charReader.position;
|
|
135
|
+
}
|
|
136
|
+
this.parseChar(aChar);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case State.InDelimitedField: {
|
|
142
|
+
const fieldFinished = this._delimitedFieldParser.parseChar(aChar);
|
|
143
|
+
if (fieldFinished) {
|
|
144
|
+
// aChar was delimiter
|
|
145
|
+
if (!this._core.seeking) {
|
|
146
|
+
this.loadDelimitedHeadingValue();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.exitActiveField();
|
|
150
|
+
|
|
151
|
+
if (this._fieldCount < this._core.fieldList.count || !this._core.ignoreExtraChars) {
|
|
152
|
+
this._state = State.InOutField;
|
|
153
|
+
} else {
|
|
154
|
+
this._state = State.OutIgnoreChars;
|
|
155
|
+
this._ignoreExtraCharsStartPosition = this._charReader.position;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
case State.OutIgnoreChars:
|
|
162
|
+
// nothing to do
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
default:
|
|
166
|
+
throw new FtUnreachableCaseError('HLRPPC44556', this._state);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Finish parsing the record.
|
|
172
|
+
*/
|
|
173
|
+
finish(): void {
|
|
174
|
+
switch (this._state) {
|
|
175
|
+
case State.Out:
|
|
176
|
+
// nothing to do
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
case State.InOutField:
|
|
180
|
+
this._state = State.Out;
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case State.InFixedWidthField:
|
|
184
|
+
if (!this._core.seeking) {
|
|
185
|
+
this.loadFixedWidthHeadingValue();
|
|
186
|
+
}
|
|
187
|
+
this.exitActiveField();
|
|
188
|
+
this._state = State.Out;
|
|
189
|
+
break;
|
|
190
|
+
|
|
191
|
+
case State.InDelimitedField:
|
|
192
|
+
if (!this._core.seeking) {
|
|
193
|
+
this.loadDelimitedHeadingValue();
|
|
194
|
+
}
|
|
195
|
+
this.exitActiveField();
|
|
196
|
+
this._state = State.Out;
|
|
197
|
+
break;
|
|
198
|
+
|
|
199
|
+
case State.OutIgnoreChars:
|
|
200
|
+
this._state = State.Out;
|
|
201
|
+
break;
|
|
202
|
+
|
|
203
|
+
default:
|
|
204
|
+
throw new FtUnreachableCaseError('HLRPF44556', this._state);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (this._fieldCount < this._core.fieldList.count) {
|
|
208
|
+
if (!this._core.allowIncompleteRecords) {
|
|
209
|
+
const error = this._headingLines ? FtSerializationError.HeadingLineNotEnoughFields : FtSerializationError.RecordNotEnoughFields;
|
|
210
|
+
const message = this._headingLines
|
|
211
|
+
? `Heading line has not enough fields. Got ${this._fieldCount}, expected ${this._core.fieldList.count}`
|
|
212
|
+
: `Record has not enough fields. Got ${this._fieldCount}, expected ${this._core.fieldList.count}`;
|
|
213
|
+
throw new FtSerializationException(error, message);
|
|
214
|
+
} else {
|
|
215
|
+
for (let i = this._fieldCount; i < this._core.fieldList.count; i++) {
|
|
216
|
+
const field = this._core.fieldList.get(i);
|
|
217
|
+
field.loadPosition(-1, -1, -1, -1);
|
|
218
|
+
if (this._headingLines) {
|
|
219
|
+
field.loadHeading(this._index, '');
|
|
220
|
+
} else {
|
|
221
|
+
field.loadNullValue();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private loadFixedWidthHeadingValue(): void {
|
|
229
|
+
if (this._activeField === undefined) {
|
|
230
|
+
throw new Error('Active field is null');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this._headingLines) {
|
|
234
|
+
this._fixedWidthFieldParser.loadFieldHeading(this._index);
|
|
235
|
+
this._core.fireFieldHeadingReadReady(this._activeField, this._index);
|
|
236
|
+
} else {
|
|
237
|
+
this._fixedWidthFieldParser.loadFieldValue();
|
|
238
|
+
this._core.fireFieldValueReadReady(this._activeField, this._index);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private loadDelimitedHeadingValue(): void {
|
|
243
|
+
if (this._activeField === undefined) {
|
|
244
|
+
throw new Error('Active field is null');
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (this._headingLines) {
|
|
248
|
+
this._delimitedFieldParser.loadFieldHeading(this._index);
|
|
249
|
+
this._core.fireFieldHeadingReadReady(this._activeField, this._index);
|
|
250
|
+
} else {
|
|
251
|
+
this._delimitedFieldParser.loadFieldValue();
|
|
252
|
+
this._core.fireFieldValueReadReady(this._activeField, this._index);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private enterField(field: FtField): void {
|
|
257
|
+
this._activeField = field;
|
|
258
|
+
this._fieldCount++;
|
|
259
|
+
if (this._activeField.fixedWidth) {
|
|
260
|
+
this._state = State.InFixedWidthField;
|
|
261
|
+
this._fixedWidthFieldParser.enterField(this._activeField);
|
|
262
|
+
} else {
|
|
263
|
+
this._state = State.InDelimitedField;
|
|
264
|
+
this._delimitedFieldParser.enterField(this._activeField);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private exitActiveField(): void {
|
|
269
|
+
switch (this._state) {
|
|
270
|
+
case State.InFixedWidthField:
|
|
271
|
+
this._fixedWidthFieldParser.exitField();
|
|
272
|
+
break;
|
|
273
|
+
case State.InDelimitedField:
|
|
274
|
+
this._delimitedFieldParser.exitField();
|
|
275
|
+
break;
|
|
276
|
+
case State.InOutField:
|
|
277
|
+
case State.Out:
|
|
278
|
+
case State.OutIgnoreChars:
|
|
279
|
+
throw new FtAssertError(`Unsupported state in exitActiveField: ${this._state}`);
|
|
280
|
+
default:
|
|
281
|
+
throw new FtUnreachableCaseError('HLRPEAF44558', this._state);
|
|
282
|
+
}
|
|
283
|
+
this._activeField = undefined;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { FtEndOfLineType } from '../types/enums/ft-end-of-line-type.js';
|
|
2
|
+
import { FtAssertError, FtUnreachableCaseError } from '../types/errors/ft-internal-error.js';
|
|
3
|
+
import { CharReader } from './char-reader.js';
|
|
4
|
+
|
|
5
|
+
const FtLineState = {
|
|
6
|
+
Out: 'Out',
|
|
7
|
+
In: 'In',
|
|
8
|
+
InNextTextOut: 'InNextTextOut',
|
|
9
|
+
InTextOut: 'InTextOut',
|
|
10
|
+
InPendingNextLineFeed: 'InPendingNextLineFeed',
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
type FtLineState = (typeof FtLineState)[keyof typeof FtLineState];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export const LineEndedType = {
|
|
19
|
+
Not: 'Not',
|
|
20
|
+
Initiated: 'Initiated',
|
|
21
|
+
Continued: 'Continued',
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export type LineEndedType = (typeof LineEndedType)[keyof typeof LineEndedType];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Parses characters into lines with end-of-line awareness.
|
|
31
|
+
* Manages line state and handles different end-of-line types.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export class LineParser {
|
|
35
|
+
private static readonly CarriageReturnChar = CharReader.CarriageReturnChar;
|
|
36
|
+
private static readonly LineFeedChar = CharReader.LineFeedChar;
|
|
37
|
+
private static readonly CarriageReturnLineFeedString = CharReader.CarriageReturnLineFeedString;
|
|
38
|
+
|
|
39
|
+
private _charReader: CharReader;
|
|
40
|
+
private _endOfLineType: FtEndOfLineType;
|
|
41
|
+
private _endOfLineChar: string;
|
|
42
|
+
|
|
43
|
+
private _textLineCount = 0;
|
|
44
|
+
private _textLineLength = 0;
|
|
45
|
+
private _lineCount = 0;
|
|
46
|
+
private _lineLength = 0;
|
|
47
|
+
private _inLineState: FtLineState = FtLineState.Out;
|
|
48
|
+
|
|
49
|
+
constructor(charReader: CharReader, endOfLineType: FtEndOfLineType, endOfLineChar: string) {
|
|
50
|
+
this._charReader = charReader;
|
|
51
|
+
this._endOfLineType = endOfLineType;
|
|
52
|
+
this._endOfLineChar = endOfLineChar;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get lineCount(): number {
|
|
56
|
+
return this._lineCount;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get lineLength(): number {
|
|
60
|
+
return this._lineLength;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get inLine(): boolean {
|
|
64
|
+
return this._inLineState !== FtLineState.Out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Update the end-of-line configuration.
|
|
69
|
+
*/
|
|
70
|
+
setEndOfLine(endOfLineType: FtEndOfLineType, endOfLineChar: string): void {
|
|
71
|
+
this._endOfLineType = endOfLineType;
|
|
72
|
+
this._endOfLineChar = endOfLineChar;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Reset the line parser state.
|
|
77
|
+
*/
|
|
78
|
+
reset(): void {
|
|
79
|
+
this._textLineCount = 0;
|
|
80
|
+
this._textLineLength = 0;
|
|
81
|
+
this._lineCount = 0;
|
|
82
|
+
this._lineLength = 0;
|
|
83
|
+
this._inLineState = FtLineState.Out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Parse a single character and update line state.
|
|
88
|
+
* @param aChar The character to parse.
|
|
89
|
+
* @param endOfLineToBeEmbedded Whether end-of-line should be embedded (not treated as line break).
|
|
90
|
+
* @returns The line ended type.
|
|
91
|
+
*/
|
|
92
|
+
parseChar(aChar: string, endOfLineToBeEmbedded: boolean): LineEndedType {
|
|
93
|
+
let lineEndedType: LineEndedType;
|
|
94
|
+
|
|
95
|
+
switch (this._inLineState) {
|
|
96
|
+
case FtLineState.InNextTextOut:
|
|
97
|
+
// Assert: aChar === LineFeedChar && endOfLineToBeEmbedded
|
|
98
|
+
this._inLineState = FtLineState.InTextOut;
|
|
99
|
+
lineEndedType = LineEndedType.Not;
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case FtLineState.InTextOut:
|
|
103
|
+
this._textLineCount++;
|
|
104
|
+
this._textLineLength = 0;
|
|
105
|
+
this._inLineState = FtLineState.In;
|
|
106
|
+
lineEndedType = this.parseInChar(aChar, endOfLineToBeEmbedded);
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
case FtLineState.In:
|
|
110
|
+
lineEndedType = this.parseInChar(aChar, endOfLineToBeEmbedded);
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case FtLineState.InPendingNextLineFeed:
|
|
114
|
+
// Assert: aChar === LineFeedChar && !endOfLineToBeEmbedded
|
|
115
|
+
this._inLineState = FtLineState.Out;
|
|
116
|
+
lineEndedType = LineEndedType.Continued;
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case FtLineState.Out:
|
|
120
|
+
this._lineCount++;
|
|
121
|
+
this._lineLength = 0;
|
|
122
|
+
this._textLineCount++;
|
|
123
|
+
this._textLineLength = 0;
|
|
124
|
+
this._inLineState = FtLineState.In;
|
|
125
|
+
lineEndedType = this.parseInChar(aChar, endOfLineToBeEmbedded);
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
default:
|
|
129
|
+
throw new FtUnreachableCaseError('LPPC54122', this._inLineState);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this._lineLength++;
|
|
133
|
+
this._textLineLength++;
|
|
134
|
+
|
|
135
|
+
return lineEndedType;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Exit the current line state.
|
|
140
|
+
*/
|
|
141
|
+
exitLine(): void {
|
|
142
|
+
if (!this.inLine) {
|
|
143
|
+
throw new FtAssertError('LPPEL54124', 'LineParser.exitLine() called when not In Line');
|
|
144
|
+
}
|
|
145
|
+
this._inLineState = FtLineState.Out;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Add a blank line to the count.
|
|
150
|
+
*/
|
|
151
|
+
addBlankLine(): void {
|
|
152
|
+
this._textLineCount++;
|
|
153
|
+
this._textLineLength = 0;
|
|
154
|
+
this._lineCount++;
|
|
155
|
+
this._lineLength = 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private parseInChar(aChar: string, embedEndOfLine: boolean): LineEndedType {
|
|
159
|
+
const crChar = LineParser.CarriageReturnChar;
|
|
160
|
+
const lfChar = LineParser.LineFeedChar;
|
|
161
|
+
|
|
162
|
+
switch (this._endOfLineType) {
|
|
163
|
+
case FtEndOfLineType.Auto:
|
|
164
|
+
switch (aChar) {
|
|
165
|
+
case crChar:
|
|
166
|
+
if (embedEndOfLine) {
|
|
167
|
+
if (this._charReader.peekNextIsLineFeed()) {
|
|
168
|
+
this._inLineState = FtLineState.InNextTextOut;
|
|
169
|
+
} else {
|
|
170
|
+
this._inLineState = FtLineState.InTextOut;
|
|
171
|
+
}
|
|
172
|
+
return LineEndedType.Not;
|
|
173
|
+
} else {
|
|
174
|
+
this._inLineState = this._charReader.peekNextIsLineFeed() ? FtLineState.InPendingNextLineFeed : FtLineState.Out;
|
|
175
|
+
return LineEndedType.Initiated;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
case lfChar:
|
|
179
|
+
if (embedEndOfLine) {
|
|
180
|
+
this._inLineState = FtLineState.InTextOut;
|
|
181
|
+
return LineEndedType.Not;
|
|
182
|
+
} else {
|
|
183
|
+
this._inLineState = FtLineState.Out;
|
|
184
|
+
return LineEndedType.Initiated;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
default:
|
|
188
|
+
this._lineLength++;
|
|
189
|
+
this._textLineLength++;
|
|
190
|
+
return LineEndedType.Not;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
case FtEndOfLineType.CrLf:
|
|
194
|
+
if (aChar !== crChar) {
|
|
195
|
+
return LineEndedType.Not;
|
|
196
|
+
} else {
|
|
197
|
+
if (embedEndOfLine) {
|
|
198
|
+
if (this._charReader.peekNextIsLineFeed()) {
|
|
199
|
+
this._inLineState = FtLineState.InNextTextOut;
|
|
200
|
+
} else {
|
|
201
|
+
this._inLineState = FtLineState.InTextOut;
|
|
202
|
+
}
|
|
203
|
+
return LineEndedType.Not;
|
|
204
|
+
} else {
|
|
205
|
+
if (!this._charReader.peekNextIsLineFeed()) {
|
|
206
|
+
return LineEndedType.Not;
|
|
207
|
+
} else {
|
|
208
|
+
this._inLineState = FtLineState.InPendingNextLineFeed;
|
|
209
|
+
return LineEndedType.Initiated;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
case FtEndOfLineType.Char:
|
|
215
|
+
if (aChar !== this._endOfLineChar) {
|
|
216
|
+
return LineEndedType.Not;
|
|
217
|
+
} else {
|
|
218
|
+
if (embedEndOfLine) {
|
|
219
|
+
this._inLineState = FtLineState.InTextOut;
|
|
220
|
+
return LineEndedType.Not;
|
|
221
|
+
} else {
|
|
222
|
+
this._inLineState = FtLineState.Out;
|
|
223
|
+
return LineEndedType.Initiated;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
default:
|
|
228
|
+
throw new FtUnreachableCaseError('LPPIC54123', this._endOfLineType);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|