Compare commits
2 Commits
57dc0455d1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
980ec285ea | ||
|
|
ae8332ab3f |
18
README.md
18
README.md
@@ -1,6 +1,6 @@
|
|||||||
# @crema/arcadia-client
|
# @crema/arcadia-core-client
|
||||||
|
|
||||||
Typed HTTP client + React bindings for the [arcadia](https://git.sky-ai.com/CremaUIStudio/arcadia-app) Phoenix API. Wraps the OpenAPI-spec'd surface at `/api/v1` with auth (Bearer JWT and/or service-account API key), tenant context (`X-Tenant-ID`), idempotency keys, error normalization, and rate-limit-aware retry.
|
Typed HTTP client + React bindings for the [arcadia](https://git.sky-ai.com/CremaUIStudio/arcadia-core) Phoenix API. Wraps the OpenAPI-spec'd surface at `/api/v1` with auth (Bearer JWT and/or service-account API key), tenant context (`X-Tenant-ID`), idempotency keys, error normalization, and rate-limit-aware retry.
|
||||||
|
|
||||||
The client is **stateless about how the JWT is obtained** — callers pass `getToken` so token refresh and storage stay app-owned.
|
The client is **stateless about how the JWT is obtained** — callers pass `getToken` so token refresh and storage stay app-owned.
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
useArcadia,
|
useArcadia,
|
||||||
useArcadiaClient,
|
useArcadiaClient,
|
||||||
ArcadiaError,
|
ArcadiaError,
|
||||||
} from "@crema/arcadia-client";
|
} from "@crema/arcadia-core-client";
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage in a Crema app
|
## Usage in a Crema app
|
||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
In `app/root.tsx`, wrap providers:
|
In `app/root.tsx`, wrap providers:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { ArcadiaProvider } from "@crema/arcadia-client";
|
import { ArcadiaProvider } from "@crema/arcadia-core-client";
|
||||||
|
|
||||||
<ArcadiaProvider
|
<ArcadiaProvider
|
||||||
baseUrl={import.meta.env.VITE_ARCADIA_URL}
|
baseUrl={import.meta.env.VITE_ARCADIA_URL}
|
||||||
@@ -36,7 +36,7 @@ import { ArcadiaProvider } from "@crema/arcadia-client";
|
|||||||
In any component:
|
In any component:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useArcadiaClient, ArcadiaError } from "@crema/arcadia-client";
|
import { useArcadiaClient, ArcadiaError } from "@crema/arcadia-core-client";
|
||||||
|
|
||||||
function ResourceList() {
|
function ResourceList() {
|
||||||
const arcadia = useArcadiaClient();
|
const arcadia = useArcadiaClient();
|
||||||
@@ -59,7 +59,7 @@ Endpoint request/response types come from arcadia's live OpenAPI spec. Regenerat
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
ARCADIA_OPENAPI_URL=http://localhost:4000/api/openapi \
|
ARCADIA_OPENAPI_URL=http://localhost:4000/api/openapi \
|
||||||
node ../lib-arcadia-client/scripts/sync-spec.mjs
|
node ../lib-arcadia-core-client/scripts/sync-spec.mjs
|
||||||
```
|
```
|
||||||
|
|
||||||
Requires `openapi-typescript` in the consuming app's devDeps:
|
Requires `openapi-typescript` in the consuming app's devDeps:
|
||||||
@@ -108,7 +108,7 @@ Phoenix Channels at `/socket/tenant`, opt-in via the provider. The socket auto-c
|
|||||||
```
|
```
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useArcadiaSubscription } from "@crema/arcadia-client";
|
import { useArcadiaSubscription } from "@crema/arcadia-core-client";
|
||||||
|
|
||||||
function NotificationToasts() {
|
function NotificationToasts() {
|
||||||
useArcadiaSubscription("notification", (n) => {
|
useArcadiaSubscription("notification", (n) => {
|
||||||
@@ -129,7 +129,7 @@ favourites, DNA-change subscriptions, notifications, search,
|
|||||||
@-mention search), there's a typed wrapper over the generic client:
|
@-mention search), there's a typed wrapper over the generic client:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createArcadiaClient, createSocialBindings } from "@crema/arcadia-client";
|
import { createArcadiaClient, createSocialBindings } from "@crema/arcadia-core-client";
|
||||||
|
|
||||||
const client = createArcadiaClient({ baseUrl, getToken });
|
const client = createArcadiaClient({ baseUrl, getToken });
|
||||||
const social = createSocialBindings(client);
|
const social = createSocialBindings(client);
|
||||||
@@ -156,5 +156,5 @@ Realtime: the social write paths broadcast via Phoenix.PubSub →
|
|||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
- Inline imports only — no own `package.json` (lib lives by the consuming app's deps).
|
- Inline imports only — no own `package.json` (lib lives by the consuming app's deps).
|
||||||
- Path-aliased into apps via `tsconfig.json` `paths`: `@crema/arcadia-client` → `../lib-arcadia-client/src/index.tsx`.
|
- Path-aliased into apps via `tsconfig.json` `paths`: `@crema/arcadia-core-client` → `../lib-arcadia-core-client/src/index.tsx`.
|
||||||
- Tailwind doesn't scan this lib — no UI; nothing to scan.
|
- Tailwind doesn't scan this lib — no UI; nothing to scan.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Fetches the arcadia OpenAPI spec and regenerates ../src/generated/openapi.d.ts.
|
// Fetches the arcadia OpenAPI spec and regenerates ../src/generated/openapi.d.ts.
|
||||||
//
|
//
|
||||||
// Usage (from a consuming app, with arcadia reachable):
|
// Usage (from a consuming app, with arcadia reachable):
|
||||||
// node ../lib-arcadia-client/scripts/sync-spec.mjs
|
// node ../lib-arcadia-core-client/scripts/sync-spec.mjs
|
||||||
//
|
//
|
||||||
// Configurable via env:
|
// Configurable via env:
|
||||||
// ARCADIA_OPENAPI_URL default: http://localhost:4000/api/openapi
|
// ARCADIA_OPENAPI_URL default: http://localhost:4000/api/openapi
|
||||||
|
|||||||
Reference in New Issue
Block a user