Plywood Base API

raw JSON →
0.2.9 verified Sat Apr 25 auth: no javascript

Plywood Base API (v0.2.9) provides foundational TypeScript types and interfaces for implementing requesters in the Plywood ecosystem. It defines the contract that all Plywood requesters must conform to, ensuring consistency across different implementations. The library is dependency-light (only requires 'plywood' as a peer) and ships TypeScript declarations. It is released irregularly alongside Plywood changes.

error Cannot find module 'plywood'
cause Missing peer dependency 'plywood'
fix
Run 'npm install plywood' in your project.
error TypeError: Class extends value undefined is not a constructor or null
cause The import of BaseRequester failed, likely due to circular dependency or bundler issue.
fix
Ensure 'plywood-base-api' and 'plywood' are installed and loaded correctly; try using dynamic import.
error Module not found: Error: Can't resolve 'plywood-base-api'
cause Package not installed or not in node_modules.
fix
Run 'npm install plywood-base-api'.
breaking Constructor signature change in v0.3.0: constructors now accept an options object instead of individual parameters.
fix Update constructor calls to pass an options object.
deprecated The 'init' method is deprecated; use constructor for initialization.
fix Move initialization logic to constructor.
gotcha TypeScript users must ensure 'plywood' is installed as a peer dependency even if not directly imported.
fix Add 'plywood' to your project's dependencies.
gotcha ESM and CJS builds are separate; import paths differ between bundlers and Node.js.
fix For Node.js ESM, use 'import { ... } from 'plywood-base-api'; for CJS, use 'const { ... } = require('plywood-base-api');'. Avoid mixing.
npm install plywood-base-api
yarn add plywood-base-api
pnpm add plywood-base-api

Shows how to subclass BaseRequester to create a custom Plywood requester with a request method.

import { BaseRequester } from 'plywood-base-api';

class MyRequester extends BaseRequester {
  constructor() {
    super();
  }

  async request(query: string): Promise<any> {
    // Implement your request logic here
    return { data: 'result' };
  }
}

const requester = new MyRequester();
requester.request('SELECT * FROM table').then(console.log);