Skip to content

Commit

Permalink
Merge pull request #23 from ubiquity-whilefoo/command-interface
Browse files Browse the repository at this point in the history
Command interface
  • Loading branch information
gentlementlegen authored Nov 25, 2024
2 parents b9fb9f1 + b4e35d9 commit c63d1fa
Show file tree
Hide file tree
Showing 20 changed files with 845 additions and 1,023 deletions.
59 changes: 0 additions & 59 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config: KnipConfig = {
ignore: ["**/__mocks__/**", "**/__fixtures__/**", "src/types/database.ts", "dist/**"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier"],
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@typescript-eslint/eslint-plugin", "@typescript-eslint/parser", "ts-node"],
eslint: true,
};

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ junit.xml
cypress/screenshots
.dev.vars
/tests/http/http-client.private.env.json
.wrangler
.wrangler
test-dashboard.md
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@ The following commands are allowed:
```

## Running locally

### Supabase types

You can run the type generations against a local database with

```shell
yarn supabase:generate:local
```

Or against an instance by setting the `SUPABASE_ACCESS_TOKEN` and `SUPABASE_PROJECT_ID` in your `.env` file

```shell
yarn prebuild
```

### Worker

Start the Worker by running

```shell
yarn dev
```

### Make requests

To trigger the worker, `POST` requests should be made to http://localhost:4000 with a `Content-Type: application/json`
header and a body looking like

```json
{
"stateId": "",
Expand All @@ -39,9 +48,11 @@ header and a body looking like
"ref": ""
}
```

For convenience, you can find an `.http` file with a valid request [here](/tests/http/request.http).

## Configuration

A valid configuration can be like:

```yaml
Expand All @@ -52,10 +63,11 @@ A valid configuration can be like:
```
## Testing
### Jest
To start Jest tests, run
```shell
yarn test
```
```
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import tsEslint from "typescript-eslint";
import eslint from "@eslint/js";
import sonarjs from "eslint-plugin-sonarjs";
import checkFile from "eslint-plugin-check-file";

export default tsEslint.config({
plugins: {
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts", "src/types/database.ts", "dist/**", "coverage/**"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
parserOptions: {
projectService: {
defaultProject: "tsconfig.json",
allowDefaultProject: ["*.mjs"],
},
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"check-file/filename-naming-convention": [
"error",
{
"**/*.{js,ts}": "+([-._a-z0-9])",
},
],
"prefer-arrow-callback": [
"warn",
{
allowNamedFunctions: true,
},
],
"func-style": [
"warn",
"declaration",
{
allowArrowFunctions: false,
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"no-restricted-syntax": ["error", "ForInStatement"],
"use-isnan": "error",
"no-unneeded-ternary": "error",
"no-nested-ternary": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "after-used",
ignoreRestSiblings: true,
vars: "all",
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-collection-size-mischeck": "error",
"sonarjs/no-duplicated-branches": "error",
"sonarjs/no-element-overwrite": "error",
"sonarjs/no-identical-conditions": "error",
"sonarjs/no-identical-expressions": "error",
"sonarjs/new-cap": "off",
"sonarjs/different-types-comparison": "off",
"sonarjs/sonar-prefer-regexp-exec": "off",
"sonarjs/function-return-type": "off",
"sonarjs/no-misleading-array-reverse": "off",
"sonarjs/slow-regex": "off",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "interface",
format: ["StrictPascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["strictCamelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["StrictPascalCase"],
},
{
selector: "typeParameter",
format: ["StrictPascalCase"],
prefix: ["T"],
},
{
selector: "variable",
format: ["strictCamelCase", "UPPER_CASE"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
format: ["strictCamelCase"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
modifiers: ["destructured"],
format: null,
},
{
selector: "variable",
types: ["boolean"],
format: ["StrictPascalCase"],
prefix: ["is", "should", "has", "can", "did", "will", "does"],
},
{
selector: "variableLike",
format: ["strictCamelCase"],
},
{
selector: ["function", "variable"],
format: ["strictCamelCase"],
},
],
},
});
11 changes: 0 additions & 11 deletions jest.config.json

This file was deleted.

27 changes: 27 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Config } from "jest";

const cfg: Config = {
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
coveragePathIgnorePatterns: ["node_modules", "mocks"],
collectCoverage: true,
coverageReporters: ["json", "lcov", "text", "clover", "json-summary"],
reporters: ["default", "jest-junit", "jest-md-dashboard"],
coverageDirectory: "coverage",
testTimeout: 20000,
roots: ["<rootDir>", "tests"],
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
setupFilesAfterEnv: ["dotenv/config"],
};

export default cfg;
11 changes: 10 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
"commands": {
"query": {
"ubiquity:example": "/query @UbiquityOS",
"description": "Returns the user's wallet, access, and multiplier information."
"description": "Returns the user's wallet, access, and multiplier information.",
"parameters": {
"type": "object",
"properties": {
"username": {
"description": "Github username",
"type": "string"
}
}
}
}
},
"configuration": {
Expand Down
Loading

0 comments on commit c63d1fa

Please sign in to comment.