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

@think-it-labs/edc-connector-client

v0.4.1

Published

EDC Connector HTTP client

Downloads

971

Readme

Abstract

The EDC Connector is a framework for a sovereign, inter-organizational data exchange. It provides low-level primitives to allow network participants to expose and consume offers. The Connector does so by providing an extensive HTTP API documented via OpenAPI specification.

This project aims to increase the level of abstraction, bringing the low-level HTTP API to mid-level developers by providing an HTTP Client which is thoroughly tested and fully type-safe.

Similarly to the EDC Connector, this library is at its early stage. It aims to maintain compatibility with the latest version of the Connector. API specification can be found on SwaggerHub

Compatibility matrix

|Client |EDC | |--------|-------| |0.4.x |0.6.x | |0.3.0 |0.5.0 | |0.2.1 |0.4.1 | |0.2.0 |0.2.0 |

Usage

Install via npm or yarn

npm install @think-it-labs/edc-connector-client
yarn add @think-it-labs/edc-connector-client

Once installed, clients can be instanciated by construcing a EdcConnectorClient.

With internal context

The standard way of using the client would be associating it with a connector, for doing that it can be instantiated through the EdcConnectorClient.Builder

import { EdcConnectorClient } from "@think-it-labs/edc-connector-client"

const client = new EdcConnectorClient.Builder()
  .apiToken("123456")
  .managementUrl("https://edc.think-it.io/management")
  .publicUrl("https://edc.think-it.io/public")
  .build();

At this point the calls can be made against the specified connector:

const result = await client.management.assets.create({
  properties: {
      "name": "asset name",
      "key": "any value"
  },
  dataAddress: {
    name: "An HTTP address",
    baseUrl: "https://example.com/",
    type: "HttpData",
    path: "/some-data",
    contentType: "application/json",
    method: "GET",
  },
});

Without internal context

A single connector instance can be used to call multiple connectors, just creating different contexts and passing them to the specific call.

The connector can be instantiated directly without the builder:

import { EdcConnectorClient } from "@think-it-labs/edc-connector-client"

const client = new EdcConnectorClient();

Context objects can be created with a createContext call:

const context = client.createContext("123456", {
  default: "https://edc.think-it.io/api",
  management: "https://edc.think-it.io/management",
  protocol: "https://edc.think-it.io/protocol",
  public: "https://edc.think-it.io/public",
  control: "https://edc.think-it.io/control",
});

And the context can be passed to every call as latest argument:

const result = await client.management.assets.create(context, {
  asset: {
    properties: {
      "name": "asset name",
      "key": "any value"
    },
    dataAddress: {
      name: "An HTTP address",
      baseUrl: "https://example.com/",
      type: "HttpData",
      path: "/some-data",
      contentType: "application/json",
      method: "GET",
    },
  }
});

Error handling

All API methods are type, and error-safe, which means arguments are fully typed with TypeScript, and thrown errors are always EdcConnectorClientError instances. This error safety level is achieved using the TypedError library.


import { EdcConnectorClientError, EdcConnectorClientErrorType } from "@think-it-labs/edc-connector-client"

try {

  // perform async EdcConnectorClient actions

} catch(error) {
  if (error instanceof EdcConnectorClientError) {
    switch (error.type) {
      case EdcConnectorClientErrorType.Duplicate: {
        // handle duplicate error
      }

      // ...

      case EdcConnectorClientErrorType.Unknown:
      default: {
        // red alert: unknown behaviour
      }
    }
  }
}

Note if you encounter an Unknown error you should report this behavior along steps to reproduce it. Unknown behaviors are unwanted and must be fixed asap.

Development

docker compose is used to run the development environment. It runs two connectors with capabilities described in the gradle configuration file.

Please, adhere to the CONTRIBUTING guidelines when suggesting changes in this repository.

Release

The release github action workflow takes care of release.

License

Copyright 2022-2023 Think.iT GmbH.

Licensed under the Apache License, Version 2.0. Files in the project may not be copied, modified, or distributed except according to those terms.