0.1.10 • Published 2 years ago

@pubpub/deposit-utils v0.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

deposit-utils

Deposit works to digital object repositories like Crossref and Datacite using statically-typed primitives that are validated against official XSD schemas.

Getting Started

Deposits for each supported registry (Crossref or Datacite) can be defined in one of three ways: JSX, Hyperscript, or plain JavaScript objects.

JSX

Update your tsconfig.json to translate JSX syntax to function calls:

{
  "compilerOptions": {
    "jsx": "react",
    "jsxFactory": "x",
    "jsxFragmentFactory": "null"
  }
}
import { x, renderXml } from "@pubpub/deposit-utils/datacite";

const depositXml = renderXml(
  <resource>
    <titles>
      <title xml:lang="en-US">deposit-utils XML Example</title>
    </titles>
    {/*...*/}
  </resource>
);

Hyperscript

import { x, renderXml } from "@pubpub/deposit-utils/datacite";

const depositXml = renderXml(
  x("resource", [
    x("titles", [
      x("title", { "xml:lang": "en-US" }, "deposit-utils XML Example"),
    ]),
  ])
);

Plain objects (xast AST):

import { renderXml } from "@pubpub/deposit-utils/datacite";

const xml = renderXml({
  type: "element",
  name: "resource",
  children: [
    {
      type: "element",
      name: "titles",
      children: [
        {
          type: "element",
          name: "title",
          attributes: { "xml:lang": "en-US" },
          children: ["deposit-utils XML Example"],
        },
      ],
    },
  ],
});

Development

Fetch XSD and generate TypeScript types:

npm run gen
0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago