npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ds-wizard/importer-sdk

v0.3.0

Published

An SDK for building importers for the Data Stewardship Wizard

Downloads

3

Readme

DSW Importer SDK

npm version License

Instalation

$ npm install @ds-wizard/importer-sdk

You can then import the library:

var DSWImporter = require('@ds-wizard/importer-sdk')

Or using ES6:

import DSWImporter from '@ds-wizard/importer-sdk'

Alternatively, you can import the library using the script tag and CDN:

<script src="https://unpkg.com/@ds-wizard/importer-sdk/lib/index.js"></script>

DSWImporter will then become globally available.

Usage

On the page that will serve your importer, you need to initialize it first. Then you can use call other methods to create the import data. When you have everything ready, you send the replies back to DSW.

const importer = new DSWImporter()
importer.init()
    .then(() => {
        // Question path is a list of UUID strings
        const questionPath = [ /* ... */ ]

        // You can set a reply using the question path and a value
        // The value is either a string for a value question or answer/choice 
        // UUID for options/multichoice question
        importer.setReply(questionPath, 'value')

        // For a list question, you can add an item and then use the item's UUID
        // to build the path for questions in the item
        const itemUuid = importer.addItem(questionPath)
        importer.setReply(
            [...questionPath, itemUuid, itemQuestionUuid],
            'Lee Harris'
        )

        // For an integration question, you can either use setReply to have
        // a plain answer or you can use setIntegrationReply to set the link 
        // as well so that the response will behave as if it was from the 
        // integration
        importer.setIntegrationReply(
            questionPath,
            'Czech Technical University in Prague',
            'https://ror.org/03kqpb082'
        )

        // Send the replies back to DSW
        // this will also close the window
        importer.send()
    })
    .catch(error => {
        console.error(error)
    })

UUIDs by Annotations

Instead of hardcoding the UUID of a specific entity (chapter, question,...) you can find it using the annotations defined in the knowledge model. For example, if you have a question with the following annotation:

Key:   rdfType
Value: http://purl.org/dc/terms/title

You can find its UUID using the importer API:

const questionUuid = importer.getQuestionUuidByAnnotation('rdfType', 'http://purl.org/dc/terms/title')

Importer Options

You can pass some extra importer options to the init function. If you don't, the default options will be used.

const importer = new DSWImporter()

importer.init({
    // options go here
})

| Option | Value | Default | Description | | --- | --- | --- |--- | | useWizardStyle | true/false | true | If you want to use the stylesheet from the client that opened the importer (see below). | | windowSize | { width: 300, height: 200 } | null | Use this to resize the importer window to the desired size when it is open. |

Wizard Styles

DSW Client uses Bootstrap with customizations, such as changing a primary color. You can load the styles in the importer to match the look and feel of the client. Then you can use all the Bootstrap classes and variables from the client that opened the importer.

For example, the following CSS code will set the body background color to the primary color of the client that opened the importer:

body {
    background-color: var(--bs-primary);
}

This way, you can create reusable importers across different DSW instances while keeping the look and feel of those instances.

Compatibility

| Importer SDK Version | DSW Version from | DSW Version to | | --- | --- | --- | | 0.3.0 | 3.20 | latest | | 0.2.0 | 3.18 | 3.19 | | 0.1.0 | 3.15 | 3.17 |

License

This project is licensed under the Apache License v2.0 - see the LICENSE file for more details.