@xylex-group/athena 1.5.0 → 1.6.1
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 -1
- package/bin/athena-js.js +7 -8
- package/dist/cli/index.cjs +2502 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +6 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +2500 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +1554 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +484 -1
- package/dist/index.d.ts +484 -1
- package/dist/index.js +1536 -16
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# athena-js
|
|
2
2
|
|
|
3
|
-
current version: `1.
|
|
3
|
+
current version: `1.6.1`
|
|
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
|
|
@@ -43,6 +43,62 @@ if (error) {
|
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
### Typed schema registry (model-first)
|
|
47
|
+
|
|
48
|
+
You can keep `createClient(...).from<T>(...)` as-is, or opt into a typed registry:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import {
|
|
52
|
+
createTypedClient,
|
|
53
|
+
defineDatabase,
|
|
54
|
+
defineModel,
|
|
55
|
+
defineRegistry,
|
|
56
|
+
defineSchema,
|
|
57
|
+
} from "@xylex-group/athena";
|
|
58
|
+
|
|
59
|
+
const registry = defineRegistry({
|
|
60
|
+
primary: defineDatabase({
|
|
61
|
+
public: defineSchema({
|
|
62
|
+
users: defineModel<{ id: string; email: string }>({
|
|
63
|
+
meta: {
|
|
64
|
+
primaryKey: ["id"],
|
|
65
|
+
nullable: { id: false, email: false },
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const typed = createTypedClient(registry, ATHENA_URL, ATHENA_API_KEY, {
|
|
73
|
+
tenantKeyMap: {
|
|
74
|
+
organizationId: "X-Organization-Id",
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
await typed
|
|
79
|
+
.withTenantContext({ organizationId: "org_1" })
|
|
80
|
+
.fromModel("primary", "public", "users")
|
|
81
|
+
.select("*");
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For full details, see [`docs/typed-schema-registry.md`](./docs/typed-schema-registry.md).
|
|
85
|
+
|
|
86
|
+
### Typed schema generator (phase 2 scaffolding)
|
|
87
|
+
|
|
88
|
+
The SDK now includes a project-root generator config system (`athena.config.ts`) and CLI command:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
athena-js generate
|
|
92
|
+
athena-js generate --dry-run
|
|
93
|
+
athena-js generate --config ./athena.config.ts
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Generator output paths support placeholder tokens (database/schema/model + case variants), feature flags, and experimental provider contracts.
|
|
97
|
+
PostgreSQL introspection works both via direct `pg_url` and gateway-only `/gateway/query` execution.
|
|
98
|
+
|
|
99
|
+
For full generator configuration, see [`docs/generator-config.md`](./docs/generator-config.md).
|
|
100
|
+
For prompt-ready documentation handoff text, see [`docs/generator-codex-handoff-prompt-pack.md`](./docs/generator-codex-handoff-prompt-pack.md).
|
|
101
|
+
|
|
46
102
|
Every query resolves to `{ data, error, errorDetails?, status, count?, raw }`. `data` is `null` on error; `error` is `null` on success.
|
|
47
103
|
|
|
48
104
|
For richer handling, inspect `errorDetails` (`code`, `status`, `endpoint`, `method`, `requestId`, etc.) or use `AthenaGatewayError` / `isAthenaGatewayError` from the package exports.
|
|
@@ -505,6 +561,9 @@ By design this is not a cache-heavy React Query clone:
|
|
|
505
561
|
- Inflight dedupe for identical query keys is enabled.
|
|
506
562
|
- Manual `refetch()` after mutations is the default invalidation strategy.
|
|
507
563
|
|
|
564
|
+
`test-sdk` includes runnable local examples for these hooks in
|
|
565
|
+
`test-sdk/examples/react-hooks`, where `queryFn`/`mutationFn` call Athena directly via `createClient(...).from(...).select()/insert()/eq()`.
|
|
566
|
+
|
|
508
567
|
`useAthenaGateway` example:
|
|
509
568
|
|
|
510
569
|
```tsx
|
|
@@ -605,5 +664,8 @@ CI and publish workflows run `typecheck` before build/publish.
|
|
|
605
664
|
|
|
606
665
|
## Learn more
|
|
607
666
|
|
|
667
|
+
- [Documentation index](docs/index.md) — complete documentation map
|
|
608
668
|
- [Getting started](docs/getting-started.md) — step-by-step walkthrough
|
|
669
|
+
- [Typed schema registry](docs/typed-schema-registry.md) — typed contracts and migration path
|
|
670
|
+
- [Generator config](docs/generator-config.md) — generator provider and output pipeline
|
|
609
671
|
- [API reference](docs/api-reference.md) — complete method and type reference
|
package/bin/athena-js.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import('../dist/cli/index.js').then(({ runCLI }) => {
|
|
4
|
-
runCLI(process.argv.slice(2))
|
|
5
|
-
}).catch(err => {
|
|
6
|
-
console.error('Failed to start athena-js CLI:', err)
|
|
7
|
-
process.exit(1)
|
|
8
|
-
})
|
|
1
|
+
#!/usr/bin/env node
|
|
9
2
|
|
|
3
|
+
import('../dist/cli/index.js')
|
|
4
|
+
.then(({ runCLI }) => runCLI(process.argv.slice(2)))
|
|
5
|
+
.catch(err => {
|
|
6
|
+
console.error('Failed to start athena-js CLI:', err)
|
|
7
|
+
process.exit(1)
|
|
8
|
+
})
|