@xylex-group/athena 2.0.0 → 2.1.2
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 +47 -26
- package/dist/browser.cjs +3319 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +25 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +3276 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli/index.cjs +599 -119
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -2
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +600 -120
- package/dist/cli/index.js.map +1 -1
- package/dist/client-BX0NQqOn.d.ts +435 -0
- package/dist/client-dpAp-NZK.d.cts +435 -0
- package/dist/cookies.cjs +890 -0
- package/dist/cookies.cjs.map +1 -0
- package/dist/cookies.d.cts +174 -0
- package/dist/cookies.d.ts +174 -0
- package/dist/cookies.js +869 -0
- package/dist/cookies.js.map +1 -0
- package/dist/index.cjs +1378 -1023
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -408
- package/dist/index.d.ts +8 -408
- package/dist/index.js +1379 -1024
- package/dist/index.js.map +1 -1
- package/dist/{model-form-CVOtC8jq.d.ts → model-form-2hqmoOUX.d.ts} +2 -2
- package/dist/{model-form-hXkvHS_3.d.cts → model-form-Cy-zaO0u.d.cts} +2 -2
- package/dist/pipeline-BOPszLsL.d.ts +8 -0
- package/dist/pipeline-E3FDbs4W.d.cts +8 -0
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/{types-BnzoaNRC.d.cts → types-BaBzjwXr.d.cts} +1 -1
- package/dist/{types-BnzoaNRC.d.ts → types-BaBzjwXr.d.ts} +1 -1
- package/dist/{pipeline-CQgV-Yfo.d.ts → types-CeBPrnGj.d.ts} +2 -7
- package/dist/{pipeline-C-cN0ACi.d.cts → types-CpqL-pZx.d.cts} +2 -7
- package/package.json +21 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# athena-js
|
|
2
2
|
|
|
3
|
-
current version: `2.
|
|
3
|
+
current version: `2.1.2`
|
|
4
4
|
`@xylex-group/athena` is a database driver and API gateway SDK that lets you interact with SQL backends over HTTP through a fluent builder API. It ships a typed query builder for Node.js / server environments plus Athena-native React hooks for client-side use.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
@@ -206,24 +206,27 @@ requireAffected(inserted, { min: 1 }, { table: "users", operation: "insert" });
|
|
|
206
206
|
|
|
207
207
|
`requireAffected` uses `result.count`; request it on writes with `{ count: "exact" }` when you need enforced postconditions.
|
|
208
208
|
|
|
209
|
-
### Error normalization
|
|
210
|
-
|
|
211
|
-
```ts
|
|
212
|
-
import { normalizeAthenaError } from "@xylex-group/athena";
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
209
|
+
### Error normalization
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { createClient, normalizeAthenaError } from "@xylex-group/athena";
|
|
213
|
+
|
|
214
|
+
const athena = createClient(ATHENA_URL, ATHENA_API_KEY, {
|
|
215
|
+
experimental: { enableErrorNormalization: true },
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const result = await athena.from("users").insert({ id: 1 }).select();
|
|
219
|
+
if (result.error) {
|
|
220
|
+
const err = normalizeAthenaError(result);
|
|
221
|
+
if (err.kind === "unique_violation") {
|
|
222
|
+
// deterministic conflict handling
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Normalized errors expose stable `kind` values (`unique_violation`, `validation`, `auth`, `rate_limit`, `transient`, etc.) plus operation metadata.
|
|
228
|
+
|
|
229
|
+
`experimental.enableErrorNormalization` keeps the existing `AthenaResult<T>` shape intact and pre-attaches context-aware metadata so `normalizeAthenaError(result)` can resolve table/operation without extra per-call context objects.
|
|
227
230
|
|
|
228
231
|
### Numeric coercion
|
|
229
232
|
|
|
@@ -254,13 +257,31 @@ const result = await withRetry(
|
|
|
254
257
|
|
|
255
258
|
By default, retries target transient/rate-limit failures; use `shouldRetry` for custom policies.
|
|
256
259
|
|
|
257
|
-
## Query builder
|
|
258
|
-
|
|
259
|
-
###
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
## Query builder
|
|
261
|
+
|
|
262
|
+
### DB module namespace
|
|
263
|
+
|
|
264
|
+
`createClient()` keeps root methods (`from`, `rpc`, `query`) and now also exposes `db` as an additive namespace.
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const athena = createClient(ATHENA_URL, ATHENA_API_KEY);
|
|
268
|
+
|
|
269
|
+
await athena.db.from("users").select("id,name").eq("active", true).limit(20);
|
|
270
|
+
|
|
271
|
+
await athena.db.select("users", "id,name").eq("id", 1).single();
|
|
272
|
+
|
|
273
|
+
await athena.db.insert("users", { id: 1, name: "Alice" }).select("id");
|
|
274
|
+
await athena.db.update("users", { name: "Updated" }).eq("id", 1).select("id,name");
|
|
275
|
+
await athena.db.delete("users", { resourceId: "r-1" }).select("id");
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
`db` mirrors the existing query builder semantics while providing a module seam for future database-surface expansion.
|
|
279
|
+
|
|
280
|
+
### Reading rows
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
// select all columns
|
|
284
|
+
const { data } = await athena.from("users").select();
|
|
264
285
|
|
|
265
286
|
// select specific columns
|
|
266
287
|
const { data } = await athena.from("users").select("id, name, email");
|