0.18.1 • Published 9 months ago

@lickd/distributions v0.18.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

Distributions

Details

⚠️ Warning!

While in version 0.x there is a chance of breaking changes between minor/patch version.
Please be cautious when upgrading between versions and check for any upgrade guides.

Once a major version is released, this will no longer be the case and this library will follow Semantic Versioning.

A library for parsing and converting distribution files.

Install

$ npm install @lickd/distributions

Usage

Examples can be found in the examples folder.

Parsing

import { Distributions } from "@lickd/distributions";
import { readFileSync } from "fs";

const distributions = new Distributions();
const file = "path/to/distribution/file";

(async () => {
  const parsed = await distributions.parse(readFileSync(file).toString());

  console.log({ parsed });
})();

Converting

Direct conversion

import { Distributions, Ern411, ErnVersions } from "@lickd/distributions";
import { readFileSync } from "fs";

const distributions = new Distributions();
const file = "path/to/distribution/file";

(async () => {
  const parsed = await distributions.parse(readFileSync(file).toString(), {
    version: ErnVersions.ERN_411,
  });

  console.log({ parsed });
})();

Indirect conversion

import { Distributions, Ern411, ErnVersions } from "@lickd/distributions";
import { readFileSync } from "fs";

const distributions = new Distributions();
const file = "path/to/distribution/file";

(async () => {
  const parsed = await distributions.parse(readFileSync(file).toString());

  logger.info({ parsed });

  const converted = await distributions.parse(parsed, {
    version: ErnVersions.ERN_411,
    normalise: true,
  });

  logger.info({ converted });
})();

Logging

Enabling logging

import { Distributions } from "@lickd/distributions";

const distributions = new Distributions({
  logger: console,
});

Custom logger

import { Distributions } from "@lickd/distributions";
import { ConsoleLogger } from "@lickd/logger";

const logger = new ConsoleLogger();
const distributions = new Distributions({ logger });

Known issues

Parsing

DDEX 411+ - DisplayCredits

Due to the definition of DisplayCredits if the sequence for DisplayCreditParty and NameUsedInDisplayCredit does not have both values then the parsed result will not be correct.

<DisplayCredits>
  <DisplayCreditText>Test</DisplayCreditText>
  <DisplayCreditParty>P1</DisplayCreditParty>
  <NameUsedInDisplayCredit>Credit1</NameUsedInDisplayCredit>
  <DisplayCreditParty>P2</DisplayCreditParty>
  <NameUsedInDisplayCredit>Credit2</NameUsedInDisplayCredit>
  <DisplayCreditParty>P3</DisplayCreditParty>
  <!-- <NameUsedInDisplayCredit>P3</NameUsedInDisplayCredit> -->
  <DisplayCreditParty>P4</DisplayCreditParty>
  <NameUsedInDisplayCredit>Credit4</NameUsedInDisplayCredit>
</DisplayCredits>

Notice how P3 has the NameUsedInDisplayCredit commented out, this will result in the following:

[
  {
    "displayCreditPartyList": "P1",
    "nameUsedInDisplayCredit": "Credit1"
  },
  {
    "displayCreditPartyList": "P2",
    "nameUsedInDisplayCredit": "Credit2"
  },
  {
    "displayCreditPartyList": "P3",
    "nameUsedInDisplayCredit": "Credit4"
  },
  {
    "displayCreditPartyList": "P4"
  }
]

This is because when we convert the raw XML into raw JSON we get the following:

{
  "DisplayCreditText": ["Test"],
  "DisplayCreditParty": ["P1", "P2", "P3", "P4"],
  "NameUsedInDisplayCredit": ["Credit1", "Credit2", "Credit4"]
}

Copyright info

This scene is protected with a standard Apache 2 licence. See the terms and conditions in the LICENSE file.

0.18.1

9 months ago

0.18.0

9 months ago

0.17.2

9 months ago

0.17.0

9 months ago

0.17.1

9 months ago

0.16.0

9 months ago

0.13.0

9 months ago

0.15.0

9 months ago

0.14.0

9 months ago

0.14.1

9 months ago

0.14.2

9 months ago

0.11.0

10 months ago

0.11.1

10 months ago

0.11.2

10 months ago

0.12.1

9 months ago

0.9.0

1 year ago

0.9.1

1 year ago

0.10.1

11 months ago

0.10.2

11 months ago

0.10.3

11 months ago

0.10.0

11 months ago

0.8.2

1 year ago

0.8.1

1 year ago

0.7.0

1 year ago

0.8.0

1 year ago

0.6.0

1 year ago

0.5.5

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.1.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.2

1 year ago

0.0.1-beta.32

1 year ago

0.0.1-beta.31

1 year ago

0.0.1-beta.30

1 year ago

0.0.1

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.4

1 year ago

0.0.1-beta.29

1 year ago

0.0.1-beta.28

1 year ago

0.0.1-beta.27

1 year ago

0.0.1-beta.26

1 year ago

0.0.1-beta.25

2 years ago

0.0.1-beta.24

2 years ago

0.0.1-beta.23

2 years ago

0.0.1-beta.22

2 years ago

0.0.1-beta.21

2 years ago

0.0.1-beta.20

2 years ago

0.0.1-beta.19

2 years ago

0.0.1-beta.18

2 years ago

0.0.1-beta.17

2 years ago

0.0.1-beta.16

2 years ago

0.0.1-beta.15

2 years ago

0.0.1-beta.14

2 years ago

0.0.1-beta.13

2 years ago

0.0.1-beta.12

2 years ago

0.0.1-beta.11

2 years ago

0.0.1-beta.10

2 years ago

0.0.1-beta.9

2 years ago

0.0.1-beta.8

2 years ago

0.0.1-beta.7

2 years ago

0.0.1-beta.5

2 years ago

0.0.1-beta.4

2 years ago

0.0.1-beta.3

2 years ago

0.0.1-beta.2

2 years ago

0.0.1-beta.1

2 years ago