onyx-database 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onyx_database-0.0.1/.github/workflows/ci.yml +31 -0
- onyx_database-0.0.1/.github/workflows/publish.yml +33 -0
- onyx_database-0.0.1/.gitignore +221 -0
- onyx_database-0.0.1/.vscode/launch.json +18 -0
- onyx_database-0.0.1/.vscode/tasks.json +33 -0
- onyx_database-0.0.1/CONTRIBUTING.md +127 -0
- onyx_database-0.0.1/LICENSE +21 -0
- onyx_database-0.0.1/PKG-INFO +727 -0
- onyx_database-0.0.1/README.md +704 -0
- onyx_database-0.0.1/config/onyx-database.json +6 -0
- onyx_database-0.0.1/examples/README.md +19 -0
- onyx_database-0.0.1/examples/__init__.py +1 -0
- onyx_database-0.0.1/examples/delete/by_id.py +10 -0
- onyx_database-0.0.1/examples/delete/query.py +15 -0
- onyx_database-0.0.1/examples/document/save_get_delete_document.py +23 -0
- onyx_database-0.0.1/examples/query/aggregate_avg.py +20 -0
- onyx_database-0.0.1/examples/query/aggregates_with_grouping.py +27 -0
- onyx_database-0.0.1/examples/query/basic.py +17 -0
- onyx_database-0.0.1/examples/query/basic_inference.py +17 -0
- onyx_database-0.0.1/examples/query/compound.py +15 -0
- onyx_database-0.0.1/examples/query/find_by_id.py +23 -0
- onyx_database-0.0.1/examples/query/first_or_none.py +17 -0
- onyx_database-0.0.1/examples/query/in_partition.py +15 -0
- onyx_database-0.0.1/examples/query/inner_query.py +63 -0
- onyx_database-0.0.1/examples/query/list.py +15 -0
- onyx_database-0.0.1/examples/query/not_inner_query.py +20 -0
- onyx_database-0.0.1/examples/query/order_by.py +14 -0
- onyx_database-0.0.1/examples/query/resolver.py +17 -0
- onyx_database-0.0.1/examples/query/resolver_with_hints.py +31 -0
- onyx_database-0.0.1/examples/query/search_by_resolver_fields.py +17 -0
- onyx_database-0.0.1/examples/query/select_example.py +19 -0
- onyx_database-0.0.1/examples/query/sorting_and_paging.py +29 -0
- onyx_database-0.0.1/examples/query/update.py +14 -0
- onyx_database-0.0.1/examples/save/basic.py +53 -0
- onyx_database-0.0.1/examples/save/batch_save.py +34 -0
- onyx_database-0.0.1/examples/save/cascade.py +46 -0
- onyx_database-0.0.1/examples/save/cascade_builder.py +51 -0
- onyx_database-0.0.1/examples/schema/basic.py +9 -0
- onyx_database-0.0.1/examples/secrets/basic.py +22 -0
- onyx_database-0.0.1/examples/seed.py +108 -0
- onyx_database-0.0.1/examples/stream/close.py +14 -0
- onyx_database-0.0.1/examples/stream/create_events.py +16 -0
- onyx_database-0.0.1/examples/stream/delete_events.py +16 -0
- onyx_database-0.0.1/examples/stream/query_stream.py +16 -0
- onyx_database-0.0.1/examples/stream/update_events.py +16 -0
- onyx_database-0.0.1/onyx/__init__.py +5 -0
- onyx_database-0.0.1/onyx/models.py +112 -0
- onyx_database-0.0.1/onyx/schema.py +356 -0
- onyx_database-0.0.1/onyx/tables.py +9 -0
- onyx_database-0.0.1/onyx_database/__init__.py +107 -0
- onyx_database-0.0.1/onyx_database/cli.py +285 -0
- onyx_database-0.0.1/onyx_database/codegen.py +166 -0
- onyx_database-0.0.1/onyx_database/config.py +230 -0
- onyx_database-0.0.1/onyx_database/errors.py +58 -0
- onyx_database-0.0.1/onyx_database/helpers/__init__.py +1 -0
- onyx_database-0.0.1/onyx_database/helpers/aggregates.py +54 -0
- onyx_database-0.0.1/onyx_database/helpers/conditions.py +110 -0
- onyx_database-0.0.1/onyx_database/helpers/sort.py +15 -0
- onyx_database-0.0.1/onyx_database/http.py +263 -0
- onyx_database-0.0.1/onyx_database/onyx.py +347 -0
- onyx_database-0.0.1/onyx_database/onyx_async.py +297 -0
- onyx_database-0.0.1/onyx_database/query_builder.py +329 -0
- onyx_database-0.0.1/onyx_database/query_builder_async.py +261 -0
- onyx_database-0.0.1/onyx_database/query_results.py +34 -0
- onyx_database-0.0.1/onyx_database/query_results_async.py +39 -0
- onyx_database-0.0.1/onyx_database/stream.py +114 -0
- onyx_database-0.0.1/onyx_database/types.py +34 -0
- onyx_database-0.0.1/plan/acceptance-criteria.md +12 -0
- onyx_database-0.0.1/plan/plan.md +16 -0
- onyx_database-0.0.1/pyproject.toml +36 -0
- onyx_database-0.0.1/schema/onyx.schema.json +357 -0
- onyx_database-0.0.1/scripts/bump-version.sh +148 -0
- onyx_database-0.0.1/scripts/release-flow.md +31 -0
- onyx_database-0.0.1/scripts/run-examples.sh +140 -0
- onyx_database-0.0.1/tasks/01-http-resilience.md +11 -0
- onyx_database-0.0.1/tasks/02-async-client.md +11 -0
- onyx_database-0.0.1/tasks/03-query-values.md +10 -0
- onyx_database-0.0.1/tasks/04-codegen-pydantic.md +10 -0
- onyx_database-0.0.1/tasks/05-cli-parity.md +12 -0
- onyx_database-0.0.1/tasks/06-packaging-ci.md +11 -0
- onyx_database-0.0.1/tests/test_async.py +55 -0
- onyx_database-0.0.1/tests/test_cli_subset.py +36 -0
- onyx_database-0.0.1/tests/test_codegen_pydantic.py +57 -0
- onyx_database-0.0.1/tests/test_http.py +84 -0
- onyx_database-0.0.1/tests/test_query_results.py +23 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build-and-test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.11"
|
|
21
|
+
|
|
22
|
+
- name: Install package (editable)
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
python -m pip install -e .
|
|
26
|
+
|
|
27
|
+
- name: Compile sources
|
|
28
|
+
run: python -m py_compile $(find onyx_database tests -name '*.py')
|
|
29
|
+
|
|
30
|
+
- name: Run unit tests
|
|
31
|
+
run: python -m unittest discover tests
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write # required for trusted publisher OIDC
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.11"
|
|
23
|
+
|
|
24
|
+
- name: Install build tooling
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install build
|
|
28
|
+
|
|
29
|
+
- name: Build package
|
|
30
|
+
run: python -m build
|
|
31
|
+
|
|
32
|
+
- name: Publish to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
.venv/
|
|
209
|
+
__pycache__/
|
|
210
|
+
*.pyc
|
|
211
|
+
dist/
|
|
212
|
+
build/
|
|
213
|
+
*.egg-info/
|
|
214
|
+
.pytest_cache/
|
|
215
|
+
.DS_Store
|
|
216
|
+
.vscode/
|
|
217
|
+
config/onyx-database.json
|
|
218
|
+
onyx-database.json
|
|
219
|
+
examples/onyx-database.json
|
|
220
|
+
onyx/
|
|
221
|
+
examples/onyx/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "debug example",
|
|
6
|
+
"type": "debugpy",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"program": "${file}",
|
|
9
|
+
"console": "integratedTerminal",
|
|
10
|
+
"env": {
|
|
11
|
+
"PYTHONPATH": "${workspaceFolder}",
|
|
12
|
+
"ONYX_DEBUG": "true"
|
|
13
|
+
},
|
|
14
|
+
"justMyCode": true,
|
|
15
|
+
"preLaunchTask": "onyx: prep"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "onyx: ensure env",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "source .venv/bin/activate && python -m pip install -e . && python -m py_compile $(find onyx_database -name '*.py')",
|
|
8
|
+
"presentation": {
|
|
9
|
+
"reveal": "always",
|
|
10
|
+
"panel": "shared",
|
|
11
|
+
"clear": true
|
|
12
|
+
},
|
|
13
|
+
"problemMatcher": []
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"label": "onyx: gen",
|
|
17
|
+
"type": "shell",
|
|
18
|
+
"command": "source .venv/bin/activate && onyx-py gen",
|
|
19
|
+
"presentation": {
|
|
20
|
+
"reveal": "always",
|
|
21
|
+
"panel": "shared",
|
|
22
|
+
"clear": true
|
|
23
|
+
},
|
|
24
|
+
"problemMatcher": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"label": "onyx: prep",
|
|
28
|
+
"dependsOn": ["onyx: ensure env", "onyx: gen"],
|
|
29
|
+
"dependsOrder": "sequence",
|
|
30
|
+
"problemMatcher": []
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Contributing to onyx-database-python
|
|
2
|
+
|
|
3
|
+
Thanks for helping build the Onyx Database Python SDK. This guide walks you from checkout to shipping changes with the same flows used in the TypeScript SDK.
|
|
4
|
+
|
|
5
|
+
# Quick start on macOS (fresh machine)
|
|
6
|
+
```bash
|
|
7
|
+
|
|
8
|
+
# first time setup
|
|
9
|
+
xcode-select --install # command line tools (once)
|
|
10
|
+
brew install python@3.11 pipx # Python + pipx from Homebrew
|
|
11
|
+
python3 -m venv .venv && source .venv/bin/activate # isolate from PEP 668 protections
|
|
12
|
+
python -m pip install --upgrade pip # upgrade pip inside the venv
|
|
13
|
+
git clone https://github.com/OnyxDevTools/onyx-database-python.git
|
|
14
|
+
cd onyx-database-python
|
|
15
|
+
|
|
16
|
+
# building and installing locally
|
|
17
|
+
python -m pip install -e . # install SDK + CLI locally
|
|
18
|
+
python -m py_compile $(find onyx_database -name '*.py') # quick sanity check
|
|
19
|
+
# Download onyx-database.json from https://cloud.onyx.dev and save to ./config/onyx-database.json
|
|
20
|
+
onyx-py info # user this to verify your installation and connection
|
|
21
|
+
onyx-py schema get # fetch schema (writes ./schema/onyx.schema.json)
|
|
22
|
+
onyx-py gen --out ./onyx # generate the onyx/ package used by examples
|
|
23
|
+
python examples/seed.py # creates sample data that the examples depend on
|
|
24
|
+
python examples/query/basic.py # run a sample
|
|
25
|
+
# Optional: set ONYX_DEBUG=true to log requests/responses
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## If you make a code change, you just need to:
|
|
29
|
+
pip install -e .
|
|
30
|
+
python -m py_compile $(find onyx_database -name '*.py')
|
|
31
|
+
## or this is done for you if you run an example using the vscode/launch.json config `debug example`
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Writing code with the SDK
|
|
35
|
+
- Initialize using your config:
|
|
36
|
+
```py
|
|
37
|
+
from onyx_database import onyx
|
|
38
|
+
db = onyx.init() # uses onyx-database.json via the resolver chain
|
|
39
|
+
```
|
|
40
|
+
- Simple save and query (drop into `examples/` or your app):
|
|
41
|
+
```py
|
|
42
|
+
from onyx_database import eq, asc
|
|
43
|
+
|
|
44
|
+
db.save("User", {"id": "user_1", "email": "a@example.com", "status": "active"})
|
|
45
|
+
users = (
|
|
46
|
+
db.from_table("User")
|
|
47
|
+
.where(eq("status", "active"))
|
|
48
|
+
.order_by(asc("createdAt"))
|
|
49
|
+
.limit(10)
|
|
50
|
+
.list()
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Configuring credentials
|
|
55
|
+
- Preferred locations (checked in order): `./config/onyx-database.json`, then `./onyx-database.json`
|
|
56
|
+
- Obtain the file from https://cloud.onyx.dev (API Keys -> download `onyx-database.json`) and place it under `./config/`
|
|
57
|
+
- Fallbacks: set `ONYX_CONFIG_PATH` to an absolute/relative JSON file; home profiles are also read if present.
|
|
58
|
+
- Schema defaults: `./schema/onyx.schema.json` or `./onyx.schema.json`
|
|
59
|
+
|
|
60
|
+
## CLI (codegen + schema)
|
|
61
|
+
- From checkout: `python3 -m pip install -e .` exposes `onyx-py`
|
|
62
|
+
- Or globally via pipx: `pipx install .`
|
|
63
|
+
- Check help: `onyx-py --help`, `onyx-py gen --help`, `onyx-py schema --help`
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
67
|
+
| Command | Flags | Defaults / notes |
|
|
68
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
69
|
+
| onyx-py info | --json | Shows DB ID, base URL, masked keys, config path, status. |
|
|
70
|
+
| | | Uses standard config resolution. |
|
|
71
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
72
|
+
| onyx-py schema get | --out <path> | Writes ./schema/onyx.schema.json if --out not set. |
|
|
73
|
+
| | --tables a,b | Creates schema/ if missing. --print skips writing. |
|
|
74
|
+
| | --print | |
|
|
75
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
76
|
+
| onyx-py schema publish | --schema <path> | Reads ./schema/onyx.schema.json (or ./onyx.schema.json) |
|
|
77
|
+
| | | by default; publishes to API. |
|
|
78
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
79
|
+
| onyx-py schema validate | --schema <path> | Validates local schema file (same default path as publish). |
|
|
80
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
81
|
+
| onyx-py schema diff | --schema <path> | Diffs local schema (same default path as publish) vs remote. |
|
|
82
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
83
|
+
| onyx-py gen | --source api|file (default file) | Generates models/tables/schema helpers. |
|
|
84
|
+
| | --schema <path> (default ./schema/onyx.schema.json | Multiple --out allowed (repeat or space-separated). |
|
|
85
|
+
| | or ./onyx.schema.json) | Default package inferred from final folder name of each |
|
|
86
|
+
| | --out <paths...> (default ./onyx) | --out when --package is omitted. |
|
|
87
|
+
| | --package <name> | |
|
|
88
|
+
| | --timestamps datetime|string|number | Default timestamps: datetime. |
|
|
89
|
+
+---------------------+---------------------------------------------+--------------------------------------------------------------+
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 10) Release / publish the library
|
|
93
|
+
- Bump version in `pyproject.toml` (and any `_version.py` once added)
|
|
94
|
+
- Build: `python -m build`
|
|
95
|
+
- Publish: `twine upload dist/*`
|
|
96
|
+
|
|
97
|
+
## 11) Install the public package
|
|
98
|
+
- `pip install onyx-database-python`
|
|
99
|
+
- For CLI-only without touching a venv: `pipx install onyx-database-python`
|
|
100
|
+
|
|
101
|
+
## CLI tools (schema + codegen)
|
|
102
|
+
Install the CLI (`onyx-py`) locally or globally, then use `schema` / `gen`:
|
|
103
|
+
|
|
104
|
+
Install:
|
|
105
|
+
- In repo venv: `python -m pip install -e .`
|
|
106
|
+
- Global (isolated) from this checkout: `pipx install .` (PyPI name not published yet). If pipx warns about PATH, run `pipx ensurepath`
|
|
107
|
+
- Verify: `onyx-py --help`
|
|
108
|
+
|
|
109
|
+
Schema commands:
|
|
110
|
+
- Download remote schema: `onyx-py schema get` (writes `./schema/onyx.schema.json` by default)
|
|
111
|
+
- Print only: `onyx-py schema get --print`
|
|
112
|
+
- Publish local schema: `onyx-py schema publish --schema ./schema/onyx.schema.json`
|
|
113
|
+
- Validate/diff: `onyx-py schema validate <path>`, `onyx-py schema diff <path>`
|
|
114
|
+
|
|
115
|
+
Codegen commands:
|
|
116
|
+
- From API: `onyx-py gen --source api --out ./onyx --package onyx`
|
|
117
|
+
- From file: `onyx-py gen --source file --schema ./schema/onyx.schema.json --out ./onyx --package onyx`
|
|
118
|
+
- Multiple outputs: `onyx-py gen --out ./onyx --out ./apps/admin/onyx`
|
|
119
|
+
- Timestamp mode: `--timestamps string` to keep ISO strings in generated models.
|
|
120
|
+
- Validation models: `--models pydantic` to emit Pydantic models (default is plain classes; extra fields allowed).
|
|
121
|
+
- HTTP flags: `--timeout <seconds>`, `--max-retries <n>`, `--retry-backoff <seconds>`
|
|
122
|
+
- Subset to stdout: `onyx-py gen --tables User Role` (prints those entities instead of writing files)
|
|
123
|
+
|
|
124
|
+
Config/env knobs:
|
|
125
|
+
- `ONYX_CONFIG_PATH` to point to a specific `onyx-database.json` (otherwise uses `./config/onyx-database.json`, then `./onyx-database.json`, then home profile).
|
|
126
|
+
- `ONYX_SCHEMA_PATH` to point to a schema file for `schema` and `gen --source file`.
|
|
127
|
+
- `ONYX_DEBUG=true` to log request/response bodies and credential resolution.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Onyx Database
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|