first commit
This commit is contained in:
21
.editorconfig
Normal file
21
.editorconfig
Normal file
@@ -0,0 +1,21 @@
|
||||
# This is simple enough and addresses the needs of **Frontend Engineering**
|
||||
# very well. Please do NOT overwrite this with a configuration
|
||||
# that was generated by committee in the interest of 'standardization' or
|
||||
# other Enterprise™ crap like that.
|
||||
#
|
||||
# Believe it or not but you don't **have** to tweak and customize every single
|
||||
# setting available to you: defaults work pretty well many times!
|
||||
#
|
||||
# Keep it Simple 🙏 🌸
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{sh,py}]
|
||||
indent_size = 4
|
||||
501
.gitignore
vendored
Normal file
501
.gitignore
vendored
Normal file
@@ -0,0 +1,501 @@
|
||||
# THIS IS MAINTAINED BY THE ARCHITECTURE TEAM.
|
||||
|
||||
# -------- Add custom ignores here --------
|
||||
|
||||
.pnpm-store/
|
||||
/out-tsc
|
||||
test/*.xml
|
||||
junit.xml
|
||||
metrics.txt
|
||||
coverage
|
||||
test-results
|
||||
.env
|
||||
|
||||
# Miscellanea
|
||||
web_dist
|
||||
|
||||
.nx
|
||||
.turbo
|
||||
|
||||
# Vite will sometimes create these junk files.
|
||||
*vite*timestamp*
|
||||
|
||||
# For `pnpm new` and anything else we might need this for
|
||||
.misc/fabric3.json
|
||||
|
||||
# From when you create a Vite app. The .gitignore was copypastaed here and is
|
||||
# edited to remove any duplicates from the auto-generated stuff below.
|
||||
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Configs we don't check into source control
|
||||
.tool-versions
|
||||
.vscode
|
||||
|
||||
# ======== DO NOT EDIT THE BELOW BY HAND ========
|
||||
|
||||
# -------- GENERATE IT USING THE LINKS BELOW AND COPYPASTA IT --------
|
||||
# -------- YOU'LL BE OKAY BOO 🌸 --------
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/node,react,windows,macos,linux,python,yarn
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node,react,windows,macos,linux,python,yarn
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### macOS Patch ###
|
||||
# iCloud generated files
|
||||
*.icloud
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
### Python Patch ###
|
||||
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
||||
poetry.toml
|
||||
|
||||
# ruff
|
||||
.ruff_cache/
|
||||
|
||||
# LSP config files
|
||||
pyrightconfig.json
|
||||
|
||||
### react ###
|
||||
.DS_*
|
||||
**/*.backup.*
|
||||
**/*.back.*
|
||||
|
||||
node_modules
|
||||
|
||||
*.sublime*
|
||||
|
||||
psd
|
||||
thumb
|
||||
sketch
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### yarn ###
|
||||
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
|
||||
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# if you are NOT using Zero-installs, then:
|
||||
# comment the following lines
|
||||
!.yarn/cache
|
||||
|
||||
# and uncomment the following lines
|
||||
# .pnp.*
|
||||
|
||||
### Terraform ###
|
||||
# Local .terraform directories
|
||||
**/.terraform/*
|
||||
|
||||
# .tfstate files
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
|
||||
# Crash log files
|
||||
crash.log
|
||||
crash.*.log
|
||||
|
||||
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
|
||||
# password, private keys, and other secrets. These should not be part of version
|
||||
# control as they are data points which are potentially sensitive and subject
|
||||
# to change depending on the environment.
|
||||
*.tfvars
|
||||
*.tfvars.json
|
||||
|
||||
# Ignore override files as they are usually used to override resources locally and so
|
||||
# are not checked in
|
||||
override.tf
|
||||
override.tf.json
|
||||
*_override.tf
|
||||
*_override.tf.json
|
||||
|
||||
# Include override files you do wish to add to version control using negated pattern
|
||||
# !example_override.tf
|
||||
|
||||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
|
||||
# example: *tfplan*
|
||||
*tfplan*
|
||||
|
||||
# Ignore CLI configuration files
|
||||
.terraformrc
|
||||
terraform.rc
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/node,react,windows,macos,linux,python,yarn
|
||||
31
biome.json
Normal file
31
biome.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": false
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"formatWithErrors": true,
|
||||
"indentStyle": "space"
|
||||
},
|
||||
"linter": {
|
||||
"enabled": false,
|
||||
"rules": {
|
||||
"recommended": true
|
||||
}
|
||||
},
|
||||
"vcs": {
|
||||
"clientKind": "git",
|
||||
"enabled": true,
|
||||
"useIgnoreFile": true,
|
||||
"defaultBranch": "main"
|
||||
},
|
||||
"files": {
|
||||
"ignore": [
|
||||
"./.configs/**",
|
||||
"generated/**",
|
||||
"tsconfig*.json",
|
||||
"orval.config.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
13
eslint.config.js
Normal file
13
eslint.config.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const { sheriff } = require('eslint-config-sheriff');
|
||||
const { defineFlatConfig } = require('eslint-define-config');
|
||||
|
||||
const sheriffOptions = {
|
||||
"react": false,
|
||||
"lodash": false,
|
||||
"next": false,
|
||||
"playwright": false,
|
||||
"jest": false,
|
||||
"vitest": false
|
||||
};
|
||||
|
||||
module.exports = defineFlatConfig([...sheriff(sheriffOptions)]);
|
||||
31
package.json
Normal file
31
package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "pancake-api-tui",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "tsx src/index.ts"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"type": "module",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@biomejs/biome": "1.7.0",
|
||||
"@types/node": "^20.12.7",
|
||||
"dotenv": "^16.4.5",
|
||||
"esbuild": "0.20.2",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-sheriff": "^18.2.0",
|
||||
"eslint-define-config": "^2.1.0",
|
||||
"ky": "^1.2.3",
|
||||
"tinyrainbow": "^1.1.1",
|
||||
"tsx": "4.7.2",
|
||||
"typescript": "5.4.5",
|
||||
"vite": "^5.2.9",
|
||||
"zod": "^3.22.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"wretched": "1.0.10-alpha"
|
||||
}
|
||||
}
|
||||
5658
pnpm-lock.yaml
generated
Normal file
5658
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
src/components/listProjects.ts
Normal file
11
src/components/listProjects.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Button, Flex } from "wretched";
|
||||
import { getAllProjects } from "../services/api-client.js";
|
||||
|
||||
const projects = await getAllProjects({ limit: 100 });
|
||||
|
||||
export const projectView = Flex.down({
|
||||
children: projects.map(x => new Button({
|
||||
text: x.name
|
||||
})
|
||||
)
|
||||
});
|
||||
38
src/index.ts
Normal file
38
src/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import "dotenv"
|
||||
import { Screen, Box, Flow, Text, Button, interceptConsoleLog, ConsoleLog, iTerm2, Window, Flex } from 'wretched'
|
||||
import * as utility from "wretched/dist/components/utility";
|
||||
import { projectView } from "./components/listProjects.js";
|
||||
|
||||
|
||||
|
||||
interceptConsoleLog();
|
||||
process.title = 'Wretched';
|
||||
|
||||
const consoleLog = new ConsoleLog({
|
||||
height: 10,
|
||||
})
|
||||
const [screen, program] = await Screen.start(
|
||||
async (program) => {
|
||||
await iTerm2.setBackground(program, [23, 23, 23])
|
||||
|
||||
return new Window({
|
||||
child: new utility.TrackMouse({
|
||||
content: Flex.down({
|
||||
children: [
|
||||
['flex1', projectView],
|
||||
['natural', consoleLog],
|
||||
],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
program.key('escape', function () {
|
||||
consoleLog.clear()
|
||||
screen.render()
|
||||
})
|
||||
|
||||
process.on("beforeExit", () => {
|
||||
|
||||
})
|
||||
359
src/services/api-client.ts
Normal file
359
src/services/api-client.ts
Normal file
@@ -0,0 +1,359 @@
|
||||
|
||||
import ky from 'ky';
|
||||
|
||||
|
||||
const API_KEY = process.env.PANCAKE_API_KEY;
|
||||
const API_URL = process.env.PANCAKE_API_URL;
|
||||
|
||||
const api = ky.create({ prefixUrl: API_URL, headers: { "Authorization": `Bearer ${API_KEY}` } });
|
||||
|
||||
type PaginationParams = { limit?: number, start?: number, sort_by?: string, sort_dir?: 'asc' | 'desc' }
|
||||
// Clients
|
||||
async function getAllClients(params: PaginationParams) {
|
||||
const { limit = 5, start = 0, sort_by = 'id', sort_dir = 'asc' } = params;
|
||||
const url = `${BASE_URL}/clients?limit=${limit}&start=${start}&sort_by=${sort_by}&sort_dir=${sort_dir}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function getOneClient(id: string) {
|
||||
const url = `${BASE_URL}/clients/show?id=${id}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function createNewClient(data) {
|
||||
const url = `${BASE_URL}/clients/new`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function updateClient(data) {
|
||||
const url = `${BASE_URL}/clients/edit`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function deleteClient(id: string) {
|
||||
const url = `${BASE_URL}/clients/delete`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Projects
|
||||
async function getOneProject(id: string) {
|
||||
const url = `${BASE_URL}/projects/show?id=${id}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function getAllProjects(params: PaginationParams) {
|
||||
const { limit = 5, start = 0, sort_by = 'id', sort_dir = 'asc' } = params;
|
||||
const url = `${BASE_URL}/projects?limit=${limit}&start=${start}&sort_by=${sort_by}&sort_dir=${sort_dir}`;
|
||||
const response = await fetch(url);
|
||||
console.log("🚀 ~ getAllProjects ~ response:", response)
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
|
||||
// Projects (continued)
|
||||
async function createNewProject(data) {
|
||||
const url = `${BASE_URL}/projects/new`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function updateProject(data) {
|
||||
const url = `${BASE_URL}/projects/edit`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Tasks
|
||||
async function getTasksByProject(projectId: string) {
|
||||
const url = `${BASE_URL}/projects/tasks?id=${projectId}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function createTask(data) {
|
||||
const url = `${BASE_URL}/projects/tasks/new`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function updateTask(data) {
|
||||
const url = `${BASE_URL}/projects/tasks/update`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function deleteTask(taskId: string) {
|
||||
const url = `${BASE_URL}/projects/tasks/show`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: taskId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function logTimeOnTask(data) {
|
||||
const url = `${BASE_URL}/projects/tasks/log_time`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function completeTask(taskId: string) {
|
||||
const url = `${BASE_URL}/projects/tasks/compete`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: taskId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function reopenTask(taskId: string) {
|
||||
const url = `${BASE_URL}/projects/tasks/reopen`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: taskId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Invoices
|
||||
async function getAllInvoices(params: { client_id: string } & PaginationParams) {
|
||||
const { client_id, limit = 5, start = 0, sort_by = 'id', sort_dir = 'asc' } = params;
|
||||
const queryParams = new URLSearchParams({ client_id, limit: limit.toFixed(0), start: start.toFixed(0), sort_by, sort_dir });
|
||||
const url = `${BASE_URL}/invoices?${queryParams.toString()}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function getOneInvoice(id: string) {
|
||||
const url = `${BASE_URL}/invoices/show?id=${id}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function createNewInvoice(data) {
|
||||
const url = `${BASE_URL}/invoices/new`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function updateInvoice(data) {
|
||||
const url = `${BASE_URL}/invoices/edit`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function deleteInvoice(invoiceId: string) {
|
||||
const url = `${BASE_URL}/invoices/delete`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: invoiceId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function openInvoice(invoiceId: string) {
|
||||
const url = `${BASE_URL}/invoices/open`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: invoiceId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function closeInvoice(invoiceId: string) {
|
||||
const url = `${BASE_URL}/invoices/close`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: invoiceId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function markInvoicePaid(invoiceId: string) {
|
||||
const url = `${BASE_URL}/invoices/paid`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: invoiceId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function sendInvoice(invoiceId: string) {
|
||||
const url = `${BASE_URL}/invoices/send`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: invoiceId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Users
|
||||
async function getOneUser(id: string) {
|
||||
const url = `${BASE_URL}/users/show?id=${id}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function getAllUsers(params: PaginationParams) {
|
||||
const { limit = 5, start = 0, sort_by = 'id', sort_dir = 'asc' } = params;
|
||||
const queryParams = new URLSearchParams({ limit: limit.toFixed(0), start: start.toFixed(0), sort_by, sort_dir });
|
||||
const url = `${BASE_URL}/users?${queryParams.toString()}`;
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function updateUser(data) {
|
||||
const url = `${BASE_URL}/users/edit`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function deleteUser(userId: string) {
|
||||
const url = `${BASE_URL}/users/delete`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: userId })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export {
|
||||
// Clients
|
||||
getAllClients,
|
||||
getOneClient,
|
||||
createNewClient,
|
||||
updateClient,
|
||||
deleteClient,
|
||||
|
||||
// Projects
|
||||
getOneProject,
|
||||
getAllProjects,
|
||||
createNewProject,
|
||||
updateProject,
|
||||
|
||||
// Tasks
|
||||
getTasksByProject,
|
||||
createTask,
|
||||
updateTask,
|
||||
deleteTask,
|
||||
logTimeOnTask,
|
||||
completeTask,
|
||||
reopenTask,
|
||||
|
||||
// Invoices
|
||||
getAllInvoices,
|
||||
getOneInvoice,
|
||||
createNewInvoice,
|
||||
updateInvoice,
|
||||
deleteInvoice,
|
||||
openInvoice,
|
||||
closeInvoice,
|
||||
markInvoicePaid,
|
||||
sendInvoice,
|
||||
|
||||
// Users
|
||||
getOneUser,
|
||||
getAllUsers,
|
||||
updateUser,
|
||||
deleteUser
|
||||
};
|
||||
32
tsconfig.json
Normal file
32
tsconfig.json
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
Super-special config for our tRPC Lambda 🌸
|
||||
|
||||
Reference:
|
||||
https://aka.ms/tsconfig
|
||||
*/
|
||||
{
|
||||
"compilerOptions": {
|
||||
// TODO: This does not work! Hono complains about not finding React...
|
||||
"lib": ["ES2022"],
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"incremental": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"tsBuildInfoFile": null
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/mocks/**/*",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
]
|
||||
}
|
||||
27
tsconfig.spec.json
Normal file
27
tsconfig.spec.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"extends": "../.configs/tsconfig.node.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"resolveJsonModule": true,
|
||||
"outDir": "dist/out-tsc",
|
||||
"types": [
|
||||
"vitest/globals",
|
||||
"vitest/importMeta",
|
||||
"node",
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"include": [
|
||||
"**/*.test.ts",
|
||||
"**/mocks/**/*.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/*.test.tsx",
|
||||
"**/*.spec.tsx",
|
||||
"**/*.test.js",
|
||||
"**/*.spec.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.spec.jsx",
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user