Skip to content

Commit

Permalink
Update readme, cleanups, build public image
Browse files Browse the repository at this point in the history
  • Loading branch information
1pxone committed Jan 2, 2025
1 parent b8e946b commit c1bbcd7
Show file tree
Hide file tree
Showing 160 changed files with 2,023 additions and 3,468 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Publish Docker Image

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: Install dependencies
run: |
npm install -g pnpm
pnpm install
- name: Bump version using Changeset
run: |
npx changeset version
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Release version bump"
git push
- name: Extract version from package.json
id: get-version
run: echo "VERSION=$(jq -r '.version' ./package.json)" >> $GITHUB_ENV

- name: Build Docker image
run: |
docker build -t rushdb/platform:$VERSION -t rushdb/platform:latest .
- name: Publish Docker image
run: |
echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
docker push rushdb/platform:$VERSION
docker push rushdb/platform:latest
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node-linker=hoisted
shamefully-hoist=true
strict-peer-dependencies=false
auto-install-peers=true
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "collect-toolkit",
"name": "rushdb",
"private": true,
"license": "MIT",
"scripts": {
Expand All @@ -17,8 +17,8 @@
"release": "changeset publish",
"version:dev": "changeset version --snapshot dev",
"release:dev": "changeset publish --tag dev",
"prepare": "husky install",
"reinstall": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + && pnpm i"
"reinstall": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + && pnpm i",
"docker:build:platform": "docker build -t platform -f platform/Dockerfile ."
},
"devDependencies": {
"@changesets/cli": "^2.27.10",
Expand All @@ -37,9 +37,8 @@
"husky": "^8.0.3",
"jest": "29.5.0",
"jest-ts-webcompat-resolver": "1.0.0",
"prettier": "3.2.5",
"prettier": "^3.4.2",
"rimraf": "5.0.1",
"tsup": "^8.3.5",
"typescript": "5.7.2"
},
"packageManager": "[email protected]",
Expand All @@ -48,6 +47,10 @@
"node": ">=18.0.0 <=22.x.x"
},
"workspaces": [
"packages/*"
"packages/*",
"platform/*",
"docs",
"website",
"examples/*"
]
}
114 changes: 68 additions & 46 deletions packages/javascript-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

![RushDB Logo](https://raw.githubusercontent.com/rush-db/rushdb/main/rushdb-logo.svg)

# RushDB SDK
# RushDB SDK for JavaScript and TypeScript

> The RushDB.com SDK for JavaScript and TypeScript
[![NPM Version](https://img.shields.io/npm/v/%40collect.so%2Fjavascript-sdk)](https://www.npmjs.com/package/@rushdb/javascript-sdk)
[![NPM Version](https://img.shields.io/npm/v/%40rushdb%2Fjavascript-sdk)](https://www.npmjs.com/package/@rushdb/javascript-sdk)
[![License](https://img.shields.io/badge/License-MIT-blue)](#license "Go to license section")

![NPM Downloads](https://img.shields.io/npm/dw/%40collect.so%2Fjavascript-sdk)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40collect.so%2Fjavascript-sdk)
![NPM Downloads](https://img.shields.io/npm/dw/%40rushdb%2Fjavascript-sdk)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40rushdb%2Fjavascript-sdk)


[![Made with Node](https://img.shields.io/badge/dynamic/json?label=node&query=%24.engines%5B%22node%22%5D&url=https%3A%2F%2Fraw.githubusercontent.com%2Fcollect-so%2Fcollect%2Fmaster%2Fpackage.json)](https://nodejs.org "Go to Node.js homepage")
Expand All @@ -19,13 +17,17 @@
[Homepage](https://rushdb.com)[Blog](https://rushdb.com/blog)[Platform](https://app.rushdb.com)[Docs](https://docs.rushdb.com)[Examples](https://github.com/rush-db/rushdb/examples)
</div>

## Features
## Highlights

---
- **Automatic Type Inference**: Enjoy seamless type safety with automatic TypeScript inference.
- **Isomorphic Architecture**: Fully compatible with both server and browser environments.
- **Zero Dependencies**: Lightweight and efficient with no external dependencies.
- **No Configuration Needed**: Plug-and-play design requires no setup or configuration.
> **✨ No Configuration Needed**: Plug-and-play design requires no setup or configuration.
> **🤖 Automatic Type Inference**: Enjoy seamless type safety with automatic TypeScript inference.
> **↔️ Isomorphic Architecture**: Fully compatible with both server and browser environments.
> **🏋️ Zero Dependencies**: Lightweight and efficient with no external dependencies.


## Installation
Expand All @@ -51,51 +53,71 @@ pnmp add @rushdb/javascript-sdk

---

1. **Obtain RushDB API Token**: Grab your API token from the [Dashboard](https://app.rushdb.com).
2. **Setup RushDB Instance**: Initialize your RushDB instance with obtained token.
3. **(Optional) Define Data Models**: Tailor your data models to fit your needs.
4. **Manage Your Data**: Push, link, fetch, and manage your data effortlessly.
1. **Obtain API Token**: Grab one from the [Dashboard](https://app.rushdb.com).
2. **Build anything**: Easily push, search, and manage relationships within your data.

### TLDR;
```ts
/* ./your-app/src/db.ts */

import RushDB, { Model } from '@rushdb/javascript-sdk'

// Setup RushDB instance
const db = new RushDB("API_TOKEN")

// Optionaly define Model
export const UserRepo = new Model(
'USER',
{
name: { type: 'string' },
email: { type: 'string', uniq: true },
verified: { type: 'boolean', default: false },
hobbies: { type: 'string', multiple: true, requiered: false },
rating: { type: 'number', default: 1 },
created: { type: 'datetime', default: () => new Date().toISOString() },
password: { type: 'string' }
},
db
)

// Create new Record
const newUser = await UserRepo.create({
name: "John Galt",
email: '[email protected]',
hobbies: ['Programming', 'Hiking'],
password: '********'
// Setup SDK
const db = new RushDB("API_TOKEN", {
// This is the default URL; no need to provide it unless overriding.
url: "https://api.rushdb.com",
});

// Push any data, and RushDB will automatically flatten it into Records
// and establish relationships between them accordingly.
await db.records.createMany("COMPANY", {
name: 'Google LLC',
address: '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA',
foundedAt: '1998-09-04T00:00:00.000Z',
rating: 4.9,
DEPARTMENT: [{
name: 'Research & Development',
description:
'Innovating and creating advanced technologies for AI, cloud computing, and consumer devices.',
PROJECT: [{
name: 'Bard AI',
description:
'A state-of-the-art generative AI model designed for natural language understanding and creation.',
active: true,
budget: 1200000000,
EMPLOYEE: [{
name: 'Jeff Dean',
position: 'Head of AI Research',
email: '[email protected]',
dob: '1968-07-16T00:00:00.000Z',
salary: 3000000
}]
}]
}]
})


// Find Records by specific criteria
const matchedUsers = await UserRepo.find({
where: {
email: { $ne: '[email protected]' },
hobbies: { $in: ['Hiking'] },
rating: { $gte: 1.5 }
const matchedEmployees = await db.records.find({
labels: ['EMPLOYEE'],
where: {
position: { $contains: 'AI' },
PROJECT: {
DEPARTMENT: {
COMPANY: {
rating: { $gte: 4 }
}
}
}
}
})

const company = await db.records.findUniq('COMPANY', {
where: {
name: 'Google LLC'
}
})

// Manage relationships
await company.attach(matchedEmployees, { type: "WORKING_AT" })
```

<div align="center">
Expand Down
18 changes: 3 additions & 15 deletions packages/javascript-sdk/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import type {
InferType,
DBRecord,
UserProvidedConfig,
Relation
} from './src/sdk'
import type { InferType, DBRecord, UserProvidedConfig, Relation } from './src/sdk'

import {
DBRecordsBatchDraft,
DBRecordDraft,
RestAPI,
ApiResponse
} from './src/api'
import { DBRecordsBatchDraft, DBRecordDraft, RestAPI, ApiResponse } from './src/api'
import { HttpClient, HttpClientResponse } from './src/network/HttpClient'
import {
Model,
Expand Down Expand Up @@ -38,9 +28,7 @@ declare module '@rushdb/javascript-sdk' {
public getModel(label: string): Model
public getModels(): Map<string, Model>
public getInstance(token: string, config?: UserProvidedConfig): RushDB
public toInstance<Schema extends Schema = Schema>(
record: DBRecord<Schema>
): DBRecordInstance
public toInstance<Schema extends Schema = Schema>(record: DBRecord<Schema>): DBRecordInstance
}

export {
Expand Down
1 change: 0 additions & 1 deletion packages/javascript-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"build-esm": "mkdir -p esm && tsc -p tsconfig.esm.json",
"build-cjs": "mkdir -p cjs && tsc -p tsconfig.cjs.json",
"postbuild": "node scripts/post-build.js",
"dev": "tsup --watch",
"types:check": "tsc --noEmit",
"clean": "rm -rf ./dist ./node_modules/.cache ./coverage ./esm ./cjs ./types",
"flush": "rm -rf node_modules",
Expand Down
Loading

0 comments on commit c1bbcd7

Please sign in to comment.