Skip to content

Commit

Permalink
CLI commands & datetime helpers in the Javascript SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
1pxone committed Jan 9, 2025
1 parent f276c07 commit 70d108d
Show file tree
Hide file tree
Showing 21 changed files with 734 additions and 189 deletions.
9 changes: 9 additions & 0 deletions .changeset/fifty-deers-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@rushdb/javascript-sdk': minor
'rushdb-dashboard': minor
'rushdb-core': minor
'rushdb-website': minor
'rushdb-docs': minor
---

CLI commands & datetime helpers in the Javascript SDK
22 changes: 13 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,34 @@ jobs:
with:
version: pnpm changeset version
publish: pnpm release --filter ./packages/javascript-sdk...
commit: "chore(release): version packages"
title: "chore(release): version packages"
commit: "chore(release): version packages v${{ steps.package-version.outputs.version }}"
title: "chore(release): version packages v${{ steps.package-version.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Check Tag Creation
id: check-tag
- name: Check Commit Type
id: check-commit
run: |
if git rev-parse "@rushdb/javascript-sdk@${{ steps.package-version.outputs.version }}" >/dev/null 2>&1; then
echo "has_tag=true" >> $GITHUB_OUTPUT
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
EXPECTED_MESSAGE="chore(release): version packages v${{ steps.package-version.outputs.version }}"
if [ "$COMMIT_MESSAGE" = "$EXPECTED_MESSAGE" ]; then
echo "is_version_bump=true" >> $GITHUB_OUTPUT
else
echo "has_tag=false" >> $GITHUB_OUTPUT
echo "is_version_bump=false" >> $GITHUB_OUTPUT
fi
- name: Check Commit Type
id: check-commit
run: |
if git log -1 --pretty=%B | grep -q "chore(release): version packages"; then
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
EXPECTED_MESSAGE="chore(release): version packages v${{ steps.package-version.outputs.version }}"
if [ "$COMMIT_MESSAGE" = "$EXPECTED_MESSAGE" ]; then
echo "is_version_bump=true" >> $GITHUB_OUTPUT
else
echo "is_version_bump=false" >> $GITHUB_OUTPUT
fi
fi
docker:
needs: release
Expand Down
56 changes: 56 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Code of Conduct

We value open collaboration and respect in all interactions. To foster a welcoming and productive community, all participants are expected to adhere to the following guidelines.

## Scope

This Code of Conduct applies to all contributors, including maintainers, users, and collaborators, in all project spaces and public communication channels.

## Our Standards

1. **Respectful Communication**
- Use welcoming and inclusive language.
- Be respectful of differing viewpoints and experiences.
- Refrain from personal attacks or derogatory comments.

2. **Collaboration**
- Provide constructive feedback and suggestions.
- Share knowledge and help others grow within the community.

3. **Responsibility**
- Take responsibility for your actions and their impact on others.
- Report issues or concerns to maintainers or moderators.

4. **Inclusivity**
- Actively seek to include and empower underrepresented groups.
- Avoid biased or discriminatory behavior.

## Unacceptable Behavior

Examples of unacceptable behavior include:

- Harassment, bullying, or intimidation.
- Disrespectful, offensive, or inappropriate comments.
- Discriminatory jokes or language.
- Publishing private information without explicit permission.

## Reporting Violations

If you observe or experience behavior that violates this Code of Conduct, please report it by:

- Contacting the project maintainer: [tg:onepx](https://t.me/onepx)
- Messaging via LinkedIn: [linkedin.com/onepx](https://linkedin.com/in/onepx)

We take all reports seriously and will investigate and address them promptly.

## Enforcement

Participants found to be in violation of this Code of Conduct may face actions such as:

- A private warning or reprimand.
- Temporary or permanent ban from project spaces.
- Removal of contributions or privileges.

## Acknowledgments

This Code of Conduct is adapted from widely recognized community guidelines to reflect our commitment to a healthy and collaborative environment.
43 changes: 43 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Contribution Guidelines for RushDB

Thank you for your interest in contributing to RushDB! To ensure a smooth contribution process, please follow the checklist below when reporting issues or submitting changes.

## Reporting Issues

When reporting an issue, include the following information:

1. **Minimum Reproducible Data Set**
- Provide a small JSON or CSV dataset if the issue is related to the core, dashboard, or SDK.
- Ensure the dataset highlights the problem clearly.

2. **RushDB Version**
- Specify the version of RushDB you are using:
- **Cloud**: Mention if you are using the latest cloud version.
- **Self-hosted**: Provide the tag from Docker Hub or the SDK version.

3. **Steps to Reproduce**
- Give a detailed explanation of how to reproduce the issue.
- Include any configurations, commands, or environment settings.

4. **Query Examples**
- If applicable, include specific queries that trigger the error.

5. **Minimum Repository (if SDK-related)**
- For issues related to the SDK, a minimal GitHub repository demonstrating the bug may be required.

## Submitting Changes

Before submitting a pull request:

- Ensure your code adheres to the project's coding standards.
- Include unit tests for new functionality or bug fixes.
- Update documentation if necessary.

## Contact Information

For urgent issues or further assistance, you can reach out directly:

- **Telegram**: [tg:onepx](https://t.me/onepx)
- **LinkedIn**: [linkedin.com/onepx](https://linkedin.com/in/onepx)

We appreciate your contributions and look forward to your feedback!
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,62 @@ Before running the container, ensure you provide the following required environm

---

### **CLI Commands**

The RushDB CLI allows you to manage users in self-hosted installations. Below are the available commands:

#### 2.1 **Create a New User**

Command:
```bash
rushdb create-user <login> <password>
```

Example:
```bash
rushdb create-user [email protected] securepassword123
```

This command creates a new user with the specified login and password. It is only allowed in self-hosted setups.

#### 2.2 **Update User Password**

Command:
```bash
rushdb update-password <login> <newPassword>
```

Example:
```bash
rushdb update-password [email protected] newsecurepassword456
```

This command updates the password for an existing user identified by the provided login. Like `create-user`, this command is restricted to self-hosted environments.

---

### 3. **Docker Usage**

To use the CLI inside a Docker container, ensure the image is built with the symbolic link for the CLI:

```bash
docker build -t rushdb-core .
```

Run the container and execute CLI commands:

```bash
docker run --rm rushdb-core rushdb create-user [email protected] securepassword123
```

Or:

```bash
docker run --rm rushdb-core rushdb update-password [email protected] newsecurepassword456
```

---

## Usage

1. **Obtain an API Token**:
Expand Down
1 change: 1 addition & 0 deletions packages/javascript-sdk/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"rules": {
"prefer-const": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/consistent-type-imports": [
2,
{ "prefer": "type-imports" }
Expand Down
9 changes: 9 additions & 0 deletions packages/javascript-sdk/src/sdk/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
import type { Transaction } from './transaction.js'

import { RestApiProxy } from '../api/rest-api-proxy.js'
import { idToDate, idToTimestamp } from './utils.js'

type DBRecordInternalProps<S extends Schema = Schema> = {
readonly __id: string
Expand Down Expand Up @@ -144,6 +145,14 @@ export class DBRecordInstance<S extends Schema = Schema> extends RestApiProxy {
this.searchParams = searchParams
}

__date() {
return idToDate(this.data!.__id)
}

__timestamp() {
return idToTimestamp(this.data!.__id)
}

async delete(transaction?: Transaction | string) {
if (this.data) {
return await this.apiProxy.records.deleteById(this.data.__id, transaction)
Expand Down
4 changes: 4 additions & 0 deletions platform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,9 @@ WORKDIR /app/platform/core
# Expose port
EXPOSE 3000

# Create a symbolic link for the CLI
RUN ln -s /app/platform/core/dist/cli.js /usr/local/bin/rushdb \
&& chmod +x /usr/local/bin/rushdb

# Start the application
CMD ["node", "dist/main.js"]
Loading

0 comments on commit 70d108d

Please sign in to comment.