@xylex-group/athena 1.7.0 → 2.0.0
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 +63 -53
- package/dist/cli/index.cjs +1224 -102
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +1224 -102
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +1832 -1138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -293
- package/dist/index.d.ts +63 -293
- package/dist/index.js +1829 -1139
- package/dist/index.js.map +1 -1
- package/dist/model-form-CVOtC8jq.d.ts +1284 -0
- package/dist/model-form-hXkvHS_3.d.cts +1284 -0
- package/dist/pipeline-C-cN0ACi.d.cts +164 -0
- package/dist/pipeline-CQgV-Yfo.d.ts +164 -0
- package/dist/react.cjs +157 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +38 -4
- package/dist/react.d.ts +38 -4
- package/dist/react.js +154 -1
- package/dist/react.js.map +1 -1
- package/dist/types-BnzoaNRC.d.cts +380 -0
- package/dist/types-BnzoaNRC.d.ts +380 -0
- package/package.json +3 -3
- package/dist/errors-BJGgjHcI.d.cts +0 -31
- package/dist/errors-Bcf5Sftv.d.ts +0 -31
- package/dist/pipeline-BsKuBqmE.d.cts +0 -343
- package/dist/pipeline-xQSjGbqF.d.ts +0 -343
- package/dist/types-wPA1Z4vQ.d.cts +0 -195
- package/dist/types-wPA1Z4vQ.d.ts +0 -195
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# athena-js
|
|
2
2
|
|
|
3
|
-
current version: `
|
|
3
|
+
current version: `2.0.0`
|
|
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
|
|
@@ -45,48 +45,45 @@ if (error) {
|
|
|
45
45
|
|
|
46
46
|
### Auth client (Athena Auth server)
|
|
47
47
|
|
|
48
|
-
If your auth backend is now Athena Auth, you can keep core login/session flows in this SDK:
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
import {
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await auth.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
await auth.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await auth.
|
|
80
|
-
await auth.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await auth.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Auth responses follow the same envelope style: `{ ok, status, data, error, errorDetails, raw }`.
|
|
48
|
+
If your auth backend is now Athena Auth, you can keep core login/session flows in this SDK:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createClient } from "@xylex-group/athena";
|
|
52
|
+
|
|
53
|
+
const athena = createClient(ATHENA_URL, ATHENA_API_KEY, {
|
|
54
|
+
client: "CLIENT_NAME",
|
|
55
|
+
auth: {
|
|
56
|
+
baseUrl: "http://localhost:3001/api/auth",
|
|
57
|
+
// optional: bearer token if you are not using cookie-based sessions
|
|
58
|
+
bearerToken: process.env.AUTH_BEARER_TOKEN,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const login = await athena.auth.signIn.email({
|
|
63
|
+
email: "demo@example.com",
|
|
64
|
+
password: "super-secret",
|
|
65
|
+
rememberMe: true,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const session = await athena.auth.getSession();
|
|
69
|
+
const sessions = await athena.auth.session.list();
|
|
70
|
+
|
|
71
|
+
// clear one session
|
|
72
|
+
await athena.auth.session.revoke({ token: "session_token_here" });
|
|
73
|
+
// or clear all sessions
|
|
74
|
+
await athena.auth.session.revoke([{ token: "session_token_here" }, { token: "session_token_2" }]);
|
|
75
|
+
|
|
76
|
+
await athena.auth.signOut();
|
|
77
|
+
|
|
78
|
+
// additional core flows
|
|
79
|
+
await athena.auth.forgetPassword({ email: "demo@example.com", redirectTo: "https://app/reset-password" });
|
|
80
|
+
await athena.auth.resetPassword({ newPassword: "new-secret", token: "reset_token" });
|
|
81
|
+
await athena.auth.verifyEmail({ token: "verify_token", callbackURL: "https://app/verified" });
|
|
82
|
+
await athena.auth.changePassword({ currentPassword: "old-secret", newPassword: "new-secret" });
|
|
83
|
+
await athena.auth.user.update({ name: "Demo User" });
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Auth responses follow the same envelope style: `{ ok, status, data, error, errorDetails, raw }`.
|
|
90
87
|
|
|
91
88
|
### Typed schema registry (model-first)
|
|
92
89
|
|
|
@@ -390,11 +387,23 @@ const { data: user } = await athena
|
|
|
390
387
|
.single();
|
|
391
388
|
```
|
|
392
389
|
|
|
393
|
-
`maybeSingle` behaves identically — both return the first element of the result set.
|
|
394
|
-
|
|
395
|
-
###
|
|
396
|
-
|
|
397
|
-
Use `
|
|
390
|
+
`maybeSingle` behaves identically — both return the first element of the result set.
|
|
391
|
+
|
|
392
|
+
### Table schema targeting
|
|
393
|
+
|
|
394
|
+
Use `schema` in table call options to qualify unqualified table names:
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
const { data } = await athena
|
|
398
|
+
.from("users")
|
|
399
|
+
.select("id,email", { schema: "public" });
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
This resolves the table target to `public.users`.
|
|
403
|
+
|
|
404
|
+
### RPC
|
|
405
|
+
|
|
406
|
+
Use `athena.rpc(...)` for Postgres function calls. By default it calls `POST /gateway/rpc`, and with `{ get: true }` it uses the compatibility route `GET /rpc/{function_name}`.
|
|
398
407
|
|
|
399
408
|
```ts
|
|
400
409
|
const { data, count } = await athena
|
|
@@ -428,11 +437,12 @@ RPC options: `schema`, `count` (`"exact" | "planned" | "estimated"`), `head`, `g
|
|
|
428
437
|
|
|
429
438
|
Pass options as the second argument to `.select()`:
|
|
430
439
|
|
|
431
|
-
| Option | Type | Description |
|
|
432
|
-
| ------------ | ------------------------------------- | -------------------------------------------- |
|
|
433
|
-
| `
|
|
434
|
-
| `
|
|
435
|
-
| `
|
|
440
|
+
| Option | Type | Description |
|
|
441
|
+
| ------------ | ------------------------------------- | -------------------------------------------- |
|
|
442
|
+
| `schema` | `string` | qualify unqualified table names for table calls |
|
|
443
|
+
| `count` | `"exact" \| "planned" \| "estimated"` | request a row count alongside the data |
|
|
444
|
+
| `head` | `boolean` | return response headers only (no rows) |
|
|
445
|
+
| `stripNulls` | `boolean` | strip null values from rows (default `true`) |
|
|
436
446
|
|
|
437
447
|
```ts
|
|
438
448
|
const { data } = await athena
|