npm

@polywrap/datetime-plugin-js
TypeScript icon, indicating that this package has built-in type declarations

0.12.0 • Public • Published

@polywrap/datetime-plugin-js

The Datetime plugin implements the datetime-interface @ wrapscan.io/polywrap/datetime@1.0 (see ./polywrap.graphql). It provides access to the current unix timestamp of the host operating system.

Usage

1. Configure Client

When creating your Polywrap JS client, add the datetime plugin:

import { ClientConfigBuilder } from "@polywrap/client-config-builder-js";
import { PolywrapClient } from "@polywrap/client-js";
import { datetimePlugin } from "@polywrap/datetime-plugin-js";

const config = new ClientConfigBuilder()
  // 1. Add the plugin package @ an arbitrary URI
  .addPackage(
    "plugin/datetime",
    datetimePlugin({ })
  )
  // 2. Register this plugin as an implementation of the interface
  .addInterfaceImplementation(
    "wrapscan.io/polywrap/datetime@1.0",
    "plugin/datetime"
  )
  // 3. Redirect invocations @ the interface to the plugin (default impl)
  .addRedirect(
    "wrapscan.io/polywrap/datetime@1.0",
    "plugin/datetime"
  )
  .build();

const client = new PolywrapClient(config);

2. Invoke the Datetime Plugin

Invocations to the datetime plugin can be made via the interface URI (which will get redirected), or the plugin's URI directly:

await client.invoke({
  uri: "wrapscan.io/polywrap/datetime@1.0" | "plugin/datetime",
  method: "currentTimestamp"
});

Readme

Keywords

none

Package Sidebar

Install

npm i @polywrap/datetime-plugin-js

Weekly Downloads

18

Version

0.12.0

License

MIT

Unpacked Size

16.8 kB

Total Files

20

Last publish

Collaborators

  • polywrap-build-bot
  • dorgjelli