@tableland/sdk
Advanced tools
Comparing version 3.1.5 to 4.0.0-pre.1
151
package.json
{ | ||
"name": "@tableland/sdk", | ||
"version": "3.1.5", | ||
"description": "A TypeScript/JavaScript library for creating and querying Tables on the Tableland network.", | ||
"repository": "https://github.com/tablelandnetwork/js-tableland", | ||
"license": "MIT", | ||
"version": "4.0.0-pre.1", | ||
"description": "A D1Database client and helpers for the Tableland network", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"keywords": [ | ||
"tableland", | ||
"sql", | ||
"ethereum" | ||
], | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"type": "module", | ||
"main": "./dist/cjs/main.js", | ||
"module": "./dist/esm/main.js", | ||
"types": "./dist/esm/main.d.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/cjs/main.js", | ||
"import": "./dist/esm/main.js", | ||
"default": "./dist/esm/main.js" | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.js", | ||
"default": "./dist/index.js" | ||
}, | ||
"./connector": { | ||
"require": "./dist/cjs/lib/connector.js", | ||
"import": "./dist/esm/lib/connector.js", | ||
"default": "./dist/esm/lib/connector.js" | ||
"./helpers": { | ||
"require": "./dist/helpers/index.js", | ||
"import": "./dist/helpers/index.js", | ||
"default": "./dist/helpers/index.js" | ||
}, | ||
"./registry": { | ||
"require": "./dist/registry/index.js", | ||
"import": "./dist/registry/index.js", | ||
"default": "./dist/registry/index.js" | ||
}, | ||
"./validator": { | ||
"require": "./dist/validator/index.js", | ||
"import": "./dist/validator/index.js", | ||
"default": "./dist/validator/index.js" | ||
}, | ||
"./database": { | ||
"require": "./dist/database.js", | ||
"import": "./dist/database.js", | ||
"default": "./dist/database.js" | ||
}, | ||
"./statement": { | ||
"require": "./dist/statement.js", | ||
"import": "./dist/statement.js", | ||
"default": "./dist/statement.js" | ||
}, | ||
"./**/*.js": { | ||
"require": "./dist/*", | ||
"import": "./dist/*", | ||
"default": "./dist/*" | ||
} | ||
@@ -37,8 +52,4 @@ }, | ||
"dist/**/*.d.ts", | ||
"dist/**/package.json", | ||
"src/**/*.ts" | ||
], | ||
"moduleTypes": { | ||
"jest.config.js": "cjs" | ||
}, | ||
"scripts": { | ||
@@ -50,61 +61,49 @@ "lint": "eslint '**/*.{js,ts}'", | ||
"format": "npm run prettier:fix && npm run lint:fix", | ||
"prepublishOnly": "npm run build:all", | ||
"test": "npm run test:unit && npm run test:e2e", | ||
"test:unit": "jest --verbose", | ||
"test:e2e": "npm run build:test && node --experimental-fetch ./node_modules/tape/bin/tape test/integration/build/test/integration/*.test.js", | ||
"clean": "rm -rf dist build package docs", | ||
"ts-node": "ts-node", | ||
"docs": "typedoc --entryPoints src/main.ts", | ||
"docs:html": "typedoc --entryPoints src/main.ts --plugin none", | ||
"build:esm": "tsc -p tsconfig.json", | ||
"build:cjs": "tsc -p tsconfig.cjs.json", | ||
"build:esbuild": "esbuild src/main.ts --bundle --minify --sourcemap=external --outfile=dist/esbuild/main.js --format=esm && node ./node_modules/add-js-extension/dist/bin.js ./dist/esm --once", | ||
"build:dev": "esbuild src/main.ts --bundle --outfile=dist/esbuild/main.js --format=esm --sourcemap=inline", | ||
"build:watch": "esbuild src/main.ts --bundle --watch --outfile=dist/esbuild/main.js --format=esm && node ./node_modules/add-js-extension/dist/bin.js ./dist/esm --once", | ||
"build:all": "npm run build:esm && npm run build:cjs && npm run build:esbuild && ./fixup.sh", | ||
"build:test": "tsc -p tsconfig.e2e.json" | ||
"prepublishOnly": "npm run build", | ||
"test": "mocha", | ||
"coverage": "c8 --exclude src/validator/client/fetcher.ts --exclude test mocha --exit", | ||
"docs": "typedoc --entryPoints src/index.ts", | ||
"clean": "rm -rf dist coverage docs", | ||
"build:api": "npx openapi-typescript https://raw.githubusercontent.com/tablelandnetwork/docs/main/specs/validator/tableland-openapi-spec.yaml --output src/validator/client/validator.ts --immutable-types --path-params-as-types", | ||
"build:ts": "npx tsc", | ||
"build": "npm run build:api && npm run build:ts" | ||
}, | ||
"keywords": [ | ||
"tableland", | ||
"sql", | ||
"ethereum", | ||
"database" | ||
], | ||
"license": "MIT AND Apache-2.0", | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.19.3", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@babel/register": "^7.18.9", | ||
"@tableland/local": "0.0.0-pre13.9", | ||
"@types/chai": "^4.2.22", | ||
"@types/jest": "^29.0.3", | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.8.2", | ||
"@types/tape": "^4.13.2", | ||
"@typescript-eslint/eslint-plugin": "^5.39.0", | ||
"@typescript-eslint/parser": "^5.30.5", | ||
"add-js-extension": "^1.0.4", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^29.0.3", | ||
"buffer": "^6.0.3", | ||
"esbuild": "^0.15.10", | ||
"eslint": "^8.19.0", | ||
"@databases/escape-identifier": "^1.0.3", | ||
"@databases/sql": "^3.2.0", | ||
"@ethersproject/experimental": "^5.7.0", | ||
"@tableland/local": "^0.0.5-pre.2", | ||
"@types/assert": "^1.5.6", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.11.17", | ||
"@typescript-eslint/eslint-plugin": "^5.47.0", | ||
"@typescript-eslint/parser": "^5.47.0", | ||
"assert": "^2.0.0", | ||
"c8": "^7.12.0", | ||
"d1-orm": "^0.7.1", | ||
"eslint": "^8.30.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-config-standard-with-typescript": "^23.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-n": "^15.3.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"events": "^3.3.0", | ||
"flush-promises": "^1.0.2", | ||
"jest": "^29.0.3", | ||
"jest-fetch-mock": "^3.0.3", | ||
"jest-ts-webcompat-resolver": "^1.0.0", | ||
"prettier": "^2.7.1", | ||
"tape": "^5.6.1", | ||
"ts-jest": "^29.0.1", | ||
"mocha": "^10.2.0", | ||
"openapi-typescript": "^6.1.0", | ||
"prettier": "^2.8.1", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.10", | ||
"typedoc-plugin-markdown": "^3.13.4", | ||
"typescript": "^4.7.4" | ||
"typedoc": "^0.23.23", | ||
"typescript": "^4.9.4" | ||
}, | ||
"dependencies": { | ||
"@stablelib/base64": "^1.0.1", | ||
"@tableland/evm": "^3.0.0", | ||
"camelcase": "^6.3.0", | ||
"ethers": "^5.6.9", | ||
"siwe": "^2.0.5" | ||
"@tableland/evm": "^4.0.0-pre.1", | ||
"@tableland/sqlparser": "^1.0.0-pre.0", | ||
"camelize-ts": "^2.2.0", | ||
"ethers": "^5.7.2" | ||
} | ||
} |
116
README.md
@@ -5,8 +5,9 @@ # @tableland/sdk | ||
[](https://github.com/tablelandnetwork/js-tableland/actions/workflows/test.yml) | ||
[](https://github.com/tablelandnetwork/js-tableland/actions/workflows/docs.yml) | ||
[](./package.json) | ||
[](https://github.com/tablelandnetwork/js-tableland/actions/workflows/publish.yml) | ||
[](./LICENSE) | ||
[](./package.json) | ||
[](https://github.com/tablelandnetwork/js-tableland/releases/latest) | ||
[](https://github.com/RichardLitt/standard-readme) | ||
A TypeScript/JavaScript library for creating and querying Tables on the Tableland network. | ||
> A D1Database client and helpers for the Tableland network | ||
@@ -18,6 +19,5 @@ # Table of Contents | ||
- [Background](#background) | ||
- [Usage](#usage) | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [Feedback](#feedback) | ||
- [Development](#development) | ||
- [Contributing](#contributing) | ||
@@ -28,75 +28,79 @@ - [License](#license) | ||
The Tableland project provides a zero-config Typescript/Javascript SDK that make it easy to interact with the Tableland network from Ethereum-based applications. The [`@tableland/sdk`](https://github.com/tablelandnetwork/js-tableland) SDK should feel comfortable to developers already familiar with the [`ethersjs` Javascript library](https://docs.ethers.io/). The Tableland SDK provides a small but powerful API surface that integrates nicely with existing ETH development best practices. | ||
The `@tableland/sdk` library provides a minimal client and SDK that implements the D1Database interface on top of the Tableland network. It can be used as a drop-in replacement to work with many community-created D1 tools and libraries. It also comes with a set of helper utilities for working with Tableland. | ||
Simply import the library, connect to the Tableland network, and you are ready to start creating and updating tables. | ||
> Note: Interested in supporting additional chains and ecosystems? Create an Issue and let us know! | ||
# Install | ||
Installation is easy using npm or yarn. An ES bundle is also available for those operating purely in a browser environnement. | ||
```bash | ||
npm i @tableland/sdk | ||
``` | ||
:warning: Please ensure you are using Node 18 (or newer). | ||
If you are using versions prior to v18, you will need to provide global access to `fetch`. Instructions on how to implement this can be found in the `node-fetch` documentation [here](https://github.com/node-fetch/node-fetch#providing-global-access). For Node 16, in particular, you can try using the [`--experimental-fetch`](https://nodejs.org/fa/blog/release/v16.15.0/#add-fetch-api) flag, which installs the `fetch`, `Request`, `Response`, `Headers`, and `FormData` globals. | ||
> Note: Not seeing the build type you need for your project or idea? Let us know, we're happy to work with you to improve the SDK usability! | ||
# Usage | ||
Most common Tableland usage patterns will follow something like the following. In general, you'll need to connect, create, mutate, and query your tables. In that order :) | ||
```ts | ||
import { Database } from "@tableland/sdk"; | ||
import { providers } from "ethers"; | ||
```typescript | ||
import { connect } from "@tableland/sdk"; | ||
// A Web3Provider wraps a standard Web3 provider, which is | ||
// what MetaMask injects as window.ethereum into each page | ||
const provider = new providers.Web3Provider(window.ethereum); | ||
// Connect | ||
const connection = await connect({ network: "testnet" }); | ||
// MetaMask requires requesting permission to connect users accounts | ||
await provider.send("eth_requestAccounts", []); | ||
// Create | ||
await connection.create("id int primary key, val text"); | ||
// The MetaMask plugin also allows signing transactions to | ||
// pay for gas when calling smart contracts like the @tableland | ||
// registry... | ||
const signer = provider.getSigner(); | ||
const db = new Database({ signer }); | ||
// Write | ||
const write = await connection.write( | ||
"INSERT INTO test_1 (colname) values (val1);" | ||
); | ||
console.log(write); | ||
// {"hash": "blahhash"} | ||
// Read | ||
const query = await connection.read("SELECT * FROM test_1;"); | ||
console.log(query); | ||
// {columns: [{name: "colname"}], rows: ["val1"]} | ||
// Prepared statements allow users to reuse query logic by binding values | ||
const stmt = db.prepare("SELECT name, age FROM users_80001_1 LIMIT ?").bind(3); | ||
const { results } = await stmt.all(); | ||
console.log(results); | ||
/* | ||
[ | ||
{ | ||
name: "John", | ||
age: 42, | ||
}, | ||
{ | ||
name: "Anthony", | ||
age: 37, | ||
}, | ||
{ | ||
name: "Dave", | ||
age: 29, | ||
}, | ||
] | ||
*/ | ||
``` | ||
# API | ||
Full library documentation [available on GitHub](https://tablelandnetwork.github.io/js-tableland/), and | ||
general docs, examples, and more [available on our docs site](https://docs.tableland.xyz). | ||
# Feedback | ||
# Install | ||
Reach out with feedback and ideas: | ||
You can install via npm/yarn: | ||
- [twitter.com/tableland\_\_](https://twitter.com/tableland__) | ||
- [Create a new issue](https://github.com/tablelandnetwork/js-tableland/issues) | ||
```bash | ||
npm i @tableland/sdk | ||
# yarn add @tableland/sdk | ||
``` | ||
# Contributing | ||
Or directly via GitHub: | ||
PRs accepted. | ||
```bash | ||
npm i tablelandnetwork/js-tableland | ||
``` | ||
To get started clone this repo, then do: | ||
# Development | ||
```bash | ||
# use the latest node and npm LTS | ||
Get started by cloning, installing, building, and testing the project: | ||
```shell | ||
git clone git@github.com:tablelandnetwork/js-tableland.git | ||
cd js-tableland | ||
npm install | ||
npm run build | ||
# see if everything is working | ||
npm test | ||
``` | ||
# Contributing | ||
PRs accepted. | ||
Small note: If editing the README, please conform to the | ||
@@ -103,0 +107,0 @@ [standard-readme](https://github.com/RichardLitt/standard-readme) specification. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4
23
109
5
215860
127
1
4582
2
+ Addedcamelize-ts@^2.2.0
+ Added@openzeppelin/contracts@4.8.3(transitive)
+ Added@tableland/evm@4.5.1(transitive)
+ Added@tableland/sqlparser@1.4.1(transitive)
+ Addedcamelize-ts@2.5.0(transitive)
- Removed@stablelib/base64@^1.0.1
- Removedcamelcase@^6.3.0
- Removedsiwe@^2.0.5
- Removed@noble/hashes@1.7.1(transitive)
- Removed@spruceid/siwe-parser@2.1.2(transitive)
- Removed@stablelib/base64@1.0.1(transitive)
- Removed@stablelib/binary@1.0.1(transitive)
- Removed@stablelib/int@1.0.1(transitive)
- Removed@stablelib/random@1.0.2(transitive)
- Removed@stablelib/wipe@1.0.1(transitive)
- Removed@tableland/evm@3.0.3(transitive)
- Removedapg-js@4.4.0(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedsiwe@2.3.2(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedvalid-url@1.0.9(transitive)
Updated@tableland/evm@^4.0.0-pre.1
Updatedethers@^5.7.2