@onyx.dev/onyx-database 1.0.2 → 1.0.3

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.
package/README.md CHANGED
@@ -13,6 +13,25 @@ TypeScript client SDK for **Onyx Cloud Database** — a zero-dependency, strict-
13
13
 
14
14
  ---
15
15
 
16
+ ## Table of contents
17
+
18
+ - [Getting started](#getting-started-cloud--keys--connect)
19
+ - [Install](#install)
20
+ - [Initialize the client](#initialize-the-client)
21
+ - [Generate schema types](#optional-generate-typescript-types-from-your-schema)
22
+ - [Query helpers](#query-helpers-at-a-glance)
23
+ - [Examples](#usage-examples-with-user-role-permission)
24
+ - [Error handling](#error-handling)
25
+ - [HTTP retries](#http-retries)
26
+ - [Onyx CLI](#onyx-cli)
27
+ - [Runtime & bundlers](#runtime--bundlers)
28
+ - [Release workflow](#release-workflow)
29
+ - [Related links](#related-links)
30
+ - [Security](#security)
31
+ - [License](#license)
32
+
33
+ ---
34
+
16
35
  ## Getting started (Cloud ➜ keys ➜ connect)
17
36
 
18
37
  1. **Sign up & create resources** at **<https://cloud.onyx.dev>**
@@ -116,6 +135,37 @@ Set `ONYX_CONFIG_PATH` to a JSON file containing your credentials. This file is
116
135
 
117
136
  These files are ignored in non-Node runtimes like Cloudflare Workers.
118
137
 
138
+ ### Edge / RSC usage (Next.js, Cloudflare Workers)
139
+
140
+ For edge runtimes (Next.js Edge/RSC, Cloudflare Workers), import the edge entry. It avoids Node-only imports and only resolves credentials from environment variables or explicit config.
141
+
142
+ ```ts
143
+ import { onyx } from '@onyx.dev/onyx-database/edge';
144
+
145
+ const db = onyx.init(); // uses env vars in edge runtimes
146
+ ```
147
+
148
+ File-based config (`ONYX_CONFIG_PATH`, project files, home profiles) is not available in edge runtimes. If you need file-based config, use the Node entry instead.
149
+
150
+ **Cloudflare Worker example:**
151
+
152
+ ```ts
153
+ import { onyx } from '@onyx.dev/onyx-database/edge';
154
+
155
+ export default {
156
+ async fetch(_request: Request, env: Record<string, string>) {
157
+ const db = onyx.init({
158
+ baseUrl: env.ONYX_DATABASE_BASE_URL,
159
+ databaseId: env.ONYX_DATABASE_ID,
160
+ apiKey: env.ONYX_DATABASE_API_KEY,
161
+ apiSecret: env.ONYX_DATABASE_API_SECRET,
162
+ });
163
+
164
+ return Response.json({ ok: true });
165
+ },
166
+ };
167
+ ```
168
+
119
169
  ### Connection handling
120
170
 
121
171
  Calling `onyx.init()` returns a lightweight client. Configuration is resolved once
@@ -665,7 +715,60 @@ try {
665
715
  }
666
716
  ```
667
717
 
668
- ---
718
+ ## HTTP retries
719
+
720
+ - GET requests retry automatically with Fibonacci backoff (300ms base) up to 3 times by default; mutations are never retried.
721
+ - Disable or tune via `retry` on `onyx.init`:
722
+
723
+ ```ts
724
+ const db = onyx.init({
725
+ retry: {
726
+ enabled: true, // default
727
+ maxRetries: 2, // default 3
728
+ initialDelayMs: 500, // default 300
729
+ },
730
+ });
731
+ ```
732
+
733
+ ## Onyx CLI
734
+
735
+
736
+ ```
737
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
738
+ | Command | Flags | Defaults / notes |
739
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
740
+ | onyx-gen | --source auto|api|file | Default: --source file; --schema ./onyx.schema.json; |
741
+ | | --schema <path> | --out ./onyx/types.ts (file or dir; repeatable; dir uses |
742
+ | | --out / --types-out / --types-file <dir|file> | --base onyx.schema); timestamps default: date; optional |
743
+ | | --base / --baseName <name> | strategy default: non-null; schema type name: OnyxSchema; |
744
+ | | --timestamps string|date|number | emit-json disabled by default; --overwrite enabled; quiet=false. |
745
+ | | --name / --schemaTypeName <T> | --api-path repeatable; --json-out derived from TS output. |
746
+ | | --prefix <Prefix> | |
747
+ | | --optional non-null|nullable|none | |
748
+ | | --emit-json / --no-emit-json | |
749
+ | | --json-out <dir> | |
750
+ | | --api-path <path> (repeatable) | |
751
+ | | --overwrite / --no-overwrite | |
752
+ | | -q / --quiet | |
753
+ | | -h / --help | |
754
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
755
+ | onyx-schema get | [file] (positional) | Default file: ./onyx.schema.json; writes file unless |
756
+ | | --tables a,b | --tables or --print (then prints to stdout). |
757
+ | | --print | |
758
+ | | -h / --help | |
759
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
760
+ | onyx-schema publish | [file] (positional) | Default file: ./onyx.schema.json; validates before publishing; |
761
+ | | -h / --help | uses onyx.init credential resolver. |
762
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
763
+ | onyx-schema validate | [file] (positional) | Default file: ./onyx.schema.json; exits non-zero on errors. |
764
+ | | -h / --help | |
765
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
766
+ | onyx-schema diff | [file] (positional) | Default file: ./onyx.schema.json; prints YAML diff vs API. |
767
+ | | -h / --help | |
768
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
769
+ | onyx-schema info | -h / --help | Shows resolved config sources, config path, connection check.|
770
+ +----------------------+-----------------------------------------------+--------------------------------------------------------------+
771
+ ```
669
772
 
670
773
  ## Runtime & bundlers
671
774