0.0.3 • Published 2 years ago

lens-platform-extension-sdk v0.0.3

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

Lens Platform Extension Sdk

Lens Platform Extension SDK

Use SDK in Lens extension:

import { LensClient } from "lens-platform-extension-sdk";

const lensClient = new LensClient({
    getAccessToken: () => Promise.resolve("<token>"), // the callback to be called before every request, useful if the access token needs to be renew often.
});

The SDK uses axios internally for HTTP(s) requests.

Lint

npm run lint

Using the SDK in Electron

You will need to change the Axios HTTP adapter to use Node to get around CORS issues:

// Set in LensPlatformClient options:
httpAdapter: true

If webpack is used, you also need to prevent webpack from using the "browser" property of package.json of axios, which would override http adapter resolving to use the xhr. xhr could cause CORS issues.

    resolve: {
      // ...
      aliasFields: []
    },

Type Check

You should enable ts support in you editor with type-checking.

Or type-checking from CLI

npm run check:type

Test

The "all-in-one" test script would run linter, type-checking, and unit tests in parallel.

npm run test

You can also run unit tests only

npm run test:unit [-- --watch]

which is just a shortcut for npx jest [--watch]

Documentation

We use tsdoc https://github.com/microsoft/tsdoc for inline doc comments.

License

Copyright (c) 2022 Mirantis, Inc.

Licensed under the MIT license. https://opensource.org/licenses/MIT