Catalog npm
Back to packageRELEASE DETAILS

0.0.5

npm

@0xintuition/slang-cli

web3 scaffolding made easy

ceramiccomposedbintuitionipfslitweb3
Published7 Apr 2023
Direct dependencies48
Transitive dependenciesNot calculated

README

Current package documentation
   .---. ,-.      .--.  .-. .-.  ,--,              ,--,  ,-.    ,-.
  ( .-._)| |     / /\ \ |  \| |.' .'             .' .')  | |    |(|
 (_) \   | |    / /__\ \|   | ||  |  __ ____.___ |  |(_) | |    (_)
 _  \ \  | |    |  __  || |\  |\  \ ( _)`----==='\  \    | |    | |
( `-'  ) | `--. | |  |)|| | |)| \  `-) )          \  `-. | `--. | |
 `----'  |( __.'|_|  (_)/(  (_) )\____/            \____\|( __.'`-'
         (_)           (__)    (__)                      (_)

Web3 Backends Made Easy

Commands

  • slang composedb:generate : Generates ComposeDB composites, types, and a full-featured sql client for reads

more coming soon...

Using the Generator

  1. Install Slang globally

    npm install -g @0xintuition/slang-cli
    
  2. Fill in a .env file with the following content (replace with your info):

    COMPOSEDB_API_URL="http://localhost:7007"
    COMPOSEDB_DB_URL="sqlite:///Users/<your_username>/.ceramic/indexing.sqlite"
    COMPOSEDB_PRIVATE_KEY=<your_composedb_private_key>
    
  3. Define a /schema folder at the root of your package/repository and add some schemas

    • All files must ordered in the way they are to be deployed (see the test package for example)

    • Dependent model id's can be referenced by using a template string with the model name EG: id: "${List}"

  4. Run a local ComposeDB instance

    npx @ceramicnetwork/cli daemon
    
    • Make sure that the admin did is set, for more details check out the composedb docs
  5. Run slang composedb:generate and you're off to the races!

Using the Client

Check out the code in __generated__/ after running the generator to see what's available.

Reads

Reads can be done by using the Prisma client included in the distributed client like so:

const client = new Client(...stuff)
const dbStuff = await client.prisma.myModelName.findMany(...moreStuff)

Since the stream_content column in the database is JSON, the resulting data is untyped. To parse this into a type-safe format, helper functions are included with each service that add a data field with the typed object. For example:

const client = new Client(...stuff)
const dbStuff = await client.prisma.myModelName.findMany(...moreStuff)
/**
 * dbStuff = [
 * {
 *   stream_id: string,
 *   controller_did: string,
 *   stream_content: any,
 *  ...
 * }
 * ...]
 */
const parsedDBStuff = dbStuff.map((s) => client.myModelNameService.parse(s))
/**
 * dbStuff = [
 * {
 *   stream_id: string,
 *   controller_did: string,
 *   stream_content: any,
 *   data: MyModelType
 *  ...
 * }
 * ...]
 */

I realize this is not ideal, however it will improve soon as Prisma has been dramatically improving JSON support.

Writes

WRITES MUST BE DONE THROUGH THE COMPOSEDB CLIENT (NOT PRISMA)!!!!!!

Nice types are included to make this very simple. For example:

const client = new Client(...stuff)
const resp = await client.myModelNameService.create({
  content: {
    ...myModelFieldsForCreation,
  },
})

Zod is used to validate the input fields and ensure they conform to the model schemas you defined.

Current Issues

  • SQLite's dynamic typing causes issues with reading integers that are greater than the 32bit max issue. This will cause problems with ComposeDB, however the Postgres backend works swimmingly!

Future Plans

  • Transpiled client code (currently output in typescript)

  • Add Lit command to generate relay code for interacting with PKP's + walletless onboarding

  • Add --encrypt flag to composedb:generate to automatically handle encrypting/decrypting ComposeDB data

  • Whatever else you might suggest!

Special Thanks

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 48

Native requirements
48 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ejs
Environment
{
  "local_name": "ejs",
  "alias": false,
  "peer_metadata": null
}
^3.1.9runtime
zod
Environment
{
  "local_name": "zod",
  "alias": false,
  "peer_metadata": null
}
^3.20.6runtime
dids
Environment
{
  "local_name": "dids",
  "alias": false,
  "peer_metadata": null
}
^4.0.0runtime
dotenv
Environment
{
  "local_name": "dotenv",
  "alias": false,
  "peer_metadata": null
}
^16.0.3runtime
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
^5.7.0runtime
figlet
Environment
{
  "local_name": "figlet",
  "alias": false,
  "peer_metadata": null
}
^1.5.2runtime
graphql
Environment
{
  "local_name": "graphql",
  "alias": false,
  "peer_metadata": null
}
^16.6.0runtime
punycode
Environment
{
  "local_name": "punycode",
  "alias": false,
  "peer_metadata": null
}
^2.3.0runtime
@oclif/core
Environment
{
  "local_name": "@oclif/core",
  "alias": false,
  "peer_metadata": null
}
^2runtime
did-session
Environment
{
  "local_name": "did-session",
  "alias": false,
  "peer_metadata": null
}
^2.0.0runtime
graphql-tag
Environment
{
  "local_name": "graphql-tag",
  "alias": false,
  "peer_metadata": null
}
^2.12.6runtime
uint8arrays
Environment
{
  "local_name": "uint8arrays",
  "alias": false,
  "peer_metadata": null
}
^4.0.3runtime
@didtools/cacao
Environment
{
  "local_name": "@didtools/cacao",
  "alias": false,
  "peer_metadata": null
}
^2.0.0runtime
@tuplo/envsubst
Environment
{
  "local_name": "@tuplo/envsubst",
  "alias": false,
  "peer_metadata": null
}
^1.15.2runtime
key-did-resolver
Environment
{
  "local_name": "key-did-resolver",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
@composedb/client
Environment
{
  "local_name": "@composedb/client",
  "alias": false,
  "peer_metadata": null
}
^0.4.3runtime
@stablelib/random
Environment
{
  "local_name": "@stablelib/random",
  "alias": false,
  "peer_metadata": null
}
^1.0.2runtime
@oclif/plugin-help
Environment
{
  "local_name": "@oclif/plugin-help",
  "alias": false,
  "peer_metadata": null
}
^5runtime
@composedb/devtools
Environment
{
  "local_name": "@composedb/devtools",
  "alias": false,
  "peer_metadata": null
}
^0.4.3runtime
@graphql-tools/load
Environment
{
  "local_name": "@graphql-tools/load",
  "alias": false,
  "peer_metadata": null
}
^7.8.12runtime
google-auth-library
Environment
{
  "local_name": "google-auth-library",
  "alias": false,
  "peer_metadata": null
}
^8.7.0runtime
@graphql-codegen/add
Environment
{
  "local_name": "@graphql-codegen/add",
  "alias": false,
  "peer_metadata": null
}
^4.0.1runtime
@graphql-codegen/cli
Environment
{
  "local_name": "@graphql-codegen/cli",
  "alias": false,
  "peer_metadata": null
}
^3.2.1runtime
@graphql-tools/utils
Environment
{
  "local_name": "@graphql-tools/utils",
  "alias": false,
  "peer_metadata": null
}
^9.2.1runtime
@oclif/plugin-plugins
Environment
{
  "local_name": "@oclif/plugin-plugins",
  "alias": false,
  "peer_metadata": null
}
^2.4.2runtime
@ceramicnetwork/common
Environment
{
  "local_name": "@ceramicnetwork/common",
  "alias": false,
  "peer_metadata": null
}
^2.23.0runtime
detect-package-manager
Environment
{
  "local_name": "detect-package-manager",
  "alias": false,
  "peer_metadata": null
}
^2.0.1runtime
@lit-protocol/constants
Environment
{
  "local_name": "@lit-protocol/constants",
  "alias": false,
  "peer_metadata": null
}
^2.1.43runtime
@ceramicnetwork/streamid
Environment
{
  "local_name": "@ceramicnetwork/streamid",
  "alias": false,
  "peer_metadata": null
}
^2.14.0runtime
@composedb/devtools-node
Environment
{
  "local_name": "@composedb/devtools-node",
  "alias": false,
  "peer_metadata": null
}
^0.4.3runtime
key-did-provider-ed25519
Environment
{
  "local_name": "key-did-provider-ed25519",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
@ceramicnetwork/http-client
Environment
{
  "local_name": "@ceramicnetwork/http-client",
  "alias": false,
  "peer_metadata": null
}
^2.20.0runtime
@graphql-codegen/typescript
Environment
{
  "local_name": "@graphql-codegen/typescript",
  "alias": false,
  "peer_metadata": null
}
^3.0.2runtime
@lit-protocol/contracts-sdk
Environment
{
  "local_name": "@lit-protocol/contracts-sdk",
  "alias": false,
  "peer_metadata": null
}
2.1.30runtime
@lit-protocol/lit-node-client
Environment
{
  "local_name": "@lit-protocol/lit-node-client",
  "alias": false,
  "peer_metadata": null
}
^2.1.43runtime
@graphql-codegen/plugin-helpers
Environment
{
  "local_name": "@graphql-codegen/plugin-helpers",
  "alias": false,
  "peer_metadata": null
}
^4.0.0runtime
@graphql-tools/graphql-file-loader
Environment
{
  "local_name": "@graphql-tools/graphql-file-loader",
  "alias": false,
  "peer_metadata": null
}
^7.5.16runtime
@graphql-codegen/typescript-operations
Environment
{
  "local_name": "@graphql-codegen/typescript-operations",
  "alias": false,
  "peer_metadata": null
}
^3.0.1runtime
graphql-codegen-typescript-validation-schema
Environment
{
  "local_name": "graphql-codegen-typescript-validation-schema",
  "alias": false,
  "peer_metadata": null
}
^0.7.1runtime
shx
Environment
{
  "local_name": "shx",
  "alias": false,
  "peer_metadata": null
}
^0.3.3development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.9.1development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.8.4development
bun-types
Environment
{
  "local_name": "bun-types",
  "alias": false,
  "peer_metadata": null
}
^0.5.0development
@types/ejs
Environment
{
  "local_name": "@types/ejs",
  "alias": false,
  "peer_metadata": null
}
^3.1.2development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.0.2development
@composedb/types
Environment
{
  "local_name": "@composedb/types",
  "alias": false,
  "peer_metadata": null
}
^0.4.3development
@types/chalk-animation
Environment
{
  "local_name": "@types/chalk-animation",
  "alias": false,
  "peer_metadata": null
}
^1.6.1development
prettier-plugin-organize-imports
Environment
{
  "local_name": "prettier-plugin-organize-imports",
  "alias": false,
  "peer_metadata": null
}
^3.2.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "255f0df4d2284e16d728ca55eebbf7d2910445fc",
  "tarball": "https://registry.npmjs.org/@0xintuition/slang-cli/-/slang-cli-0.0.5.tgz",
  "fileCount": 12,
  "integrity": "sha512-JV2Gu5MM0eEtIaxYHitoAyFM/UXzWDQJKgBollwg5MAl3W8ghjj/hJx6h2zCsMLL1etfRVc+U9kyqE0onvBpxg==",
  "signatures": [
    {
      "sig": "MEUCIAsQjIz7mzlwxWZmMUXBu28HNRs04Re69uXFgAhN6wGlAiEA4iJl2aea3nmlsFag6wzFG1++bxGE6pUiJzNtzNwIhHA=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 36595,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkL+HLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrCcQ//ckHtWYLY0LnpYzT6NhC1IVrQ6SoPwrUGeefjuVpg8lTaL8YZ\r\noo4KGgi4H1aotWn28Wj1+1QlhvKJUDn/hHulZh6kcvg11zJ1yxLSv3mmgpiY\r\nwg0AvhaAkNAF+Saj5ve8BHUbW/PWVMF6bMheQtK3CpiG1vA9ZEsR/+ib1o0U\r\n9L0Q//ifsxfRDf7CuiaRa70AUqvZIzoblOqycfQqcvLbH2/Nlc/M6nf+AeIC\r\n8ef0B5GgvC5pVSNZGdD8mPJzOZbaeYQnYprm8Xc4YcReyLAbENfEAa5jU1GT\r\nHD+6xZwd92WxAR4P7gRLPS+e34SM/kY43Vb5S6VboiNrtm/mu8NMCFgWPBMX\r\nFvMqlTlDBAqA+6QcyjpYkt0SwGvuMBhGNtc1Ux1IHFwdIPt1Wz2PQgFuCzoo\r\nqPRASBMLqCaI5jmF26RRI8i7tR9XiSXUgDvp+bUQi2x8cUb4ddYrmySkELCY\r\nu+7BlDa7v3+tSw/LfbwLXaI8FWWqNncMamMRuyPgpg6ibKICWmHbRn5VSdjL\r\nz3Lx1CJi23p96pMsMUDX9QSCOWciay4MumRuxhPOCAmrVaPqYD5M6JCWH33k\r\npe3Y+XAdD+x5fcGpClbkGIerFY2rwkC25/94VEncjGDchQ1SfZ2BluPbPU35\r\nRczH2kXn8MJw6yGLqGIJ8NTqkP2x48lpnOk=\r\n=NkDP\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
0xintuition/slang

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 08:57 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:d6bcbacbbc2e96f92901d65a38b3adbc4b6a368611b8ee09143e59c1bdb214c2

Other collected versions

0.0.87 Apr0.0.77 Apr0.0.67 Apr0.0.422 Mar0.0.322 Mar0.0.221 MarView all collected versions →