@razakalpha/convngx 0.2.0 → 0.2.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 +17 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @razakalpha/convngx
|
|
2
2
|
|
|
3
3
|
Angular-first utilities for Convex with Better Auth:
|
|
4
4
|
- DI-wrapped Convex client with Better Auth token refresh
|
|
@@ -8,13 +8,17 @@ Angular-first utilities for Convex with Better Auth:
|
|
|
8
8
|
|
|
9
9
|
Demo app: projects/example-chat (Angular + Convex + Better Auth)
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Installation
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Install the package and its peer dependencies:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm
|
|
16
|
+
npm install @razakalpha/convngx convex @convex-dev/better-auth better-auth
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
### Peer Dependencies
|
|
20
|
+
|
|
21
|
+
This library provides Angular wrappers and expects Convex + Better Auth to be available in your project.
|
|
18
22
|
## Assumptions
|
|
19
23
|
|
|
20
24
|
This library assumes your Convex backend uses Better Auth (via `@convex-dev/better-auth`) and exposes the Better Auth HTTP endpoints on your Convex site (e.g. `https://YOUR.convex.site`). The Angular providers wire the Convex client to Better Auth, handle proactive token refresh, and optionally support cross‑domain OTT handoff.
|
|
@@ -25,7 +29,7 @@ Register the provider once in your bootstrap:
|
|
|
25
29
|
|
|
26
30
|
```ts
|
|
27
31
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
28
|
-
import { provideConvexAngular } from 'convngx';
|
|
32
|
+
import { provideConvexAngular } from '@razakalpha/convngx';
|
|
29
33
|
import { AppComponent } from './app';
|
|
30
34
|
|
|
31
35
|
bootstrapApplication(AppComponent, {
|
|
@@ -45,7 +49,7 @@ bootstrapApplication(AppComponent, {
|
|
|
45
49
|
Inject the Convex client anywhere:
|
|
46
50
|
|
|
47
51
|
```ts
|
|
48
|
-
import { injectConvex } from 'convngx';
|
|
52
|
+
import { injectConvex } from '@razakalpha/convngx';
|
|
49
53
|
|
|
50
54
|
const convex = injectConvex();
|
|
51
55
|
// convex.query(...), convex.watchQuery(...), convex.mutation(...), convex.action(...)
|
|
@@ -58,7 +62,7 @@ Angular Resource wrapper around Convex watchQuery with smart gating, keep-last,
|
|
|
58
62
|
Core usage:
|
|
59
63
|
|
|
60
64
|
```ts
|
|
61
|
-
import { convexLiveResource } from 'convngx';
|
|
65
|
+
import { convexLiveResource } from '@razakalpha/convngx';
|
|
62
66
|
import { api } from '@/convex/_generated/api';
|
|
63
67
|
|
|
64
68
|
// Live updated with angular resource api
|
|
@@ -110,7 +114,7 @@ function convexLiveResource<Q extends FunctionReference<'query'>>(
|
|
|
110
114
|
|
|
111
115
|
Global default for keep mode (optional DI)
|
|
112
116
|
```ts
|
|
113
|
-
import { provideConvexResourceOptions } from 'convngx';
|
|
117
|
+
import { provideConvexResourceOptions } from '@razakalpha/convngx';
|
|
114
118
|
|
|
115
119
|
bootstrapApplication(App, {
|
|
116
120
|
providers: [
|
|
@@ -126,7 +130,7 @@ Implementation: src/lib/resources/live.resource.ts
|
|
|
126
130
|
A mutation helper that returns an imperative `run()` plus resource-shaped state and derived signals. Supports optimistic updates, callbacks, basic concurrency controls, and retries.
|
|
127
131
|
|
|
128
132
|
```ts
|
|
129
|
-
import { convexMutationResource } from 'convngx';
|
|
133
|
+
import { convexMutationResource } from '@razakalpha/convngx';
|
|
130
134
|
import { api } from '@/convex/_generated/api';
|
|
131
135
|
|
|
132
136
|
// Minimal
|
|
@@ -182,7 +186,7 @@ Implementation: src/lib/resources/mutation.resource.ts
|
|
|
182
186
|
Identical ergonomics to mutations but calls `convex.action`. Useful for long-running or external API calls.
|
|
183
187
|
|
|
184
188
|
```ts
|
|
185
|
-
import { convexActionResource } from 'convngx';
|
|
189
|
+
import { convexActionResource } from '@razakalpha/convngx';
|
|
186
190
|
import { api } from '@/convex/_generated/api';
|
|
187
191
|
|
|
188
192
|
const exportData = convexActionResource(api.reports.export, {
|
|
@@ -238,7 +242,7 @@ Example service (from the chat app) that derives a reactive `isAuthenticated`:
|
|
|
238
242
|
```ts
|
|
239
243
|
// projects/example-chat/src/app/state/convex-auth.state.ts
|
|
240
244
|
import { Injectable, computed, inject, signal } from '@angular/core';
|
|
241
|
-
import { CONVEX, type ConvexAngularClient } from 'convngx';
|
|
245
|
+
import { CONVEX, type ConvexAngularClient } from '@razakalpha/convngx';
|
|
242
246
|
|
|
243
247
|
@Injectable({ providedIn: 'root' })
|
|
244
248
|
export class ConvexAuthState {
|
|
@@ -271,7 +275,7 @@ Snippet from the chat component:
|
|
|
271
275
|
|
|
272
276
|
```ts
|
|
273
277
|
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
|
|
274
|
-
import { convexLiveResource, convexMutationResource } from 'convngx';
|
|
278
|
+
import { convexLiveResource, convexMutationResource } from '@razakalpha/convngx';
|
|
275
279
|
import { api } from 'convex/_generated/api';
|
|
276
280
|
|
|
277
281
|
@Component({ /* ... */ })
|
|
@@ -307,7 +311,7 @@ export class ChatComponent {
|
|
|
307
311
|
## Build
|
|
308
312
|
|
|
309
313
|
```bash
|
|
310
|
-
ng build convngx
|
|
314
|
+
ng build alpha-convngx
|
|
311
315
|
```
|
|
312
316
|
|
|
313
317
|
Outputs to dist/convngx.
|