npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brx-node

v0.6.7-development

Published

Main BRX-AI Node interface

Downloads

283

Readme

brx-node

brx-node logo

Status

npm package Downloads

BRX-NODE.js official interaction Module

brx-node is the official interaction module for BRX-NODE.js. It is used for interacting with the BRX AI API and includes functionalities such as sending requests and receiving responses.

We're currently in BETA expect package changes and improvements in the future!

You can install brx-node using the following commands:

Install

For npm:

npm install brx-node -s

For yarn:

yarn install brx-node -s

For pnpm:

pnpm install brx-node -D

Usage

Here is how you can interact with the BRX AI API using this module:

import BRX from 'brx-node';

const brx = new BRX(process.env.CUR_API_KEY!, { verbose: true });

const result = await brx.execute(query);

//=> 'Response from BRX'

CLI terminal Example for query rebuilds

import readline from 'readline';
import BRX from 'brx-node';
import { objToMap, objToMapField } from 'brx-node';

let input_fields: any[] = [];  // Initialized input_fields as an array
let outputObject:any;
let brx_schema_export:any = '';

let brx;

brx = new BRX("BRX-API-KEY", { verbose:true });

async function getUserInput(question:string) {
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });

    return new Promise<string>((resolve) => rl.question(question, (ans) => {
        rl.close();
        resolve(ans);
    }));
}

async function update_inputs() {
  for (const input of input_fields) {
    // Get value for current input field from user 
    const value = await getUserInput(`Please enter the value for ${input.name}: `);
  
    // Update the fieldValue for current input field in the map
    let currentSchema = outputObject.userSchemaInteract.schemas.get(input.entry_key);
  
    if (currentSchema && currentSchema.schemaFields instanceof Map) {
      let currentField = currentSchema.schemaFields.get(`${input.name}`);

      if (currentField) {
        // Update the existing fieldValue
        currentField.fieldValue = value; 
      } else {
        // fieldValue not present currently, add a new one
        currentSchema.schemaFields.set(`${input.name}`, {fieldValue: value});
      }
    }
  }
}

const query_rebuilder = async () => {
  // console.log("starting rebuild: "  , input_fields)
  let json_export:any = JSON.parse(brx_schema_export)
  // let json_export:any =  brx_schema_export
  // console.log(json_export)
  outputObject = {
      userSchemaInteract: {
        mainBrxId: json_export.schemas.mainBrxId,
        schemas: objToMap(
          json_export.schemas.schemas.data.reduce((schemas:any, schemaEntry:any) => {
            const [schemaKey, schemaData] = schemaEntry;
            const newBrxName = schemaKey;

            const schemaFields = objToMapField(
              schemaData.schemaFields.data.reduce((fields:any, fieldEntry:any) => {
                const [fieldKey, fieldData] = fieldEntry;          
                input_fields.push({ type: fieldData.fieldValueDataType, name: fieldKey , entry_key: schemaKey })
                             
                fields[fieldKey] = { ...fieldData, fieldValue: fieldKey };
                return fields;
              }, {})
            );

            schemas[schemaKey] = {
              brxId: schemaData.brxId,
              brxName: newBrxName,
              schemaFields,
            };

            return schemas;
          }, {})
        ),
      },
    };
}

(async function() {
    brx_schema_export = await getUserInput("Please enter the brx_schema_export: ");

    await query_rebuilder();

    // console.log("After Rebuilder")
    // console.log(input_fields)

    await update_inputs();

    console.log(outputObject)

    const result = await brx.execute(outputObject);
    console.log("After Execution");
    console.log(result);
}());

Functions

The main class in this module is BRX. Here are the functions that you can use:

BRX.constructor(accessToken: string, options?: { use_brx_key?: boolean, verbose?: boolean, send_local?: boolean }): BRX

Creates an instance of the BRX class.

Parameters:

  • accessToken (string): The access token to interact with the BRX AI API.
  • options (object): An optional parameter for various options. The fields can be:
    • use_brx_key (boolean): Whether to use the BRX API key for authorization. Default is true.
    • verbose (boolean): Whether to log additional details. Default is false.
    • send_local (boolean): Whether to use a local connection string. Default is false.

Example:

const brx = new BRX("your_access_token", { verbose: true, send_local: false });

BRX.execute(query: queryStreamRequest): Promise<any>

Executes a given query and returns a promise for the response.

Parameters:

  • query (queryStreamRequest): The query you want to execute.

Example:

const result = await brx.execute(query);

BRX.modify

BRX.modify(brxid: string, userInput: object , process_in:processType): Promise<any>

Under construction, check future versions for implementation

BRX.create(brk_gen:brx , brxFieldData:schema): Promise<any>

Create schema for your BRX.

Parameters:

  • brk_gen (brx): BRX generation data
  • brxFieldData(schema): Schema data for fields in BRX

Example:

await brx.create(brx_gen, brxFieldData);

BRX.validate(brxid: string, userInput: object): Promise<any>

Under construction, check future versions for implementation

Objects

Several different objects are imported and used within the BRX class. These objects include brx, schema, userSchemaInteract and many more. See the enclosed object files 'brx.ts' and 'api.interact.ts' for detailed information on all these objects and their properties.